disable go1.11 in travis and make some small fixes for go1.11

This commit is contained in:
Denis Isaev 2018-07-29 12:53:18 +03:00 committed by Isaev Denis
parent 3a806e9c78
commit d02ac2466e
4 changed files with 20 additions and 12 deletions

View File

@ -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\.

View File

@ -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,
}
}
}

View File

@ -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)

View File

@ -1,5 +1,5 @@
// args: -Etypecheck
package testdata
fun NotCompiles() { // ERROR "expected declaration, found 'IDENT' fun"
fun NotCompiles() { // ERROR "expected declaration, found.* fun"
}