staticcheck (#313)
* CI: use staticcheck for linting This commit switches the linter for Go code from golint to staticcheck. Golint has been deprecated since last year and staticcheck is a recommended replacement. Signed-off-by: Lucas Servén Marín <lserven@gmail.com> * revendor Signed-off-by: Lucas Servén Marín <lserven@gmail.com> * cmd,pkg: fix lint warnings Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
This commit is contained in:
committed by
GitHub
parent
93f46e03ea
commit
50fbc2eec2
51
vendor/honnef.co/go/tools/pattern/fuzz.go
vendored
Normal file
51
vendor/honnef.co/go/tools/pattern/fuzz.go
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
//go:build gofuzz
|
||||
// +build gofuzz
|
||||
|
||||
package pattern
|
||||
|
||||
import (
|
||||
"go/ast"
|
||||
goparser "go/parser"
|
||||
"go/token"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var files []*ast.File
|
||||
|
||||
func init() {
|
||||
fset := token.NewFileSet()
|
||||
filepath.Walk("/usr/lib/go/src", func(path string, info os.FileInfo, err error) error {
|
||||
if err != nil {
|
||||
// XXX error handling
|
||||
panic(err)
|
||||
}
|
||||
if !strings.HasSuffix(path, ".go") {
|
||||
return nil
|
||||
}
|
||||
f, err := goparser.ParseFile(fset, path, nil, 0)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
files = append(files, f)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func Fuzz(data []byte) int {
|
||||
p := &Parser{}
|
||||
pat, err := p.Parse(string(data))
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "internal error") {
|
||||
panic(err)
|
||||
}
|
||||
return 0
|
||||
}
|
||||
_ = pat.Root.String()
|
||||
|
||||
for _, f := range files {
|
||||
Match(pat.Root, f)
|
||||
}
|
||||
return 1
|
||||
}
|
||||
Reference in New Issue
Block a user