aboutsummaryrefslogtreecommitdiff
path: root/int32.go
diff options
context:
space:
mode:
authorbogem <[email protected]>2016-09-10 12:08:47 +0500
committerbogem <[email protected]>2016-09-10 12:08:47 +0500
commitd16d05ecad8d146ef127c975e2e3e167b6e38ad6 (patch)
treea13921d2f956128ed2d1c123d89749db36625645 /int32.go
parent6fd2ff4ff8dfcdf5556fbdc0ac0284408274b1a7 (diff)
Use strconv instead of fmt in values' String funcs
The existing implementation of flag values with fmt package uses more memory and works slower than the implementation with strconv package.
Diffstat (limited to 'int32.go')
-rw-r--r--int32.go7
1 files changed, 2 insertions, 5 deletions
diff --git a/int32.go b/int32.go
index 41659a9..9b95944 100644
--- a/int32.go
+++ b/int32.go
@@ -1,9 +1,6 @@
package pflag
-import (
- "fmt"
- "strconv"
-)
+import "strconv"
// -- int32 Value
type int32Value int32
@@ -23,7 +20,7 @@ func (i *int32Value) Type() string {
return "int32"
}
-func (i *int32Value) String() string { return fmt.Sprintf("%v", *i) }
+func (i *int32Value) String() string { return strconv.FormatInt(int64(*i), 10) }
func int32Conv(sval string) (interface{}, error) {
v, err := strconv.ParseInt(sval, 0, 32)