1
1
mirror of https://github.com/wader/fq.git synced 2024-11-22 07:16:49 +03:00

lint: Fix typeassert and case exhaustive warnings

This commit is contained in:
Mattias Wadman 2022-01-25 17:23:41 +01:00
parent 1e859cdaef
commit 898dfec1d1
4 changed files with 22 additions and 3 deletions

View File

@ -30,6 +30,8 @@ linters-settings:
- rela
- equalisation
- synchronisation
exhaustive:
default-signifies-exhaustive: true
gosec:
excludes:
# allow md5

View File

@ -39,6 +39,8 @@ func Parse(s string) []Token {
sb.WriteRune(r)
ss = doubleQuote
continue
default:
// nop
}
switch r {
@ -107,6 +109,8 @@ func Parse(s string) []Token {
case whitespace:
ss = word
start = i
default:
// nop
}
sb.WriteRune(r)
}
@ -115,6 +119,8 @@ func Parse(s string) []Token {
switch ss {
case word, singleQuote, doubleQuote:
tokens = append(tokens, Token{Start: start, End: len(s), Str: sb.String()})
default:
// nop
}
}
tokens = append(tokens, Token{Separator: true})

View File

@ -989,7 +989,11 @@ func (d *D) TryFieldScalarFn(name string, sfn scalar.Fn, sms ...scalar.Mapper) (
if err != nil {
return &scalar.S{}, err
}
return v.V.(*scalar.S), nil
sr, ok := v.V.(*scalar.S)
if !ok {
panic("not a scalar value")
}
return sr, nil
}
func (d *D) FieldScalarFn(name string, sfn scalar.Fn, sms ...scalar.Mapper) *scalar.S {

View File

@ -965,10 +965,17 @@ func (i *Interp) lookupState(key string) interface{} {
}
func (i *Interp) includePaths() []string {
pathsAny, _ := i.lookupState("include_paths").([]interface{})
pathsAny, ok := i.lookupState("include_paths").([]interface{})
if !ok {
panic("include_paths not slice")
}
var paths []string
for _, pathAny := range pathsAny {
paths = append(paths, pathAny.(string))
path, ok := pathAny.(string)
if !ok {
panic("path not string")
}
paths = append(paths, path)
}
return paths
}