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

x/tools/gopls: //go:generate ... code lens fails due to GOPROXY=off #55109

Open
tigerinus opened this issue Sep 11, 2022 · 1 comment
Open

x/tools/gopls: //go:generate ... code lens fails due to GOPROXY=off #55109

tigerinus opened this issue Sep 11, 2022 · 1 comment
Labels
gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@tigerinus
Copy link

tigerinus commented Sep 11, 2022

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
    • go version go1.19.1 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
Build info
----------
golang.org/x/tools/gopls v0.9.5
    golang.org/x/tools/gopls@v0.9.5 h1:F3TO5th6TUg40FHrpxZfMkMlVaaTmByeEvylgVHGH2A=
    github.com/BurntSushi/toml@v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
    github.com/google/go-cmp@v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/exp@v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
    golang.org/x/exp/typeparams@v0.0.0-20220722155223-a9213eeb770e h1:7Xs2YCOpMlNqSQSmrrnhlzBXIE/bpMecZplbLePTJvE=
    golang.org/x/mod@v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
    golang.org/x/sync@v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=
    golang.org/x/sys@v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=
    golang.org/x/text@v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
    golang.org/x/tools@v0.1.13-0.20220908144252-ce397412b6a4 h1:glzimF7qHZuKVEiMbE7UqBu44MyTjt5u6j3Jz+rfMRM=
    golang.org/x/vuln@v0.0.0-20220901221904-62b0186a1058 h1:YnB27EXBD8XxB0JcaOeluuvhF2kS4DrH0k+lpopG2xc=
    honnef.co/go/tools@v0.3.2 h1:ytYb4rOqyp1TSa2EPvNVwtPQJctSELKaMyLfqNP4+34=
    mvdan.cc/gofumpt@v0.3.1 h1:avhhrOmv0IuvQVK7fvwV91oFSGAk5/6Po8GXTzICeu8=
    mvdan.cc/xurls/v2@v2.4.0 h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=
go: go1.19.1
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
1.71.0
784b0177c56c607789f9638da7b6bf3230d47a8c
x64
  • Check your installed extensions to get the version of the VS Code Go extension
Name: Go
Id: golang.go
Description: Rich Go language support for Visual Studio Code
Version: 0.35.2
Publisher: Go Team at Google
VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=golang.Go
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
Checking configured tools....
GOBIN: undefined
toolsGopath: 
gopath: /home/wxh/go
GOROOT: /home/wxh/.local/go
PATH: /home/wxh/.local/go/bin:/home/wxh/.vscode-server/bin/784b0177c56c607789f9638da7b6bf3230d47a8c/bin/remote-cli:/home/wxh/.local/jdk/bin:/home/wxh/.local/invesla/bin:/home/wxh/.local/bin:/home/wxh/.local/apache-maven/bin:/home/wxh/.local/node/bin:/home/wxh/.cargo/bin:/home/wxh/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/wxh/.local/fzf/bin
PATH (vscode launched with): /home/wxh/.vscode-server/bin/784b0177c56c607789f9638da7b6bf3230d47a8c/bin/remote-cli:/home/wxh/.local/jdk/bin:/home/wxh/.local/invesla/bin:/home/wxh/.local/bin:/home/wxh/.local/apache-maven/bin:/home/wxh/.local/node/bin:/home/wxh/.cargo/bin:/home/wxh/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/wxh/.local/fzf/bin

	go:	/home/wxh/.local/go/bin/go: go version go1.19.1 linux/amd64

	gotests:	/home/wxh/go/bin/gotests	(version: v1.6.0 built with go: go1.19.1)
	gomodifytags:	/home/wxh/go/bin/gomodifytags	(version: v1.16.0 built with go: go1.19.1)
	impl:	/home/wxh/go/bin/impl	(version: v1.1.0 built with go: go1.19.1)
	goplay:	/home/wxh/go/bin/goplay	(version: v1.0.0 built with go: go1.19.1)
	dlv:	/home/wxh/go/bin/dlv	(version: v1.9.1 built with go: go1.19.1)
	golangci-lint:	/home/wxh/go/bin/golangci-lint	(version: v1.49.0 built with go: go1.19.1)
	gopls:	/home/wxh/go/bin/gopls	(version: v0.9.5 built with go: go1.19.1)

go env
Workspace Folder (CasaOS-Common): /home/wxh/dev/CasaOS-Common
	GO111MODULE=""
	GOARCH="amd64"
	GOBIN=""
	GOCACHE="/home/wxh/.cache/go-build"
	GOENV="/home/wxh/.config/go/env"
	GOEXE=""
	GOEXPERIMENT=""
	GOFLAGS=""
	GOHOSTARCH="amd64"
	GOHOSTOS="linux"
	GOINSECURE=""
	GOMODCACHE="/home/wxh/go/pkg/mod"
	GONOPROXY=""
	GONOSUMDB=""
	GOOS="linux"
	GOPATH="/home/wxh/go"
	GOPRIVATE=""
	GOPROXY="https://proxy.golang.org,direct"
	GOROOT="/home/wxh/.local/go"
	GOSUMDB="sum.golang.org"
	GOTMPDIR=""
	GOTOOLDIR="/home/wxh/.local/go/pkg/tool/linux_amd64"
	GOVCS=""
	GOVERSION="go1.19.1"
	GCCGO="gccgo"
	GOAMD64="v1"
	AR="ar"
	CC="gcc"
	CXX="g++"
	CGO_ENABLED="1"
	GOMOD="/home/wxh/dev/CasaOS-Common/go.mod"
	GOWORK=""
	CGO_CFLAGS="-g -O2"
	CGO_CPPFLAGS=""
	CGO_CXXFLAGS="-g -O2"
	CGO_FFLAGS="-g -O2"
	CGO_LDFLAGS="-g -O2"
	PKG_CONFIG="pkg-config"
	GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4266243234=/tmp/go-build -gno-record-gcc-switches"
	
