ondrajz / go-callvis

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

support for modules #32

Closed deefdragon closed 5 years ago

deefdragon commented 5 years ago

when using go-callvis with a 1.11 module project, I am not able to get an output, I just get a lot of "could nit find x in any of ..."

sanguohot commented 5 years ago

Well, I want this feature too.

trivigy commented 5 years ago

Any advice on how to deal with this issue is much appreciated. Here is the printout of what the errors on my end look like.

┌─[trivigy@x1yoga]─[~/Syncaide/Projects/gate]
└─[issue-48]─$ go-callvis -ignore go.uber.org/zap,github.com/spf13/afero,github.com/lestrrat-go/jwx/jwk .
/home/trivigy/.go/pkg/mod/github.com/lestrrat-go/jwx@v0.0.0-20190410064423-01291bc3293a/jwk/certchain.go:7:2: could not import github.com/pkg/errors (cannot find package "github.com/pkg/errors" in any of:
        /usr/local/go/src/github.com/pkg/errors (from $GOROOT)
        /home/trivigy/.go/src/github.com/pkg/errors (from $GOPATH))
/home/trivigy/.go/pkg/mod/github.com/lestrrat-go/jwx@v0.0.0-20190410064423-01291bc3293a/jwk/ecdsa.go:11:2: could not import github.com/lestrrat-go/jwx/internal/base64 (cannot find package "github.com/lestrrat-go/jwx/internal/base64" in any of:
        /usr/local/go/src/github.com/lestrrat-go/jwx/internal/base64 (from $GOROOT)
        /home/trivigy/.go/src/github.com/lestrrat-go/jwx/internal/base64 (from $GOPATH))
/home/trivigy/.go/pkg/mod/github.com/lestrrat-go/jwx@v0.0.0-20190410064423-01291bc3293a/jwk/ecdsa.go:12:2: could not import github.com/lestrrat-go/jwx/jwa (cannot find package "github.com/lestrrat-go/jwx/jwa" in any of:
        /usr/local/go/src/github.com/lestrrat-go/jwx/jwa (from $GOROOT)
        /home/trivigy/.go/src/github.com/lestrrat-go/jwx/jwa (from $GOPATH))
/home/trivigy/.go/pkg/mod/github.com/lestrrat-go/jwx@v0.0.0-20190410064423-01291bc3293a/jwk/ecdsa.go:13:9: could not import github.com/lestrrat-go/pdebug (cannot find package "github.com/lestrrat-go/pdebug" in any of:
        /usr/local/go/src/github.com/lestrrat-go/pdebug (from $GOROOT)
        /home/trivigy/.go/src/github.com/lestrrat-go/pdebug (from $GOPATH))
/home/trivigy/.go/pkg/mod/github.com/lestrrat-go/jwx@v0.0.0-20190410064423-01291bc3293a/jwk/option.go:6:2: could not import github.com/lestrrat-go/jwx/internal/option (cannot find package "github.com/lestrrat-go/jwx/internal/option" in any of:
        /usr/local/go/src/github.com/lestrrat-go/jwx/internal/option (from $GOROOT)
        /home/trivigy/.go/src/github.com/lestrrat-go/jwx/internal/option (from $GOPATH))
/home/trivigy/.go/pkg/mod/github.com/spf13/afero@v1.1.2/memmap.go:25:2: could not import github.com/spf13/afero/mem (go/build: importGo github.com/spf13/afero/mem: exit status 1
error writing go.mod: open /home/trivigy/.go/pkg/mod/github.com/spf13/afero@v1.1.2/go.mod485317572.tmp: permission denied

)
/home/trivigy/.go/pkg/mod/github.com/spf13/afero@v1.1.2/util.go:28:2: could not import golang.org/x/text/transform (go/build: importGo golang.org/x/text/transform: exit status 1
error writing go.mod: open /home/trivigy/.go/pkg/mod/github.com/spf13/afero@v1.1.2/go.mod131271422.tmp: permission denied

)
/home/trivigy/.go/pkg/mod/github.com/spf13/afero@v1.1.2/util.go:29:2: could not import golang.org/x/text/unicode/norm (go/build: importGo golang.org/x/text/unicode/norm: exit status 1
error writing go.mod: open /home/trivigy/.go/pkg/mod/github.com/spf13/afero@v1.1.2/go.mod568267103.tmp: permission denied

)
/home/trivigy/.go/pkg/mod/go.uber.org/zap@v1.9.1/array.go:26:2: could not import go.uber.org/zap/zapcore (cannot find package "go.uber.org/zap/zapcore" in any of:
        /usr/local/go/src/go.uber.org/zap/zapcore (from $GOROOT)
        /home/trivigy/.go/src/go.uber.org/zap/zapcore (from $GOPATH))
/home/trivigy/.go/pkg/mod/go.uber.org/zap@v1.9.1/level.go:24:2: could not import go.uber.org/atomic (cannot find package "go.uber.org/atomic" in any of:
        /usr/local/go/src/go.uber.org/atomic (from $GOROOT)
        /home/trivigy/.go/src/go.uber.org/atomic (from $GOPATH))
/home/trivigy/.go/pkg/mod/go.uber.org/zap@v1.9.1/stacktrace.go:28:2: could not import go.uber.org/zap/internal/bufferpool (cannot find package "go.uber.org/zap/internal/bufferpool" in any of:
        /usr/local/go/src/go.uber.org/zap/internal/bufferpool (from $GOROOT)
        /home/trivigy/.go/src/go.uber.org/zap/internal/bufferpool (from $GOPATH))
/home/trivigy/.go/pkg/mod/go.uber.org/zap@v1.9.1/sugar.go:28:2: could not import go.uber.org/multierr (cannot find package "go.uber.org/multierr" in any of:
        /usr/local/go/src/go.uber.org/multierr (from $GOROOT)
        /home/trivigy/.go/src/go.uber.org/multierr (from $GOPATH))
go-callvis: couldn't load packages due to errors: go.uber.org/zap, github.com/lestrrat-go/jwx/jwk, github.com/spf13/afero
traitmeta commented 5 years ago

I also encountered this issue.

asvetlik commented 5 years ago

I have encountered the issue as well.

lthung1504 commented 5 years ago

I also ecountered this issue :( can not run for go mod projects

yonggang985 commented 5 years ago

I also encountered this issue.

joeblubaugh commented 5 years ago

@TrueFurby are you looking for contributors to this project? Adding module support to the library would be a big win for my company as we migrate to go mod.

marcofranssen commented 5 years ago

I also tried go-callvis today. We are fully on go modules and currently not able to use it with go modules.

FYI: this is how we add tools to our project so we can version them as well using go modules. Would be great if the makefile would not be required and someone can leverage go mod natively to install and version this tool.

We add a tool.go file in the root of our project.

// +build tools

package tools

import (
    _ "github.com/TrueFurby/go-callvis"
    _ "github.com/golangci/golangci-lint/cmd/golangci-lint"
    _ "github.com/goreleaser/goreleaser"
    _ "github.com/spf13/cobra/cobra"
    _ "github.com/tebeka/go2xunit"
    _ "golang.org/x/lint/golint"
    _ "golang.org/x/perf/cmd/benchstat"
    _ "golang.org/x/tools/cmd/stringer"
)

Then to install all tools we use following in our CI to use them.

go mod download
cat tools.go | grep _ | awk -F'"' '{print $2}' | xargs -tI % go install %

I would also recommend using goreleaser to release this tool as a binary.

medyagh commented 5 years ago

+1.

danmartinj commented 5 years ago

+1