I can't run the go program on vscode on my Win11 computer ( no run button, pressing Ctrl+F5 or F5 doesn't work ,like this: vscode ) and I can't debug it. It's not written on FAQ.
It works on my other Win10 PC. All dependencies are installed
This is my settings.json:
"go.autocompleteUnimportedPackages": true,
"go.gocodePackageLookupMode": "go",
"go.gotoSymbol.includeImports": true,
"go.useCodeSnippetsOnFunctionSuggest": true,
"go.inferGopath": false,
"go.gopath": "F:\\vscodefiles\\src\\hello",
"go.goroot": "D:\\go\\",
"go.useCodeSnippetsOnFunctionSuggestWithoutType": true,
why is this?
Try in the terminal:
go run myfirstprogram.go
Remember to install Go on your computer before, you can download it from its official page: https://go.dev/ and restart Visual Studio Code.
Besides installing Go locally, for VSCode you need to install the correct extension:
https://marketplace.visualstudio.com/items?itemName=golang.Go
You can install this extension by navigating to " Extensions " with:
Windows: ctrl + shift + x
MacOS: command + shift + x
Then searching for " go " which is by author " Go Team at Google "
When you navigate back to your code, you can now press F5 to trigger a debugging run.
Note when pressing F5 pay attention to the bottom right as you may be prompted to install further dependencies (I had to install 3 more)
I also needed to execute this in a terminal as I kept seeing "no go.mod detected in the current directory"
go env -w GO111MODULE=off
as per this answer
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.