Workspace Folder (CasaOS-Gateway): /home/wxh/dev/CasaOS-Gateway
	GO111MODULE=""
	GOARCH="amd64"
	GOBIN=""
	GOCACHE="/home/wxh/.cache/go-build"
	GOENV="/home/wxh/.config/go/env"
	GOEXE=""
	GOEXPERIMENT=""
	GOFLAGS=""
	GOHOSTARCH="amd64"
	GOHOSTOS="linux"
	GOINSECURE=""
	GOMODCACHE="/home/wxh/go/pkg/mod"
	GONOPROXY=""
	GONOSUMDB=""
	GOOS="linux"
	GOPATH="/home/wxh/go"
	GOPRIVATE=""
	GOPROXY="https://proxy.golang.org,direct"
	GOROOT="/home/wxh/.local/go"
	GOSUMDB="sum.golang.org"
	GOTMPDIR=""
	GOTOOLDIR="/home/wxh/.local/go/pkg/tool/linux_amd64"
	GOVCS=""
	GOVERSION="go1.19.1"
	GCCGO="gccgo"
	GOAMD64="v1"
	AR="ar"
	CC="gcc"
	CXX="g++"
	CGO_ENABLED="1"
	GOMOD="/home/wxh/dev/CasaOS-Gateway/go.mod"
	GOWORK=""
	CGO_CFLAGS="-g -O2"
	CGO_CPPFLAGS=""
	CGO_CXXFLAGS="-g -O2"
	CGO_FFLAGS="-g -O2"
	CGO_LDFLAGS="-g -O2"
	PKG_CONFIG="pkg-config"
	GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2000851297=/tmp/go-build -gno-record-gcc-switches"
	
Workspace Folder (CasaOS-UserService): /home/wxh/dev/CasaOS-UserService
	GO111MODULE=""
	GOARCH="amd64"
	GOBIN=""
	GOCACHE="/home/wxh/.cache/go-build"
	GOENV="/home/wxh/.config/go/env"
	GOEXE=""
	GOEXPERIMENT=""
	GOFLAGS=""
	GOHOSTARCH="amd64"
	GOHOSTOS="linux"
	GOINSECURE=""
	GOMODCACHE="/home/wxh/go/pkg/mod"
	GONOPROXY=""
	GONOSUMDB=""
	GOOS="linux"
	GOPATH="/home/wxh/go"
	GOPRIVATE=""
	GOPROXY="https://proxy.golang.org,direct"
	GOROOT="/home/wxh/.local/go"
	GOSUMDB="sum.golang.org"
	GOTMPDIR=""
	GOTOOLDIR="/home/wxh/.local/go/pkg/tool/linux_amd64"
	GOVCS=""
	GOVERSION="go1.19.1"
	GCCGO="gccgo"
	GOAMD64="v1"
	AR="ar"
	CC="gcc"
	CXX="g++"
	CGO_ENABLED="1"
	GOMOD="/home/wxh/dev/CasaOS-UserService/go.mod"
	GOWORK=""
	CGO_CFLAGS="-g -O2"
	CGO_CPPFLAGS=""
	CGO_CXXFLAGS="-g -O2"
	CGO_FFLAGS="-g -O2"
	CGO_LDFLAGS="-g -O2"
	PKG_CONFIG="pkg-config"
	GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2784595749=/tmp/go-build -gno-record-gcc-switches"
	
Workspace Folder (CasaOS-LocalStorage): /home/wxh/dev/CasaOS-LocalStorage
	GO111MODULE=""
	GOARCH="amd64"
	GOBIN=""
	GOCACHE="/home/wxh/.cache/go-build"
	GOENV="/home/wxh/.config/go/env"
	GOEXE=""
	GOEXPERIMENT=""
	GOFLAGS=""
	GOHOSTARCH="amd64"
	GOHOSTOS="linux"
	GOINSECURE=""
	GOMODCACHE="/home/wxh/go/pkg/mod"
	GONOPROXY=""
	GONOSUMDB=""
	GOOS="linux"
	GOPATH="/home/wxh/go"
	GOPRIVATE=""
	GOPROXY="https://proxy.golang.org,direct"
	GOROOT="/home/wxh/.local/go"
	GOSUMDB="sum.golang.org"
	GOTMPDIR=""
	GOTOOLDIR="/home/wxh/.local/go/pkg/tool/linux_amd64"
	GOVCS=""
	GOVERSION="go1.19.1"
	GCCGO="gccgo"
	GOAMD64="v1"
	AR="ar"
	CC="gcc"
	CXX="g++"
	CGO_ENABLED="1"
	GOMOD="/home/wxh/dev/CasaOS-LocalStorage/go.mod"
	GOWORK=""
	CGO_CFLAGS="-g -O2"
	CGO_CPPFLAGS=""
	CGO_CXXFLAGS="-g -O2"
	CGO_FFLAGS="-g -O2"
	CGO_LDFLAGS="-g -O2"
	PKG_CONFIG="pkg-config"
	GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build3985453527=/tmp/go-build -gno-record-gcc-switches"
	
