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

command:pickGoProcess does not work due to not inferred mode property #1929

Closed
hashedhyphen opened this issue Dec 5, 2021 · 3 comments
Closed
Assignees
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@hashedhyphen
Copy link
Contributor

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.17 darwin/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
Build info
----------
golang.org/x/tools/gopls v0.7.3
    golang.org/x/tools/gopls@v0.7.3 h1:Lru57ht8vtDMouRskFC085VAjBAZRAISd/lwvwOOV0Q=
    github.com/google/go-cmp@v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
    golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
    golang.org/x/sys@v0.0.0-20210809222454-d867a43fc93e h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA=
    golang.org/x/text@v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
    golang.org/x/tools@v0.1.8-0.20211014194737-fc98fb2abd48 h1:hk7xRoeg0CG1nRLsd5BZLDUgVpA9bnKylGk1p2/BPH0=
    golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    mvdan.cc/gofumpt@v0.1.1 h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
    mvdan.cc/xurls/v2@v2.3.0 h1:59Olnbt67UKpxF1EwVBopJvkSUBmgtb468E4GVWIZ1I=
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
1.62.3
ccbaa2d27e38e5afa3e5c21c1c7bef4657064247
x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.29.0
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
Checking configured tools....
GOBIN: undefined
toolsGopath: 
gopath: undefined
GOROOT: 
PATH: /usr/local/opt/redis@4.0/bin:/Users/hash/google-cloud-sdk/bin:/Users/hash/Library/Python/3.7/bin:/Users/hash/go/bin:/Users/hash/.rbenv/shims:/Users/hash/.pyenv/shims:/Users/hash/.goenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Library/TeX/texbin:/Applications/Wireshark.app/Contents/MacOS

	go:	/Users/hash/.goenv/shims/go: go version go1.17 darwin/amd64

	gopkgs:	/Users/hash/go/bin/gopkgs: go version -m failed: Error: failed to run 'go version -m /Users/hash/go/bin/gopkgs': /Users/hash/go/bin/gopkgs: go version not found

	go-outline:	/Users/hash/go/bin/go-outline: go version -m failed: Error: failed to run 'go version -m /Users/hash/go/bin/go-outline': /Users/hash/go/bin/go-outline: go version not found

	gotests:	/Users/hash/go/bin/gotests: go version -m failed: Error: failed to run 'go version -m /Users/hash/go/bin/gotests': /Users/hash/go/bin/gotests: go version not found

	gomodifytags:	/Users/hash/go/bin/gomodifytags: go version -m failed: Error: failed to run 'go version -m /Users/hash/go/bin/gomodifytags': /Users/hash/go/bin/gomodifytags: go version not found

	impl:	/Users/hash/go/bin/impl: go version -m failed: Error: failed to run 'go version -m /Users/hash/go/bin/impl': /Users/hash/go/bin/impl: go version not found

	goplay:	/Users/hash/go/bin/goplay: go version -m failed: Error: failed to run 'go version -m /Users/hash/go/bin/goplay': /Users/hash/go/bin/goplay: go version not found

	dlv:	/Users/hash/go/bin/dlv: go version -m failed: Error: failed to run 'go version -m /Users/hash/go/bin/dlv': /Users/hash/go/bin/dlv: go version not found

	dlv-dap:	/Users/hash/go/1.17.0/bin/dlv-dap: go1.17
		path	github.com/go-delve/delve/cmd/dlv
		mod	github.com/go-delve/delve	v1.7.4-0.20211202111747-1a815365d552	h1:RLgZ2dAQyVaBMcOfMMTsK4AgKfGljZH0xUUvgg9YpjY=
		dep	github.com/cilium/ebpf	v0.7.0	h1:1k/q3ATgxSXRdrmPfH8d7YK0GfqVsEKZAX9dQZvs56k=
		dep	github.com/cosiner/argv	v0.1.0	h1:BVDiEL32lwHukgJKP87btEPenzrrHUjajs/8yzaqcXg=
		dep	github.com/cpuguy83/go-md2man/v2	v2.0.0	h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
		dep	github.com/derekparker/trie	v0.0.0-20200317170641-1fdf38b7b0e9	h1:G765iDCq7bP5opdrPkXk+4V3yfkgV9iGFuheWZ/X/zY=
		dep	github.com/google/go-dap	v0.6.0	h1:Y1RHGUtv3R8y6sXq2dtGRMYrFB2hSqyFVws7jucrzX4=
		dep	github.com/hashicorp/golang-lru	v0.5.4	h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
		dep	github.com/mattn/go-isatty	v0.0.3	h1:ns/ykhmWi7G9O+8a448SecJU3nSMBXJfqQkl0upE1jI=
		dep	github.com/mattn/go-runewidth	v0.0.3	h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4=
		dep	github.com/peterh/liner	v1.2.1	h1:O4BlKaq/LWu6VRWmol4ByWfzx6MfXc5Op5HETyIy5yg=
		dep	github.com/russross/blackfriday/v2	v2.0.1	h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
		dep	github.com/shurcooL/sanitized_anchor_name	v1.0.0	h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
		dep	github.com/sirupsen/logrus	v1.6.0	h1:UBcNElsrwanuuMsnGSlYmtmgbb23qDR5dG+6X6Oo89I=
		dep	github.com/spf13/cobra	v1.1.3	h1:xghbfqPkxzxP3C/f3n5DdpAbdKLj4ZE4BWQI362l53M=
		dep	github.com/spf13/pflag	v1.0.5	h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
		dep	go.starlark.net	v0.0.0-20200821142938-949cc6f4b097	h1:YiRMXXgG+Pg26t1fjq+iAjaauKWMC9cmGFrtOEuwDDg=
		dep	golang.org/x/arch	v0.0.0-20190927153633-4e8777c89be4	h1:QlVATYS7JBoZMVaf+cNjb90WD/beKVHnIxFKT4QaHVI=
		dep	golang.org/x/sys	v0.0.0-20211019181941-9d821ace8654	h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0=
		dep	gopkg.in/yaml.v2	v2.4.0	h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
	
	staticcheck:	not installed
	gopls:	/Users/hash/go/bin/gopls: go1.13.4
		path	golang.org/x/tools/gopls
		mod	golang.org/x/tools/gopls	v0.7.3	h1:Lru57ht8vtDMouRskFC085VAjBAZRAISd/lwvwOOV0Q=
		dep	github.com/google/go-cmp	v0.5.6	h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
		dep	github.com/sergi/go-diff	v1.1.0	h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
		dep	golang.org/x/mod	v0.4.2	h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
		dep	golang.org/x/sync	v0.0.0-20210220032951-036812b2e83c	h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
		dep	golang.org/x/sys	v0.0.0-20210809222454-d867a43fc93e	h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA=
		dep	golang.org/x/text	v0.3.6	h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
		dep	golang.org/x/tools	v0.1.8-0.20211014194737-fc98fb2abd48	h1:hk7xRoeg0CG1nRLsd5BZLDUgVpA9bnKylGk1p2/BPH0=
		dep	golang.org/x/xerrors	v0.0.0-20200804184101-5ec99f83aff1	h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
		dep	mvdan.cc/gofumpt	v0.1.1	h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
		dep	mvdan.cc/xurls/v2	v2.3.0	h1:59Olnbt67UKpxF1EwVBopJvkSUBmgtb468E4GVWIZ1I=
	

go env
Workspace Folder (no folder): undefined
	GO111MODULE=""
	GOARCH="amd64"
	GOBIN=""
	GOCACHE="/Users/hash/Library/Caches/go-build"
	GOENV="/Users/hash/Library/Application Support/go/env"
	GOEXE=""
	GOEXPERIMENT=""
	GOFLAGS=""
	GOHOSTARCH="amd64"
	GOHOSTOS="darwin"
	GOINSECURE=""
	GOMODCACHE="/Users/hash/go/1.17.0/pkg/mod"
	GONOPROXY=""
	GONOSUMDB=""
	GOOS="darwin"
	GOPATH="/Users/hash/go/1.17.0"
	GOPRIVATE=""
	GOPROXY="https://proxy.golang.org,direct"
	GOROOT="/Users/hash/.goenv/versions/1.17.0"
	GOSUMDB="sum.golang.org"
	GOTMPDIR=""
	GOTOOLDIR="/Users/hash/.goenv/versions/1.17.0/pkg/tool/darwin_amd64"
	GOVCS=""
	GOVERSION="go1.17"
	GCCGO="gccgo"
	AR="ar"
	CC="clang"
	CXX="clang++"
	CGO_ENABLED="1"
	GOMOD="/dev/null"
	CGO_CFLAGS="-g -O2"
	CGO_CPPFLAGS=""
	CGO_CXXFLAGS="-g -O2"
	CGO_FFLAGS="-g -O2"
	CGO_LDFLAGS="-g -O2"
	PKG_CONFIG="pkg-config"
	GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/7v/_2s_0rsx5dz19j7z_vygl0n40000gn/T/go-build2643103437=/tmp/go-build -gno-record-gcc-switches -fno-common"

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.formatTool": "goimports",
"go.toolsManagement.autoUpdate": true,

Describe the bug

According to https://github.com/golang/vscode-go/blob/master/docs/debugging.md#launchjson-attributes , the mode property in launch.json defaults to local for attach requests.

However, if I omit mode property for attach requests, configs returned by resolveDebugConfiguration() have undefined mode.

This leads to cannot unmarshal string into processId to type int error due to skipping parseInt in resolveDebugConfigurationWithSubstitutedVariables hook when using command:pickGoProcess.

if (debugConfiguration.request === 'attach' && debugConfiguration['mode'] === 'local') {

Steps to reproduce the behavior:

  1. Keep running any Go program
  2. Launch your debugger with launch.json as below
  3. Pick any Go process from suggestions
  4. See error

Sample launch.json:

{
  "version": "0.2.0",
  "configurations": [
       {
          "name": "app",
          "type": "go",
          "request": "attach",
          "processId": "${command:pickGoProcess}"
       }
  }
}

Additional notes

I made a patch and integration tests for this issue, so I am willing to send a PR.
https://github.com/golang/vscode-go/compare/master...hashedhyphen:infer-default-mode?expand=1

@gopherbot gopherbot added this to the Untriaged milestone Dec 5, 2021
@hyangah
Copy link
Contributor

hyangah commented Dec 6, 2021

Thanks for catching the root cause and also preparing the fix (along with test), @hashedhyphen !

cc @suzmue

@hyangah hyangah modified the milestones: Untriaged, On Deck Dec 6, 2021
@hyangah hyangah added the NeedsFix The path to resolution is known, but the work has not been done. label Dec 6, 2021
hashedhyphen added a commit to hashedhyphen/vscode-go that referenced this issue Dec 8, 2021
hashedhyphen added a commit to hashedhyphen/vscode-go that referenced this issue Dec 8, 2021
@hashedhyphen
Copy link
Contributor Author

@hyangah Thank you for triaging this issue. I send a PR #1932 ✏️

@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/370454 mentions this issue: src/goDebugConfiguration: infer default mode property

@hyangah hyangah modified the milestones: On Deck, v0.30.0 Dec 9, 2021
@golang golang locked and limited conversation to collaborators Dec 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants