| # https://golang.org/issue/45979: after 'go get' on a package, |
| # that package should be importable without error. |
| |
| |
| # We start out with an unresolved dependency. |
| # 'go list' suggests that we run 'go get' on that dependency. |
| |
| ! go list -deps . |
| stderr '^m.go:3:8: no required module provides package rsc\.io/quote; to add it:\n\tgo get rsc.io/quote$' |
| |
| |
| # When we run the suggested 'go get' command, the new dependency can be used |
| # immediately. |
| # |
| # 'go get' marks the new dependency as 'indirect', because it doesn't scan |
| # enough source code to know whether it is direct, and it is easier and less |
| # invasive to remove an incorrect indirect mark (e.g. using 'go get') than to |
| # add one that is missing ('go mod tidy' or 'go mod vendor'). |
| |
| go get rsc.io/quote |
| grep 'rsc.io/quote v\d+\.\d+\.\d+ // indirect$' go.mod |
| ! grep 'rsc.io/quote v\d+\.\d+\.\d+$' go.mod |
| |
| go list -deps . |
| ! stderr . |
| [!short] go build . |
| [!short] ! stderr . |
| |
| |
| # 'go get .' (or 'go mod tidy') removes the indirect mark. |
| |
| go get . |
| grep 'rsc.io/quote v\d+\.\d+\.\d+$' go.mod |
| ! grep 'rsc.io/quote v\d+\.\d+\.\d+ // indirect$' go.mod |
| |
| |
| -- go.mod -- |
| module example.com/m |
| |
| go 1.17 |
| -- m.go -- |
| package m |
| |
| import _ "rsc.io/quote" |