Workspace Folder (CasaOS): /home/wxh/dev/CasaOS
	GO111MODULE=""
	GOARCH="amd64"
	GOBIN=""
	GOCACHE="/home/wxh/.cache/go-build"
	GOENV="/home/wxh/.config/go/env"
	GOEXE=""
	GOEXPERIMENT=""
	GOFLAGS=""
	GOHOSTARCH="amd64"
	GOHOSTOS="linux"
	GOINSECURE=""
	GOMODCACHE="/home/wxh/go/pkg/mod"
	GONOPROXY=""
	GONOSUMDB=""
	GOOS="linux"
	GOPATH="/home/wxh/go"
	GOPRIVATE=""
	GOPROXY="https://proxy.golang.org,direct"
	GOROOT="/home/wxh/.local/go"
	GOSUMDB="sum.golang.org"
	GOTMPDIR=""
	GOTOOLDIR="/home/wxh/.local/go/pkg/tool/linux_amd64"
	GOVCS=""
	GOVERSION="go1.19.1"
	GCCGO="gccgo"
	GOAMD64="v1"
	AR="ar"
	CC="gcc"
	CXX="g++"
	CGO_ENABLED="1"
	GOMOD="/home/wxh/dev/CasaOS/go.mod"
	GOWORK=""
	CGO_CFLAGS="-g -O2"
	CGO_CPPFLAGS=""
	CGO_CXXFLAGS="-g -O2"
	CGO_FFLAGS="-g -O2"
	CGO_LDFLAGS="-g -O2"
	PKG_CONFIG="pkg-config"
	GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build68001256=/tmp/go-build -gno-record-gcc-switches"

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

    "go.enableCodeLens": {
        "references": true,
        "runtest": true
    },
    "go.delveConfig": {
        "showGlobalVariables": true,
    },
    "go.gopath": "/home/wxh/go",
    "go.goroot": "/home/wxh/.local/go",
    "go.lintFlags": [
        "-D",
        "staticcheck",
        "-E",
        "gocyclo,gosec,makezero,prealloc,revive,usestdlibvars"
    ],
    "go.lintTool": "golangci-lint",
    "go.toolsManagement.autoUpdate": true,
    "gopls": {
        "ui.semanticTokens": true,
        "formatting.gofumpt": true,
        "ui.codelenses": {
            "gc_details": true,
            "run_vulncheck_exp": true,
            "test": true,
        }  
    },

Steps to reproduce the behavior:

  1. In main.go have line with //go:generate following by any go run ... command like
//go:generate go run golang.org/x/tools/cmd/stringer@latest --help

(it does not have to be go run golang.org/x/tools/cmd/stringer@latest --help)

  1. Click on run go generate in the codelens

image

Result:

[Info  - 12:53:16 p.m.] 2022/09/11 12:53:16 go run golang.org/x/tools/cmd/stringer@latest --help

	operation="generate"

[Info  - 12:53:16 p.m.] 2022/09/11 12:53:16 go: golang.org/x/tools/cmd/stringer@latest: module lookup disabled by GOPROXY=off

	operation="generate"

[Info  - 12:53:16 p.m.] 2022/09/11 12:53:16 main.go:1: running "go": exit status 1

	operation="generate"

[Error - 12:53:16 p.m.] Request workspace/executeCommand failed.
  Message: exit status 1
  Code: 0 
[Error - 12:53:16 p.m.] 2022/09/11 12:53:16 command error: exit status 1

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.

bug

If I run go generate directly in the terminal:

$ rm codegen/local_storage_api.go 
$ go generate
$ ls codegen/local_storage_api.go 
codegen/local_storage_api.go
@findleyr
Copy link
Contributor

findleyr commented Sep 16, 2022

Thanks for the report. This is because we don't allow network access during the go:generate codelens. We should lift that restriction.

@findleyr findleyr changed the title //go:generate ... always fail when running via codelens while running go generate in command line always succeed. x/tools/gopls: //go:generate ... code lens fails due to GOPROXY=off Sep 16, 2022
@findleyr findleyr transferred this issue from golang/vscode-go Sep 16, 2022
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Sep 16, 2022
@gopherbot gopherbot added this to the Unreleased milestone Sep 16, 2022
@findleyr findleyr modified the milestones: Unreleased, gopls/later Sep 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. NeedsFix The path to resolution is known, but the work has not been done. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants