Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd: instructions don't work for vendoring in x/tools into stdlib #45440

Open
randall77 opened this issue Apr 8, 2021 · 2 comments
Open

cmd: instructions don't work for vendoring in x/tools into stdlib #45440

randall77 opened this issue Apr 8, 2021 · 2 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@randall77
Copy link
Contributor

I'm trying to vendor in x/tools into the stdlib to add a new vet analysis pass.

I'm trying to follow the instructions in src/README.vendor, and to some extent src/cmd/README.vendor. So I do:

$ cd src/cmd
$ ../../bin/go get -d golang.org/x/tools@latest
go get: downgraded golang.org/x/tools v0.1.1-0.20210312185553-8e4f4c86593a => v0.1.0

That downgraded sentence looks bad. But I asked for "latest". Is there something else I should ask for?
Continuing anyway:

$ ../../bin/go mod tidy
go: finding module for package golang.org/x/tools/go/analysis/passes/sigchanyzer
cmd/vet imports
	golang.org/x/tools/go/analysis/passes/sigchanyzer: module golang.org/x/tools@latest found (v0.1.0), but does not contain package golang.org/x/tools/go/analysis/passes/sigchanyzer

Nothing else subsequent in those instructions work either.

I end up with this diff in go.mod and go.sum:

diff --git a/src/cmd/go.mod b/src/cmd/go.mod
index 5fbcf642f4..0f4b4fc29f 100644
--- a/src/cmd/go.mod
+++ b/src/cmd/go.mod
@@ -9,5 +9,5 @@ require (
        golang.org/x/mod v0.4.3-0.20210323215154-1cc8812c1740
        golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 // indirect
        golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d
-       golang.org/x/tools v0.1.1-0.20210312185553-8e4f4c86593a
+       golang.org/x/tools v0.1.0
 )
diff --git a/src/cmd/go.sum b/src/cmd/go.sum
index 391e99ca99..e11a055c95 100644
--- a/src/cmd/go.sum
+++ b/src/cmd/go.sum
@@ -13,6 +13,7 @@ golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8U
 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
 golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83 h1:/ZScEX8SfEmUGRHs0gxpqteO5nfNW6axyZbBdw9A12g=
 golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
+golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
 golang.org/x/mod v0.4.3-0.20210323215154-1cc8812c1740 h1:UYbWz0ISU1ccVf+FK/BRuwA4LGw2SzoambF9r5ozR/E=
 golang.org/x/mod v0.4.3-0.20210323215154-1cc8812c1740/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
@@ -27,6 +28,7 @@ golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7w
 golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
 golang.org/x/sys v0.0.0-20210309074719-68d13333faf2 h1:46ULzRKLh1CwgRq2dC5SlBzEqqNCi8rreOZnNrbqcIY=
 golang.org/x/sys v0.0.0-20210309074719-68d13333faf2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@@ -37,6 +39,8 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
 golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
 golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
+golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
+golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
 golang.org/x/tools v0.1.1-0.20210312185553-8e4f4c86593a h1:dM42cKDDlU6VAcfE6/ANedIkHqAPncj3GWNGqjv0f0Q=
 golang.org/x/tools v0.1.1-0.20210312185553-8e4f4c86593a/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU=
 golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

I suspect this is due to the downgrade error above. Looks like sigchanyzer was added around Dec 1 2020.

If I look at the tags on the x/tools repo, there are version tags up to gopls/v0.6.1. Not sure why gopls is in the version string, or if that might be relevant to this problem.

@jayconrod
@bcmills

@randall77
Copy link
Contributor Author

Using @b261fe96097f8db197a1033090651783e8eb8350 in my go get command seems to help somewhat. That's the SHA1 hash of the CL I'm trying to pull into the stdlib (CL 308209). I get farther, but the code in that CL doesn't seem to get pulled in after the tidy/vendor command combo. I get

$ git status
On branch issue45242
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   go.mod
	modified:   go.sum
	modified:   vendor/golang.org/x/tools/go/analysis/passes/inspect/inspect.go
	modified:   vendor/modules.txt

no changes added to commit (use "git add" and/or "git commit -a")

That change (the inspect.go file) looks like CL 302989, not my change.

@ALTree ALTree added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Apr 8, 2021
@bcmills
Copy link
Contributor

bcmills commented Apr 8, 2021

I asked for "latest". Is there something else I should ask for?

latest defaults to the latest tagged release, which for x/tools is indeed v0.1.0. As you have found, if you want a commit after that tag you need to request that commit explicitly.

the code in that CL doesn't seem to get pulled in after the tidy/vendor command combo.

go mod vendor only vendors in packages that are imported. For a new cmd/vet analyzer in particular, you will need to import and use it in src/cmd/vet/main.go before it will be vendored in.

@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants