diff --git a/.travis.yml b/.travis.yml index f2075962..982bb5e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ language: go go: - 1.9.x - 1.10.x - - 1.11beta2 + # - 1.11beta2 - https://github.com/golang/go/issues/26671 script: make check_generated test after_success: @@ -22,4 +22,5 @@ deploy: tags: true # it's important to build on the newest version of go: # - go1.11 type checking properly supports _wasm.go file, without that golangci-lint won't compile program with go 1.11 env - condition: $TRAVIS_GO_VERSION =~ ^1\.11 + # but currently go1.11 has bugs, so we build on go1.10 + condition: $TRAVIS_GO_VERSION =~ ^1\.10\. diff --git a/pkg/lint/astcache/astcache.go b/pkg/lint/astcache/astcache.go index e903eb09..b7df0cf1 100644 --- a/pkg/lint/astcache/astcache.go +++ b/pkg/lint/astcache/astcache.go @@ -77,17 +77,21 @@ func LoadFromProgram(prog *loader.Program, log logutils.Log) (*Cache, error) { continue } - relPath, err := filepath.Rel(root, pos.Filename) - if err != nil { - c.log.Warnf("Can't get relative path for %s and %s: %s", - root, pos.Filename, err) - continue + path := pos.Filename + if filepath.IsAbs(path) { + relPath, err := filepath.Rel(root, pos.Filename) + if err != nil { + c.log.Warnf("Can't get relative path for %s and %s: %s", + root, pos.Filename, err) + continue + } + path = relPath } - c.m[relPath] = &File{ + c.m[path] = &File{ F: f, Fset: prog.Fset, - Name: relPath, + Name: path, } } } diff --git a/pkg/result/processors/autogenerated_exclude.go b/pkg/result/processors/autogenerated_exclude.go index b49c5e70..ac5bdc6d 100644 --- a/pkg/result/processors/autogenerated_exclude.go +++ b/pkg/result/processors/autogenerated_exclude.go @@ -117,8 +117,11 @@ func getDoc(f *ast.File, fset *token.FileSet, filePath string) string { filePos := fset.Position(pos) text := g.Text() - // files using cgo have implicitly added comment "Created by cgo - DO NOT EDIT" - isAllowed := pos < importPos && filePos.Column == 1 && !strings.Contains(text, "Created by cgo") + // files using cgo have implicitly added comment "Created by cgo - DO NOT EDIT" for go <= 1.10 + // and "Code generated by cmd/cgo" for go >= 1.11 + isCgoGenerated := strings.Contains(text, "Created by cgo") || strings.Contains(text, "Code generated by cmd/cgo") + + isAllowed := pos < importPos && filePos.Column == 1 && !isCgoGenerated if isAllowed { autogenDebugf("file %q: pos=%d, filePos=%s: comment %q: it's allowed", filePath, pos, filePos, text) neededComments = append(neededComments, text) diff --git a/test/testdata/notcompiles/typecheck.go b/test/testdata/notcompiles/typecheck.go index 6cd5d42b..b428ab53 100644 --- a/test/testdata/notcompiles/typecheck.go +++ b/test/testdata/notcompiles/typecheck.go @@ -1,5 +1,5 @@ // args: -Etypecheck package testdata -fun NotCompiles() { // ERROR "expected declaration, found 'IDENT' fun" +fun NotCompiles() { // ERROR "expected declaration, found.* fun" }