From 1076f5ee1f54b8e1a61669b2b3ba64d3985ff71b Mon Sep 17 00:00:00 2001 From: Alec Thomas Date: Fri, 21 Jun 2019 10:07:24 +1000 Subject: [PATCH] Remove unused return value from PopValueInto. --- mapper.go | 18 +++++++++--------- mapper_test.go | 2 +- resolver_test.go | 2 +- scanner.go | 16 ++++++++-------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/mapper.go b/mapper.go index 46f13a7..58e45bb 100644 --- a/mapper.go +++ b/mapper.go @@ -196,7 +196,7 @@ func (r *Registry) RegisterDefaults() *Registry { RegisterKind(reflect.Float32, floatDecoder(32)). RegisterKind(reflect.Float64, floatDecoder(64)). RegisterKind(reflect.String, MapperFunc(func(ctx *DecodeContext, target reflect.Value) error { - _, err := ctx.Scan.PopValueInto("string", target.Addr().Interface()) + err := ctx.Scan.PopValueInto("string", target.Addr().Interface()) return err })). RegisterKind(reflect.Bool, boolMapper{}). @@ -235,7 +235,7 @@ func (boolMapper) IsBool() bool { return true } func durationDecoder() MapperFunc { return func(ctx *DecodeContext, target reflect.Value) error { var value string - if _, err := ctx.Scan.PopValueInto("duration", &value); err != nil { + if err := ctx.Scan.PopValueInto("duration", &value); err != nil { return err } r, err := time.ParseDuration(value) @@ -254,7 +254,7 @@ func timeDecoder() MapperFunc { format = ctx.Value.Format } var value string - if _, err := ctx.Scan.PopValueInto("time", &value); err != nil { + if err := ctx.Scan.PopValueInto("time", &value); err != nil { return err } t, err := time.Parse(format, value) @@ -388,7 +388,7 @@ func mapDecoder(r *Registry) MapperFunc { } for !childScanner.Peek().IsEOL() { var token string - _, err := childScanner.PopValueInto("map", &token) + err := childScanner.PopValueInto("map", &token) if err != nil { return err } @@ -478,7 +478,7 @@ func pathMapper(r *Registry) MapperFunc { return errors.Errorf("\"path\" type must be applied to a string not %s", target.Type()) } var path string - _, err := ctx.Scan.PopValueInto("file", &path) + err := ctx.Scan.PopValueInto("file", &path) if err != nil { return err } @@ -497,7 +497,7 @@ func existingFileMapper(r *Registry) MapperFunc { return errors.Errorf("\"existingfile\" type must be applied to a string not %s", target.Type()) } var path string - _, err := ctx.Scan.PopValueInto("file", &path) + err := ctx.Scan.PopValueInto("file", &path) if err != nil { return err } @@ -523,7 +523,7 @@ func existingDirMapper(r *Registry) MapperFunc { return errors.Errorf("\"existingdir\" must be applied to a string not %s", target.Type()) } var path string - _, err := ctx.Scan.PopValueInto("file", &path) + err := ctx.Scan.PopValueInto("file", &path) if err != nil { return err } @@ -543,7 +543,7 @@ func existingDirMapper(r *Registry) MapperFunc { func urlMapper() MapperFunc { return func(ctx *DecodeContext, target reflect.Value) error { var urlStr string - _, err := ctx.Scan.PopValueInto("url", &urlStr) + err := ctx.Scan.PopValueInto("url", &urlStr) if err != nil { return err } @@ -601,7 +601,7 @@ type FileContentFlag []byte func (f *FileContentFlag) Decode(ctx *DecodeContext) error { // nolint: golint var filename string - _, err := ctx.Scan.PopValueInto("filename", &filename) + err := ctx.Scan.PopValueInto("filename", &filename) if err != nil { return err } diff --git a/mapper_test.go b/mapper_test.go index a69f36b..12def43 100644 --- a/mapper_test.go +++ b/mapper_test.go @@ -140,7 +140,7 @@ type mappedValue struct { } func (m *mappedValue) Decode(ctx *kong.DecodeContext) error { - _, err := ctx.Scan.PopValueInto("mapped", &m.decoded) + err := ctx.Scan.PopValueInto("mapped", &m.decoded) return err } diff --git a/resolver_test.go b/resolver_test.go index 8e37aee..fa9f41b 100644 --- a/resolver_test.go +++ b/resolver_test.go @@ -123,7 +123,7 @@ type testUppercaseMapper struct{} func (testUppercaseMapper) Decode(ctx *kong.DecodeContext, target reflect.Value) error { var value string - _, err := ctx.Scan.PopValueInto("lowercase", &value) + err := ctx.Scan.PopValueInto("lowercase", &value) if err != nil { return err } diff --git a/scanner.go b/scanner.go index b805736..c8c3636 100644 --- a/scanner.go +++ b/scanner.go @@ -14,11 +14,11 @@ type TokenType int const ( UntypedToken TokenType = iota EOLToken - FlagToken // -- - FlagValueToken // = - ShortFlagToken // -[ - PositionalArgumentToken // + FlagToken // -- + FlagValueToken // = + ShortFlagToken // -[ + PositionalArgumentToken // ) func (t TokenType) String() string { @@ -156,12 +156,12 @@ func (s *Scanner) PopValue(context string) (Token, error) { // PopValueInto pops a value token into target or returns an error. // // "context" is used to assist the user if the value can not be popped, eg. "expected value but got " -func (s *Scanner) PopValueInto(context string, target interface{}) (Token, error) { +func (s *Scanner) PopValueInto(context string, target interface{}) error { t := s.Pop() if !t.IsValue() { - return t, errors.Errorf("expected %s value but got %q (%s)", context, t, t.InferredType()) + return errors.Errorf("expected %s value but got %q (%s)", context, t, t.InferredType()) } - return t, jsonTranscode(t.Value, target) + return jsonTranscode(t.Value, target) } // PopWhile predicate returns true.