ondrajz / go-callvis

Visualize call graph of a Go program using Graphviz
https://ofabry.github.io/go-callvis
MIT License
5.82k stars 402 forks source link

update(go.mod): dependency update to support go 1.18 generics #121

Closed xinyubot closed 1 year ago

xinyubot commented 2 years ago

Output of current version of go-callvis:

$ go-callvis -version
v0.6.1 built from git v0.6.1-11-g06b3e4b

$ go-callvis -nointer -nostd -debug ./...
panic: T

goroutine 5906 [running]:
golang.org/x/tools/go/ssa.(*Program).needMethods(0xc01f0644e0, {0xba6ec0?, 0xc021bac690?}, 0x0)
        golang.org/x/tools@v0.1.9/go/ssa/methods.go:237 +0x5b1
golang.org/x/tools/go/ssa.(*Program).needMethods(0xc01f0644e0, {0xba6e48?, 0xc01eb3c970?}, 0x0)
        golang.org/x/tools@v0.1.9/go/ssa/methods.go:196 +0x347
golang.org/x/tools/go/ssa.(*Program).needMethods(0xc01f0644e0, {0xba6e98?, 0xc01b6b23f0?}, 0x0)
        golang.org/x/tools@v0.1.9/go/ssa/methods.go:233 +0x708
golang.org/x/tools/go/ssa.(*Program).needMethods(0xc01f0644e0, {0xba6e20?, 0xc021a72a40?}, 0x0)
        golang.org/x/tools@v0.1.9/go/ssa/methods.go:209 +0x448
golang.org/x/tools/go/ssa.(*Program).needMethodsOf(0xc01f0644e0, {0xba6e20?, 0xc021a72a40?})
        golang.org/x/tools@v0.1.9/go/ssa/methods.go:145 +0x70
golang.org/x/tools/go/ssa.(*Package).build(0xc017f54cc0)
        golang.org/x/tools@v0.1.9/go/ssa/builder.go:2281 +0x111
sync.(*Once).doSlow(0xc0005b97b8?, 0x6b719e?)
        sync/once.go:68 +0xc2
sync.(*Once).Do(...)
        sync/once.go:59
golang.org/x/tools/go/ssa.(*Package).Build(...)
        golang.org/x/tools@v0.1.9/go/ssa/builder.go:2269
golang.org/x/tools/go/ssa.(*Program).Build.func1(0x3861615f34313830?)
        golang.org/x/tools@v0.1.9/go/ssa/builder.go:2253 +0x4c
created by golang.org/x/tools/go/ssa.(*Program).Build
        golang.org/x/tools@v0.1.9/go/ssa/builder.go:2252 +0x19c

It panicked because some historical version of dependencies do not support go 1.18 generics type parameters. I simply updated the dependencies and re-built from source, and it worked well.

$ go get -u $(go list -u -f '{{if (and (not (or .Main .Indirect)) .Update)}}{{.Path}}{{end}}' -m all)
go: upgraded github.com/goccy/go-graphviz v0.0.6 => v0.0.9
go: upgraded github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 => v0.0.0-20210911075715-681adbf594b8
go: upgraded golang.org/x/image v0.0.0-20200119044424-58c23975cae1 => v0.0.0-20220617043117-41969df76e82
go: upgraded golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 => v0.0.0-20220615213510-4f61da869c0c
go: upgraded golang.org/x/tools v0.1.9 => v0.1.11

$ go mod tidy

$ make install
go install -tags "" -ldflags "-X main.commit=v0.6.1-11-g06b3e4b-dirty -w -s" -trimpath

$ go-callvis -version
v0.6.1 built from git v0.6.1-13-g03ed36c-dirty

$ go-callvis -nointer -nostd -debug ./...
18:48:02.345442 http serving at http://localhost:7878
(more log...)

Go version remains as go 1.12, so it won't affect developers without go 1.18 installed locally to build from source.

ondrajz commented 1 year ago

Hey, thanks for the PR. The checks are failing I believe the reason is that go.mod file defines go version 1.12, try changing that to 1.18 a running go mod tidy again.

xinyubot commented 1 year ago

Hey, thanks for the PR. The checks are failing I believe the reason is that go.mod file defines go version 1.12, try changing that to 1.18 a running go mod tidy again.

Thanks for replying. I've changed go version to 1.18; however the checks are still failing. It seems that we have two checks for both go 1.17 and 1.18, and the one for 1.17 has the following error message: go mod tidy: go.mod file indicates go 1.18, but maximum supported version is 1.17 😅

If you want to support the two latest major releases of go, I've changed go.mod go version to 1.17 since by doing so it passes the checks.