@@ -18,7 +18,6 @@ func (bytesHex bytesHexValue) String() string {
1818// Set implements pflag.Value.Set.
1919func (bytesHex * bytesHexValue ) Set (value string ) error {
2020 bin , err := hex .DecodeString (strings .TrimSpace (value ))
21-
2221 if err != nil {
2322 return err
2423 }
@@ -39,20 +38,18 @@ func newBytesHexValue(val []byte, p *[]byte) *bytesHexValue {
3938}
4039
4140func bytesHexConv (sval string ) (interface {}, error ) {
42-
4341 bin , err := hex .DecodeString (sval )
4442
4543 if err == nil {
4644 return bin , nil
4745 }
4846
49- return nil , fmt .Errorf ("invalid string being converted to Bytes: %s %s" , sval , err )
47+ return nil , fmt .Errorf ("invalid string being converted to Bytes: %s %s" , sval , err . Error () )
5048}
5149
5250// GetBytesHex return the []byte value of a flag with the given name
5351func (f * FlagSet ) GetBytesHex (name string ) ([]byte , error ) {
5452 val , err := f .getFlagType (name , "bytesHex" , bytesHexConv )
55-
5653 if err != nil {
5754 return []byte {}, err
5855 }
@@ -119,7 +116,6 @@ func (bytesBase64 bytesBase64Value) String() string {
119116// Set implements pflag.Value.Set.
120117func (bytesBase64 * bytesBase64Value ) Set (value string ) error {
121118 bin , err := base64 .StdEncoding .DecodeString (strings .TrimSpace (value ))
122-
123119 if err != nil {
124120 return err
125121 }
@@ -140,19 +136,17 @@ func newBytesBase64Value(val []byte, p *[]byte) *bytesBase64Value {
140136}
141137
142138func bytesBase64ValueConv (sval string ) (interface {}, error ) {
143-
144139 bin , err := base64 .StdEncoding .DecodeString (sval )
145140 if err == nil {
146141 return bin , nil
147142 }
148143
149- return nil , fmt .Errorf ("invalid string being converted to Bytes: %s %s" , sval , err )
144+ return nil , fmt .Errorf ("invalid string being converted to Bytes: %s %s" , sval , err . Error () )
150145}
151146
152147// GetBytesBase64 return the []byte value of a flag with the given name
153148func (f * FlagSet ) GetBytesBase64 (name string ) ([]byte , error ) {
154149 val , err := f .getFlagType (name , "bytesBase64" , bytesBase64ValueConv )
155-
156150 if err != nil {
157151 return []byte {}, err
158152 }
0 commit comments