From 6b5ec8fab6460a3aa384e4a83d3acd9873185999 Mon Sep 17 00:00:00 2001 From: Sri Krishna Paritala Date: Tue, 20 Aug 2019 23:28:50 +0530 Subject: [PATCH 01/10] Module aware Added mod files and support for go module libraries --- go.mod | 11 +++++++++++ go.sum | 25 +++++++++++++++++++++++++ parse.go | 27 ++++++++++----------------- 3 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 go.mod create mode 100644 go.sum diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..6a8cb02 --- /dev/null +++ b/go.mod @@ -0,0 +1,11 @@ +module github.com/zimmski/go-mutesting + +go 1.12 + +require ( + github.com/jessevdk/go-flags v1.4.0 + github.com/stretchr/testify v1.4.0 + github.com/zimmski/go-tool v0.0.0-20150119110811-2dfdc9ac8439 + github.com/zimmski/osutil v0.0.0-20190128123334-0d0b3ca231ac + golang.org/x/tools v0.0.0-20190820033707-85edb9ef3283 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e26bf42 --- /dev/null +++ b/go.sum @@ -0,0 +1,25 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= +github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/zimmski/go-tool v0.0.0-20150119110811-2dfdc9ac8439 h1:yHqsjUkj0HWbKPw/6ZqC0/eMklaRpqubA199vaRLzzE= +github.com/zimmski/go-tool v0.0.0-20150119110811-2dfdc9ac8439/go.mod h1:G4FVqCRvfz74AEB1crDNdQuvMfOoKtk7DlePsnV2yGs= +github.com/zimmski/osutil v0.0.0-20190128123334-0d0b3ca231ac h1:uiFRlKzyIzHeLOthe0ethUkSGW7POlqxU3Tc21R8QpQ= +github.com/zimmski/osutil v0.0.0-20190128123334-0d0b3ca231ac/go.mod h1:wJ9WGevuM/rw8aB2pQPFMUgXZWeaouI0ueFamR0DUPE= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20190820033707-85edb9ef3283 h1:Seblypk5Prvsc9UDjPTV/1N+YjNIXQntlZt0EpobDww= +golang.org/x/tools v0.0.0-20190820033707-85edb9ef3283/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/parse.go b/parse.go index 799ead1..3d7e53f 100644 --- a/parse.go +++ b/parse.go @@ -7,9 +7,10 @@ import ( "go/parser" "go/token" "go/types" - "golang.org/x/tools/go/loader" "io/ioutil" "path/filepath" + + "golang.org/x/tools/go/packages" ) // ParseFile parses the content of the given file and returns the corresponding ast.File node and its file set for positional information. @@ -50,32 +51,24 @@ func ParseAndTypeCheckFile(file string) (*ast.File, *token.FileSet, *types.Packa return nil, nil, nil, nil, fmt.Errorf("Could not create build package of %q: %v", file, err) } - var conf = loader.Config{ - ParserMode: parser.AllErrors | parser.ParseComments, - } - - if buildPkg.ImportPath != "." { - conf.Import(buildPkg.ImportPath) - } else { - // This is most definitely the case for files inside a "testdata" package - conf.CreateFromFilenames(dir, fileAbs) - } - - prog, err := conf.Load() + prog, err := packages.Load(&packages.Config{ + Mode: packages.NeedTypes | packages.NeedSyntax | packages.NeedDeps | packages.NeedName | packages.NeedImports | packages.NeedTypesInfo, + }, buildPkg.ImportPath) if err != nil { + fmt.Println(err) return nil, nil, nil, nil, fmt.Errorf("Could not load package of file %q: %v", file, err) } - pkgInfo := prog.InitialPackages()[0] + pkgInfo := prog[0] var src *ast.File - for _, f := range pkgInfo.Files { - if prog.Fset.Position(f.Pos()).Filename == fileAbs { + for _, f := range pkgInfo.Syntax { + if pkgInfo.Fset.Position(f.Pos()).Filename == fileAbs { src = f break } } - return src, prog.Fset, pkgInfo.Pkg, &pkgInfo.Info, nil + return src, pkgInfo.Fset, pkgInfo.Types, pkgInfo.TypesInfo, nil } From a7a7d26e72ebbe77147697bf66d26ebf7eed4cb7 Mon Sep 17 00:00:00 2001 From: Sri Krishna Paritala Date: Wed, 21 Aug 2019 00:46:47 +0530 Subject: [PATCH 02/10] Add Tests Pass --- parse.go | 15 ++++++++++++--- test/mutator.go | 2 +- testdata/branch/mutatecase.go | 2 +- testdata/branch/mutatecase.go.0.go | 2 +- testdata/branch/mutatecase.go.1.go | 2 +- testdata/branch/mutatecase.go.2.go | 2 +- testdata/branch/mutateelse.go | 2 +- testdata/branch/mutateelse.go.0.go | 2 +- testdata/branch/mutateif.go | 2 +- testdata/branch/mutateif.go.0.go | 2 +- testdata/branch/mutateif.go.1.go | 2 +- testdata/expression/comparison.go | 2 +- testdata/expression/comparison.go.0.go | 2 +- testdata/expression/comparison.go.1.go | 2 +- testdata/expression/comparison.go.2.go | 2 +- testdata/expression/comparison.go.3.go | 2 +- testdata/expression/remove.go | 2 +- testdata/expression/remove.go.0.go | 2 +- testdata/expression/remove.go.1.go | 2 +- testdata/expression/remove.go.2.go | 2 +- testdata/expression/remove.go.3.go | 2 +- testdata/expression/remove.go.4.go | 2 +- testdata/expression/remove.go.5.go | 2 +- testdata/statement/remove.go | 2 +- testdata/statement/remove.go.0.go | 2 +- testdata/statement/remove.go.1.go | 2 +- testdata/statement/remove.go.10.go | 2 +- testdata/statement/remove.go.11.go | 2 +- testdata/statement/remove.go.12.go | 2 +- testdata/statement/remove.go.13.go | 2 +- testdata/statement/remove.go.14.go | 2 +- testdata/statement/remove.go.15.go | 2 +- testdata/statement/remove.go.16.go | 2 +- testdata/statement/remove.go.2.go | 2 +- testdata/statement/remove.go.3.go | 2 +- testdata/statement/remove.go.4.go | 2 +- testdata/statement/remove.go.5.go | 2 +- testdata/statement/remove.go.6.go | 2 +- testdata/statement/remove.go.7.go | 2 +- testdata/statement/remove.go.8.go | 2 +- testdata/statement/remove.go.9.go | 2 +- 41 files changed, 52 insertions(+), 43 deletions(-) diff --git a/parse.go b/parse.go index 3d7e53f..71ac00a 100644 --- a/parse.go +++ b/parse.go @@ -39,7 +39,7 @@ func ParseSource(data interface{}) (*ast.File, *token.FileSet, error) { // ParseAndTypeCheckFile parses and type-checks the given file, and returns everything interesting about the file. // If a fatal error is encountered the error return argument is not nil. -func ParseAndTypeCheckFile(file string) (*ast.File, *token.FileSet, *types.Package, *types.Info, error) { +func ParseAndTypeCheckFile(file string, flags ...string) (*ast.File, *token.FileSet, *types.Package, *types.Info, error) { fileAbs, err := filepath.Abs(file) if err != nil { return nil, nil, nil, nil, fmt.Errorf("Could not absolute the file path of %q: %v", file, err) @@ -51,9 +51,18 @@ func ParseAndTypeCheckFile(file string) (*ast.File, *token.FileSet, *types.Packa return nil, nil, nil, nil, fmt.Errorf("Could not create build package of %q: %v", file, err) } + pkgPath := buildPkg.ImportPath + if buildPkg.ImportPath == "." { + pkgPath = dir + } + prog, err := packages.Load(&packages.Config{ - Mode: packages.NeedTypes | packages.NeedSyntax | packages.NeedDeps | packages.NeedName | packages.NeedImports | packages.NeedTypesInfo, - }, buildPkg.ImportPath) + ParseFile: func(fset *token.FileSet, filename string, src []byte) (*ast.File, error) { + return parser.ParseFile(fset, filename, src, parser.ParseComments|parser.AllErrors) + }, + BuildFlags: flags, + Mode: packages.NeedTypes | packages.NeedSyntax | packages.NeedDeps | packages.NeedName | packages.NeedImports | packages.NeedTypesInfo | packages.NeedFiles, + }, pkgPath) if err != nil { fmt.Println(err) return nil, nil, nil, nil, fmt.Errorf("Could not load package of file %q: %v", file, err) diff --git a/test/mutator.go b/test/mutator.go index f195430..a1455c0 100644 --- a/test/mutator.go +++ b/test/mutator.go @@ -24,7 +24,7 @@ func Mutator(t *testing.T, m mutator.Mutator, testFile string, count int) { assert.Nil(t, err) // Parse and type-check the original source code - src, fset, pkg, info, err := mutesting.ParseAndTypeCheckFile(testFile) + src, fset, pkg, info, err := mutesting.ParseAndTypeCheckFile(testFile, `-tags=test`) assert.Nil(t, err) // Mutate a non relevant node diff --git a/testdata/branch/mutatecase.go b/testdata/branch/mutatecase.go index d95899e..b0de8ff 100644 --- a/testdata/branch/mutatecase.go +++ b/testdata/branch/mutatecase.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/branch/mutatecase.go.0.go b/testdata/branch/mutatecase.go.0.go index a757ce0..6e2779b 100644 --- a/testdata/branch/mutatecase.go.0.go +++ b/testdata/branch/mutatecase.go.0.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/branch/mutatecase.go.1.go b/testdata/branch/mutatecase.go.1.go index 8f6316a..3168091 100644 --- a/testdata/branch/mutatecase.go.1.go +++ b/testdata/branch/mutatecase.go.1.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/branch/mutatecase.go.2.go b/testdata/branch/mutatecase.go.2.go index 3bed4b3..c96d82b 100644 --- a/testdata/branch/mutatecase.go.2.go +++ b/testdata/branch/mutatecase.go.2.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/branch/mutateelse.go b/testdata/branch/mutateelse.go index 1675adb..7667024 100644 --- a/testdata/branch/mutateelse.go +++ b/testdata/branch/mutateelse.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/branch/mutateelse.go.0.go b/testdata/branch/mutateelse.go.0.go index ee3c223..48a351c 100644 --- a/testdata/branch/mutateelse.go.0.go +++ b/testdata/branch/mutateelse.go.0.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/branch/mutateif.go b/testdata/branch/mutateif.go index 1675adb..7667024 100644 --- a/testdata/branch/mutateif.go +++ b/testdata/branch/mutateif.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/branch/mutateif.go.0.go b/testdata/branch/mutateif.go.0.go index fb45fb7..d94fa77 100644 --- a/testdata/branch/mutateif.go.0.go +++ b/testdata/branch/mutateif.go.0.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/branch/mutateif.go.1.go b/testdata/branch/mutateif.go.1.go index 694cf07..6822dfc 100644 --- a/testdata/branch/mutateif.go.1.go +++ b/testdata/branch/mutateif.go.1.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/expression/comparison.go b/testdata/expression/comparison.go index 6b50425..29867df 100644 --- a/testdata/expression/comparison.go +++ b/testdata/expression/comparison.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/expression/comparison.go.0.go b/testdata/expression/comparison.go.0.go index bdf38a6..8b77521 100644 --- a/testdata/expression/comparison.go.0.go +++ b/testdata/expression/comparison.go.0.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/expression/comparison.go.1.go b/testdata/expression/comparison.go.1.go index 77f87a2..fbeac4c 100644 --- a/testdata/expression/comparison.go.1.go +++ b/testdata/expression/comparison.go.1.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/expression/comparison.go.2.go b/testdata/expression/comparison.go.2.go index 088917a..912cb5f 100644 --- a/testdata/expression/comparison.go.2.go +++ b/testdata/expression/comparison.go.2.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/expression/comparison.go.3.go b/testdata/expression/comparison.go.3.go index 81577c6..1a7bfcf 100644 --- a/testdata/expression/comparison.go.3.go +++ b/testdata/expression/comparison.go.3.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/expression/remove.go b/testdata/expression/remove.go index 20e1ed4..5825fae 100644 --- a/testdata/expression/remove.go +++ b/testdata/expression/remove.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/expression/remove.go.0.go b/testdata/expression/remove.go.0.go index 8a0ad0f..3e4b94b 100644 --- a/testdata/expression/remove.go.0.go +++ b/testdata/expression/remove.go.0.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/expression/remove.go.1.go b/testdata/expression/remove.go.1.go index d95c7f0..80aec28 100644 --- a/testdata/expression/remove.go.1.go +++ b/testdata/expression/remove.go.1.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/expression/remove.go.2.go b/testdata/expression/remove.go.2.go index d2c99b8..01ab57c 100644 --- a/testdata/expression/remove.go.2.go +++ b/testdata/expression/remove.go.2.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/expression/remove.go.3.go b/testdata/expression/remove.go.3.go index 894ec39..35b8b7b 100644 --- a/testdata/expression/remove.go.3.go +++ b/testdata/expression/remove.go.3.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/expression/remove.go.4.go b/testdata/expression/remove.go.4.go index 5db754c..6bd6bf6 100644 --- a/testdata/expression/remove.go.4.go +++ b/testdata/expression/remove.go.4.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/expression/remove.go.5.go b/testdata/expression/remove.go.5.go index f150a52..1a1164a 100644 --- a/testdata/expression/remove.go.5.go +++ b/testdata/expression/remove.go.5.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package main diff --git a/testdata/statement/remove.go b/testdata/statement/remove.go index bd26b31..311a888 100644 --- a/testdata/statement/remove.go +++ b/testdata/statement/remove.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.0.go b/testdata/statement/remove.go.0.go index 2eada2f..82ce0f9 100644 --- a/testdata/statement/remove.go.0.go +++ b/testdata/statement/remove.go.0.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.1.go b/testdata/statement/remove.go.1.go index 0734932..35ed101 100644 --- a/testdata/statement/remove.go.1.go +++ b/testdata/statement/remove.go.1.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.10.go b/testdata/statement/remove.go.10.go index eaf9c59..eb320e0 100644 --- a/testdata/statement/remove.go.10.go +++ b/testdata/statement/remove.go.10.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.11.go b/testdata/statement/remove.go.11.go index 2c18271..e9b53ec 100644 --- a/testdata/statement/remove.go.11.go +++ b/testdata/statement/remove.go.11.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.12.go b/testdata/statement/remove.go.12.go index fc9c503..8eb148d 100644 --- a/testdata/statement/remove.go.12.go +++ b/testdata/statement/remove.go.12.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.13.go b/testdata/statement/remove.go.13.go index 5ac9088..35873e5 100644 --- a/testdata/statement/remove.go.13.go +++ b/testdata/statement/remove.go.13.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.14.go b/testdata/statement/remove.go.14.go index 3923640..5927eb5 100644 --- a/testdata/statement/remove.go.14.go +++ b/testdata/statement/remove.go.14.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.15.go b/testdata/statement/remove.go.15.go index 87cfe11..cae810b 100644 --- a/testdata/statement/remove.go.15.go +++ b/testdata/statement/remove.go.15.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.16.go b/testdata/statement/remove.go.16.go index 437b904..8061c8f 100644 --- a/testdata/statement/remove.go.16.go +++ b/testdata/statement/remove.go.16.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.2.go b/testdata/statement/remove.go.2.go index f44686b..282dddf 100644 --- a/testdata/statement/remove.go.2.go +++ b/testdata/statement/remove.go.2.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.3.go b/testdata/statement/remove.go.3.go index f44686b..282dddf 100644 --- a/testdata/statement/remove.go.3.go +++ b/testdata/statement/remove.go.3.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.4.go b/testdata/statement/remove.go.4.go index d5ff2ec..915d2c7 100644 --- a/testdata/statement/remove.go.4.go +++ b/testdata/statement/remove.go.4.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.5.go b/testdata/statement/remove.go.5.go index 820477e..8675eb7 100644 --- a/testdata/statement/remove.go.5.go +++ b/testdata/statement/remove.go.5.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.6.go b/testdata/statement/remove.go.6.go index ae90ac9..793ddfb 100644 --- a/testdata/statement/remove.go.6.go +++ b/testdata/statement/remove.go.6.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.7.go b/testdata/statement/remove.go.7.go index 3536e61..dba41c2 100644 --- a/testdata/statement/remove.go.7.go +++ b/testdata/statement/remove.go.7.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.8.go b/testdata/statement/remove.go.8.go index fa569e4..8312e55 100644 --- a/testdata/statement/remove.go.8.go +++ b/testdata/statement/remove.go.8.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example diff --git a/testdata/statement/remove.go.9.go b/testdata/statement/remove.go.9.go index 6b5481f..560844d 100644 --- a/testdata/statement/remove.go.9.go +++ b/testdata/statement/remove.go.9.go @@ -1,4 +1,4 @@ -// +build example-main +// +build test package example From c2d67fb5361c994e3306875cdd28d78d2ea38d37 Mon Sep 17 00:00:00 2001 From: Sri Krishna Paritala Date: Wed, 21 Aug 2019 00:49:59 +0530 Subject: [PATCH 03/10] Version Change Added go 1.12 to Travis and reduced minimum version to go 1.10 in mod file --- .travis.yml | 1 + go.mod | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0dbc9a0..d742529 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ os: go: - 1.10.x - 1.11.x + - 1.12.x install: - make install-dependencies diff --git a/go.mod b/go.mod index 6a8cb02..7757792 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/zimmski/go-mutesting -go 1.12 +go 1.10 require ( github.com/jessevdk/go-flags v1.4.0 From d1b1cbefa11a98930d1d9e752ab967849898cb4e Mon Sep 17 00:00:00 2001 From: David Poros Date: Mon, 21 Oct 2019 13:36:47 +0200 Subject: [PATCH 04/10] Enable go modules in travis builds --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d742529..dd4e7be 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,7 +7,10 @@ os: go: - 1.10.x - 1.11.x - - 1.12.x + +env: + global: + - GO111MODULE: "on" install: - make install-dependencies From d0aa590386a3d98b3a92d4cdc4d5d7dbe72c3fe1 Mon Sep 17 00:00:00 2001 From: David Poros Date: Mon, 21 Oct 2019 14:33:28 +0200 Subject: [PATCH 05/10] fix makefile and linter according to go modules --- Makefile | 18 +++++++++--------- go.mod | 14 +++++++++++++- go.sum | 39 +++++++++++++++++++++++++++++++++++++++ scripts/lint.sh | 10 +++++----- 4 files changed, 66 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 6f387fd..019d956 100644 --- a/Makefile +++ b/Makefile @@ -36,24 +36,24 @@ install: .PHONY: install install-dependencies: - go get -t -v $(PKG)/... + go mod vendor go test -i -v $(PKG)/... .PHONY: install-dependencies install-tools: # generation - go get -u -v golang.org/x/tools/cmd/stringer + go get golang.org/x/tools/cmd/stringer # linting - go get -u -v golang.org/x/lint/golint/... - go get -u -v github.com/kisielk/errcheck/... - go get -u -v honnef.co/go/tools/cmd/megacheck + go get golang.org/x/lint/golint + go get github.com/kisielk/errcheck + go get honnef.co/go/tools # code coverage - go get -u -v golang.org/x/tools/cmd/cover - go get -u -v github.com/onsi/ginkgo/ginkgo/... - go get -u -v github.com/modocache/gover/... - go get -u -v github.com/mattn/goveralls/... + go get golang.org/x/tools/cmd/cover + go get github.com/onsi/ginkgo/ginkgo + go get github.com/modocache/gover + go get github.com/mattn/goveralls .PHONY: install-tools lint: diff --git a/go.mod b/go.mod index 7757792..8d82686 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,21 @@ module github.com/zimmski/go-mutesting go 1.10 require ( + github.com/davecgh/go-spew v1.1.0 + github.com/hpcloud/tail v1.0.0 // indirect github.com/jessevdk/go-flags v1.4.0 + github.com/kisielk/errcheck v1.2.0 // indirect + github.com/mattn/goveralls v0.0.3 // indirect + github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5 // indirect + github.com/onsi/ginkgo v1.10.2 // indirect + github.com/pmezard/go-difflib v1.0.0 github.com/stretchr/testify v1.4.0 github.com/zimmski/go-tool v0.0.0-20150119110811-2dfdc9ac8439 github.com/zimmski/osutil v0.0.0-20190128123334-0d0b3ca231ac - golang.org/x/tools v0.0.0-20190820033707-85edb9ef3283 + golang.org/x/lint v0.0.0-20190930215403-16217165b5de // indirect + golang.org/x/tools v0.0.0-20191018212557-ed542cd5b28a + gopkg.in/fsnotify.v1 v1.4.7 // indirect + gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect + gopkg.in/yaml.v2 v2.2.2 + honnef.co/go/tools v0.0.1-2019.2.3 // indirect ) diff --git a/go.sum b/go.sum index e26bf42..153ffbc 100644 --- a/go.sum +++ b/go.sum @@ -1,9 +1,27 @@ +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGARJA= github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= +github.com/kisielk/errcheck v1.2.0 h1:reN85Pxc5larApoH1keMBiu2GWtPqXQ1nc9gx+jOU+E= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/mattn/goveralls v0.0.3 h1:GnFhBAK0wJmxZBum88FqDzcDPLjAk9sL0HzhmW+9bo8= +github.com/mattn/goveralls v0.0.3/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5 h1:8Q0qkMVC/MmWkpIdlvZgcv2o2jrlF6zqVOh7W5YHdMA= +github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= +github.com/onsi/ginkgo v1.10.2 h1:uqH7bpe+ERSiDa34FDOF7RikN6RzXgduUF8yarlZp94= +github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= @@ -12,14 +30,35 @@ github.com/zimmski/go-tool v0.0.0-20150119110811-2dfdc9ac8439/go.mod h1:G4FVqCRv github.com/zimmski/osutil v0.0.0-20190128123334-0d0b3ca231ac h1:uiFRlKzyIzHeLOthe0ethUkSGW7POlqxU3Tc21R8QpQ= github.com/zimmski/osutil v0.0.0-20190128123334-0d0b3ca231ac/go.mod h1:wJ9WGevuM/rw8aB2pQPFMUgXZWeaouI0ueFamR0DUPE= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= golang.org/x/tools v0.0.0-20190820033707-85edb9ef3283 h1:Seblypk5Prvsc9UDjPTV/1N+YjNIXQntlZt0EpobDww= golang.org/x/tools v0.0.0-20190820033707-85edb9ef3283/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191018212557-ed542cd5b28a h1:UuQ+70Pi/ZdWHuP4v457pkXeOynTdgd/4enxeIO/98k= +golang.org/x/tools v0.0.0-20191018212557-ed542cd5b28a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +honnef.co/go/tools v0.0.1-2019.2.3 h1:3JgtbtFHMiCmsznwGVTUWbgGov+pVqnlf1dEJTNAXeM= +honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= diff --git a/scripts/lint.sh b/scripts/lint.sh index e8af6d8..a48bf6a 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -4,23 +4,23 @@ if [ -z ${PKG+x} ]; then echo "PKG is not set"; exit 1; fi if [ -z ${ROOT_DIR+x} ]; then echo "ROOT_DIR is not set"; exit 1; fi echo "gofmt:" -OUT=$(gofmt -l -s $ROOT_DIR 2>&1 | grep --invert-match -E "(/example)") +OUT=$(gofmt -l -s $ROOT_DIR 2>&1 | grep --invert-match -E "(/(example|vendor))") if [ -n "$OUT" ]; then echo "$OUT"; PROBLEM=1; fi echo "errcheck:" -OUT=$(errcheck $PKG/... 2>&1 | grep --invert-match -E "(/example)") +OUT=$(errcheck $PKG/... 2>&1 | grep --invert-match -E "(/(example|vendor))") if [ -n "$OUT" ]; then echo "$OUT"; PROBLEM=1; fi echo "go vet:" -OUT=$(go tool vet -all=true -v=true $ROOT_DIR 2>&1 | grep --invert-match -E "(Checking file|\%p of wrong type|can't check non-constant format|/example)") +OUT=$(go vet -all=true -v=true $ROOT_DIR 2>&1 | grep --invert-match -E "(Checking file|\%p of wrong type|can't check non-constant format|/example|/vendor)") if [ -n "$OUT" ]; then echo "$OUT"; PROBLEM=1; fi echo "golint:" -OUT=$(golint $PKG/... 2>&1 | grep --invert-match -E "(/example)") +OUT=$(golint $PKG/... 2>&1 | grep --invert-match -E "(/(example|vendor))") if [ -n "$OUT" ]; then echo "$OUT"; PROBLEM=1; fi echo "megacheck:" -OUT=$(megacheck $PKG/... 2>&1 | grep --invert-match -E "(example/)") +OUT=$(megacheck $PKG/... 2>&1 | grep --invert-match -E "(/(example|vendor))") if [ -n "$OUT" ]; then echo "$OUT"; PROBLEM=1; fi if [ -n "$PROBLEM" ]; then exit 1; fi From dc46625b859fc5723519b2cd161239b5aa688605 Mon Sep 17 00:00:00 2001 From: David Poros Date: Mon, 21 Oct 2019 14:35:27 +0200 Subject: [PATCH 06/10] Remove go 1.10 build because it does not support go modules --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index dd4e7be..3a77dcf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,8 @@ os: - osx go: - - 1.10.x - 1.11.x + - 1.12.x env: global: From 36dfc23f515ac3e1527e49a77a065d587780022d Mon Sep 17 00:00:00 2001 From: David Poros Date: Mon, 21 Oct 2019 14:43:06 +0200 Subject: [PATCH 07/10] Fix tools installion --- Makefile | 12 ++++++------ go.sum | 5 +++++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 019d956..e35747d 100644 --- a/Makefile +++ b/Makefile @@ -45,15 +45,15 @@ install-tools: go get golang.org/x/tools/cmd/stringer # linting - go get golang.org/x/lint/golint - go get github.com/kisielk/errcheck - go get honnef.co/go/tools + go get golang.org/x/lint/golint/... + go get github.com/kisielk/errcheck/... + go get honnef.co/go/tools/... # code coverage go get golang.org/x/tools/cmd/cover - go get github.com/onsi/ginkgo/ginkgo - go get github.com/modocache/gover - go get github.com/mattn/goveralls + go get github.com/onsi/ginkgo/ginkgo/... + go get github.com/modocache/gover/... + go get github.com/mattn/goveralls/... .PHONY: install-tools lint: diff --git a/go.sum b/go.sum index 153ffbc..1744119 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,8 @@ +github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= @@ -8,6 +10,7 @@ github.com/jessevdk/go-flags v1.4.0 h1:4IU2WS7AumrZ/40jfhf4QVDMsQwqA7VEHozFRrGAR github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI= github.com/kisielk/errcheck v1.2.0 h1:reN85Pxc5larApoH1keMBiu2GWtPqXQ1nc9gx+jOU+E= github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= @@ -20,6 +23,7 @@ github.com/onsi/ginkgo v1.10.2 h1:uqH7bpe+ERSiDa34FDOF7RikN6RzXgduUF8yarlZp94= github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.3.0 h1:RR9dF3JtopPvtkroDZuVD7qquD0bnHlKSqaQhgwt8yk= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -33,6 +37,7 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e h1:JgcxKXxCjrA2tyDP/aNU9K0Ck5Czfk6C7e2tMw7+bSI= golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= From 967977d48b4b8107537294b5cd796139ff42e4d7 Mon Sep 17 00:00:00 2001 From: David Poros Date: Mon, 21 Oct 2019 14:47:47 +0200 Subject: [PATCH 08/10] Use staticcheck instead of megacheck because it has been removed --- scripts/lint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index a48bf6a..48c7853 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -19,8 +19,8 @@ echo "golint:" OUT=$(golint $PKG/... 2>&1 | grep --invert-match -E "(/(example|vendor))") if [ -n "$OUT" ]; then echo "$OUT"; PROBLEM=1; fi -echo "megacheck:" -OUT=$(megacheck $PKG/... 2>&1 | grep --invert-match -E "(/(example|vendor))") +echo "staticcheck:" +OUT=$(staticcheck $PKG/... 2>&1 | grep --invert-match -E "(/(example|vendor))") if [ -n "$OUT" ]; then echo "$OUT"; PROBLEM=1; fi if [ -n "$PROBLEM" ]; then exit 1; fi From 92e15443005c2793df09c89949433765f8be43eb Mon Sep 17 00:00:00 2001 From: David Poros Date: Mon, 21 Oct 2019 14:51:12 +0200 Subject: [PATCH 09/10] Fix staticcheck error ST1005 --- parse.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/parse.go b/parse.go index 71ac00a..6f16a7d 100644 --- a/parse.go +++ b/parse.go @@ -42,13 +42,13 @@ func ParseSource(data interface{}) (*ast.File, *token.FileSet, error) { func ParseAndTypeCheckFile(file string, flags ...string) (*ast.File, *token.FileSet, *types.Package, *types.Info, error) { fileAbs, err := filepath.Abs(file) if err != nil { - return nil, nil, nil, nil, fmt.Errorf("Could not absolute the file path of %q: %v", file, err) + return nil, nil, nil, nil, fmt.Errorf("could not absolute the file path of %q: %v", file, err) } dir := filepath.Dir(fileAbs) buildPkg, err := build.ImportDir(dir, build.FindOnly) if err != nil { - return nil, nil, nil, nil, fmt.Errorf("Could not create build package of %q: %v", file, err) + return nil, nil, nil, nil, fmt.Errorf("could not create build package of %q: %v", file, err) } pkgPath := buildPkg.ImportPath @@ -65,7 +65,7 @@ func ParseAndTypeCheckFile(file string, flags ...string) (*ast.File, *token.File }, pkgPath) if err != nil { fmt.Println(err) - return nil, nil, nil, nil, fmt.Errorf("Could not load package of file %q: %v", file, err) + return nil, nil, nil, nil, fmt.Errorf("could not load package of file %q: %v", file, err) } pkgInfo := prog[0] From 90970dc0b939b75fc30077d8b3f1e67cb5103981 Mon Sep 17 00:00:00 2001 From: David Poros Date: Mon, 21 Oct 2019 14:55:53 +0200 Subject: [PATCH 10/10] Fix linter - Remove verbosity from go vet - Fix staticcheck regex --- scripts/lint.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/lint.sh b/scripts/lint.sh index 48c7853..26c27ff 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -12,7 +12,7 @@ OUT=$(errcheck $PKG/... 2>&1 | grep --invert-match -E "(/(example|vendor))") if [ -n "$OUT" ]; then echo "$OUT"; PROBLEM=1; fi echo "go vet:" -OUT=$(go vet -all=true -v=true $ROOT_DIR 2>&1 | grep --invert-match -E "(Checking file|\%p of wrong type|can't check non-constant format|/example|/vendor)") +OUT=$(go vet -all=true $ROOT_DIR 2>&1 | grep --invert-match -E "(Checking file|\%p of wrong type|can't check non-constant format|/example|/vendor)") if [ -n "$OUT" ]; then echo "$OUT"; PROBLEM=1; fi echo "golint:" @@ -20,7 +20,7 @@ OUT=$(golint $PKG/... 2>&1 | grep --invert-match -E "(/(example|vendor))") if [ -n "$OUT" ]; then echo "$OUT"; PROBLEM=1; fi echo "staticcheck:" -OUT=$(staticcheck $PKG/... 2>&1 | grep --invert-match -E "(/(example|vendor))") +OUT=$(staticcheck $PKG/... 2>&1 | grep --invert-match -E "((example|vendor)/)") if [ -n "$OUT" ]; then echo "$OUT"; PROBLEM=1; fi if [ -n "$PROBLEM" ]; then exit 1; fi