From d16d05ecad8d146ef127c975e2e3e167b6e38ad6 Mon Sep 17 00:00:00 2001 From: bogem Date: Sat, 10 Sep 2016 12:08:47 +0500 Subject: 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. --- string.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'string.go') 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 -- cgit v1.2.3