file names and column info broken by go1.11beta
kolyshkin opened this issue · 2 comments
kolyshkin commented
I am having issue using unconvert with go 1.11beta2 (and beta1). Errors reported do have file names truncated (no path), and there's no column info
I am using slightly modified unconvert.go
with some debug info
--- a/unconvert.go
+++ b/unconvert.go
@@ -323,6 +323,7 @@ func computeEdits(importPaths []string, os, arch string, cgoEnabled bool) fileTo
defer wg.Done()
v := visitor{pkg: pkg, file: conf.Fset.File(file.Package), edits: make(editSet)}
ast.Walk(&v, file)
+ fmt.Printf(" <- edits %v\n", v.edits)
ch <- res{v.file.Name(), v.edits}
}()
}
@@ -410,6 +411,9 @@ func (v *visitor) unconvert(call *ast.CallExpr) {
return
}
+ fmt.Printf("v.file.Name: %+v\ncall.Lparen: %+v\n", v.file.Name(), call.Lparen)
+ fmt.Printf("v.file.Position(call.Lparen): %+v\n", v.file.Position(call.Lparen))
+
v.edits[v.file.Position(call.Lparen)] = struct{}{}
}
Here is an example when run with Go 1.10:
kir@kd:~/go/src/github.com/mdempsky/unconvert$ go run unconvert.go github.com/docker/docker/daemon/graphdriver/copy
<- edits map[]
v.file.Name: /home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go
call.Lparen: 6551
v.file.Position(call.Lparen): /home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go:242:28
v.file.Name: /home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go
call.Lparen: 6573
v.file.Position(call.Lparen): /home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go:242:50
v.file.Name: /home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go
call.Lparen: 6618
v.file.Position(call.Lparen): /home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go:243:28
v.file.Name: /home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go
call.Lparen: 6640
v.file.Position(call.Lparen): /home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go:243:50
<- edits map[/home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go:242:28:{} /home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go:242:50:{} /home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go:243:28:{} /home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go:243:50:{}]
/home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go:242:28: unnecessary conversion
/home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go:242:50: unnecessary conversion
/home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go:243:28: unnecessary conversion
/home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go:243:50: unnecessary conversion
exit status 1
And here's one with Go 1.11beta2:
kir@kd:~/go/src/github.com/mdempsky/unconvert$ go1.11beta2 run unconvert.go github.com/docker/docker/daemon/graphdriver/copy
<- edits map[]
v.file.Name: /home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go
call.Lparen: 6573
v.file.Position(call.Lparen): copy.go:242
v.file.Name: /home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go
call.Lparen: 6595
v.file.Position(call.Lparen): copy.go:242
v.file.Name: /home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go
call.Lparen: 6640
v.file.Position(call.Lparen): copy.go:243
v.file.Name: /home/kir/go/src/github.com/docker/docker/daemon/graphdriver/copy/copy.go
call.Lparen: 6662
v.file.Position(call.Lparen): copy.go:243
<- edits map[copy.go:243:{} copy.go:242:{} copy.go:242:{} copy.go:243:{}]
copy.go:242:0: unnecessary conversion
copy.go:242:0: unnecessary conversion
copy.go:243:0: unnecessary conversion
copy.go:243:0: unnecessary conversion
exit status 1
kolyshkin commented
I got the fix! Will create a PR soon.
kolyshkin commented
This was fixed upstream in golang/go: