aboutsummaryrefslogtreecommitdiff
path: root/string.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 /string.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 'string.go')
-rw-r--r--string.go4
1 files changed, 1 insertions, 3 deletions
diff --git a/string.go b/string.go
index e296136..04e0a26 100644
--- a/string.go
+++ b/string.go
@@ -1,7 +1,5 @@
package pflag
-import "fmt"
-
// -- string Value
type stringValue string
@@ -18,7 +16,7 @@ func (s *stringValue) Type() string {
return "string"
}
-func (s *stringValue) String() string { return fmt.Sprintf("%s", *s) }
+func (s *stringValue) String() string { return string(*s) }
func stringConv(sval string) (interface{}, error) {
return sval, nil