loov / goda

Go Dependency Analysis toolkit
MIT License
1.37k stars 45 forks source link

goda complains about needing a go mod tidy that is never enough #69

Open soypat opened 1 year ago

soypat commented 1 year ago

What happened

Ran goda in my repository, got a message:

$ goda graph -std "reach(github.com/...:all, flag)" | dot -Tsvg -o graph.svg
err: exit status 1: stderr: go: updates to go.mod needed; to update it:
        go mod tidy

Running go mod tidy does not fix the problem.

Deleting go.sum fixes the issue.

Steps to replicate

using go19.3: main.go contents:

package main

import (
    "golang.org/x/exp/slog"
    "periph.io/x/host/v3"
)

func main() {
    slog.Any("", "")
    host.Init()
}
  1. Run go mod init something
  2. Run go mod tidy
  3. Run goda graph -std "reach(github.com/...:all, flag)"

Generated go.mod file

module tg

go 1.19

require (
    golang.org/x/exp v0.0.0-20230420155640-133eef4313cb
    periph.io/x/host/v3 v3.8.0
)

require periph.io/x/conn/v3 v3.7.0 // indirect

Generated go.sum:

github.com/jonboulle/clockwork v0.3.0 h1:9BSCMi8C+0qdApAp4auwX0RkLGUjs956h0EkuQymUhg=
golang.org/x/exp v0.0.0-20230420155640-133eef4313cb h1:rhjz/8Mbfa8xROFiH+MQphmAmgqRM0bOMnytznhWEXk=
golang.org/x/exp v0.0.0-20230420155640-133eef4313cb/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
periph.io/x/conn/v3 v3.7.0 h1:f1EXLn4pkf7AEWwkol2gilCNZ0ElY+bxS4WE2PQXfrA=
periph.io/x/conn/v3 v3.7.0/go.mod h1:ypY7UVxgDbP9PJGwFSVelRRagxyXYfttVh7hJZUHEhg=
periph.io/x/host/v3 v3.8.0 h1:T5ojZ2wvnZHGPS4h95N2ZpcCyHnsvH3YRZ1UUUiv5CQ=
periph.io/x/host/v3 v3.8.0/go.mod h1:rzOLH+2g9bhc6pWZrkCrmytD4igwQ2vxFw6Wn6ZOlLY=
egonelbre commented 1 year ago

I just realized what's going wrong:

goda graph -std "reach(github.com/...:all, flag)" | dot -Tsvg -o graph.svg
                       ^--- implies loading all modules from github

This should work:

goda graph -std "reach(./...:all, flag)" | dot -Tsvg -o graph.svg

I'll need to figure out why it's giving that error and whether there's a way I can output a better error.

This gives the same error btw.:

go list github.com/...
soypat commented 1 year ago

Filed! https://github.com/golang/go/issues/59755