Skip to content

Commit

Permalink
disable go1.11 in travis and make some small fixes for go1.11
Browse files Browse the repository at this point in the history
  • Loading branch information
jirfag committed Jul 29, 2018
1 parent 3a806e9 commit d02ac24
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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\.
18 changes: 11 additions & 7 deletions pkg/lint/astcache/astcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/result/processors/autogenerated_exclude.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test/testdata/notcompiles/typecheck.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// args: -Etypecheck
package testdata

fun NotCompiles() { // ERROR "expected declaration, found 'IDENT' fun"
fun NotCompiles() { // ERROR "expected declaration, found.* fun"
}

0 comments on commit d02ac24

Please sign in to comment.