1
0
mirror of https://github.com/golang/go synced 2024-11-18 15:24:41 -07:00
go/cmd/stringer
Daniel Martí bd4635fd25 cmd/stringer: use strconv instead of fmt
In the generated code, we want to pull in as few dependencies as
possible. fmt is heavier than strconv, and the latter can be used with a
bit of extra code for the same results.

More importantly, this will allow stringer to be used in some std
packages that cannot import fmt, such as regexp/syntax. While strconv
lies in L2 in deps_test.go, fmt lies in L4.

This means that many other packages will also be able to use stringer
where it could be useful, such as path/filepath, os/exec, or io/ioutil.

Since some of these types may be 64-bit integers, use FormatInt instead
of Itoa to avoid overflows with int on 32-bit.

Also double-checked that the generated code is still formatted properly.

Change-Id: Iffb3bd2df5c94407705689719240aca0c7474a89
Reviewed-on: https://go-review.googlesource.com/77473
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-11-14 15:22:39 +00:00
..
testdata cmd/stringer: fix panic caused by integer overflow 2015-06-02 19:44:20 +00:00
endtoend_test.go cmd/stringer: fix typo in test log message ("no" -> "not") 2017-11-07 22:55:16 +00:00
golden_test.go cmd/stringer: use strconv instead of fmt 2017-11-14 15:22:39 +00:00
importer18.go cmd/stringer: use source importer when available 2017-04-12 18:56:47 +00:00
importer19.go cmd/stringer: use source importer when available 2017-04-12 18:56:47 +00:00
stringer.go cmd/stringer: use strconv instead of fmt 2017-11-14 15:22:39 +00:00
util_test.go go.tools/cmd/stringer: add tests 2014-09-04 14:16:59 -07:00