VsCode Go extension debugs Example_c.c file instead of actual file
I just tried to execute a Hello World from VSCode 1.28.2 (Windows 8.1) in a C:Scriptshello_world.go file:
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello, Gopher!")
}
My environment is as follows:
- I installed Go from scratch using the Windows installer:
$ go version
go version go1.11.2 windows/amd64
- Installed on C:Go
- Installed VSCode Go Extension: https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go
- Installed debugger:
go get -u github.com/derekparker/delve/cmd/dlv
- Checked with SystemPropertiesAdvanced:
- Local Variable GOPATH = %USERPROFILE%go
- Local Variable PATH adds %USERPROFILE%gobin
- System Variable PATH adds C:Gobin
- System Variable GOROOT = C:Go
- I have MinGW64, GitBash and MinGW 1.0 (However I don't see how that could affect running Go from VSCode)
- Running from cmd.exe runs the program without problems at all:
C:Scripts>go run hello_world.go
Hello, Gopher!
In VSCode settings my global go.gopath and go.goroot settings are:
// Specify GOPATH here to override the one that is set as environment variable. The inferred GOPATH from workspace root overrides this, if go.inferGopath is set to true.
"go.gopath": null
// Specifies the GOROOT to use when no environment variable is set.
"go.goroot": null
So I customized the variables from VSCode as follows:
{
"editor.renderControlCharacters": false,
"go.inferGopath": true,
"go.goroot": "C:\go",
}
Now this is the weird part. When I hit Ctrl+F5 compilation takes a "Example_c.c" file (?) and reports errors with that file (which I never created or even knew that existed):
# _/c_/Scripts
C:UsersMikeAppDataLocalTempgo-build530760830b001_x003.o: In function `main':
./Example_c.c:1: multiple definition of `main'
C:UsersMikeAppDataLocalTempgo-build530760830b001_cgo_main.o:/tmp/go-build/_cgo_main.c:1: first defined here
C:UsersMikeAppDataLocalTempgo-build530760830b001_x004.o: In function `main':
./Test_C-01.c:3: multiple definition of `main'
C:UsersMikeAppDataLocalTempgo-build530760830b001_cgo_main.o:/tmp/go-build/_cgo_main.c:1: first defined here
C:UsersMikeAppDataLocalTempgo-build530760830b001_x005.o: In function `main':
./Test_C-02.c:3: multiple definition of `main'
C:UsersMikeAppDataLocalTempgo-build530760830b001_cgo_main.o:/tmp/go-build/_cgo_main.c:1: first defined here
collect2: ld returned 1 exit status
# _/c_/Scripts
Example_c.c: In function 'main':
Example_c.c:2:3: warning: incompatible implicit declaration of built-in function 'printf'
Example_c.c:4:19: warning: incompatible implicit declaration of built-in function 'malloc'
Example_c.c:9:3: warning: incompatible implicit declaration of built-in function 'free'
exit status 2
Process exiting with code: 1
I already tried deleting all my temporary files and restarted VsCode multiple times. The whole experience to setup a Go environment to debug a hello world is really dissapointing.
What else can I check? Any hints?
go visual-studio-code vscode-settings
add a comment |
I just tried to execute a Hello World from VSCode 1.28.2 (Windows 8.1) in a C:Scriptshello_world.go file:
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello, Gopher!")
}
My environment is as follows:
- I installed Go from scratch using the Windows installer:
$ go version
go version go1.11.2 windows/amd64
- Installed on C:Go
- Installed VSCode Go Extension: https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go
- Installed debugger:
go get -u github.com/derekparker/delve/cmd/dlv
- Checked with SystemPropertiesAdvanced:
- Local Variable GOPATH = %USERPROFILE%go
- Local Variable PATH adds %USERPROFILE%gobin
- System Variable PATH adds C:Gobin
- System Variable GOROOT = C:Go
- I have MinGW64, GitBash and MinGW 1.0 (However I don't see how that could affect running Go from VSCode)
- Running from cmd.exe runs the program without problems at all:
C:Scripts>go run hello_world.go
Hello, Gopher!
In VSCode settings my global go.gopath and go.goroot settings are:
// Specify GOPATH here to override the one that is set as environment variable. The inferred GOPATH from workspace root overrides this, if go.inferGopath is set to true.
"go.gopath": null
// Specifies the GOROOT to use when no environment variable is set.
"go.goroot": null
So I customized the variables from VSCode as follows:
{
"editor.renderControlCharacters": false,
"go.inferGopath": true,
"go.goroot": "C:\go",
}
Now this is the weird part. When I hit Ctrl+F5 compilation takes a "Example_c.c" file (?) and reports errors with that file (which I never created or even knew that existed):
# _/c_/Scripts
C:UsersMikeAppDataLocalTempgo-build530760830b001_x003.o: In function `main':
./Example_c.c:1: multiple definition of `main'
C:UsersMikeAppDataLocalTempgo-build530760830b001_cgo_main.o:/tmp/go-build/_cgo_main.c:1: first defined here
C:UsersMikeAppDataLocalTempgo-build530760830b001_x004.o: In function `main':
./Test_C-01.c:3: multiple definition of `main'
C:UsersMikeAppDataLocalTempgo-build530760830b001_cgo_main.o:/tmp/go-build/_cgo_main.c:1: first defined here
C:UsersMikeAppDataLocalTempgo-build530760830b001_x005.o: In function `main':
./Test_C-02.c:3: multiple definition of `main'
C:UsersMikeAppDataLocalTempgo-build530760830b001_cgo_main.o:/tmp/go-build/_cgo_main.c:1: first defined here
collect2: ld returned 1 exit status
# _/c_/Scripts
Example_c.c: In function 'main':
Example_c.c:2:3: warning: incompatible implicit declaration of built-in function 'printf'
Example_c.c:4:19: warning: incompatible implicit declaration of built-in function 'malloc'
Example_c.c:9:3: warning: incompatible implicit declaration of built-in function 'free'
exit status 2
Process exiting with code: 1
I already tried deleting all my temporary files and restarted VsCode multiple times. The whole experience to setup a Go environment to debug a hello world is really dissapointing.
What else can I check? Any hints?
go visual-studio-code vscode-settings
github.com/Microsoft/vscode-go/wiki/…
– 23k
Nov 13 at 3:57
add a comment |
I just tried to execute a Hello World from VSCode 1.28.2 (Windows 8.1) in a C:Scriptshello_world.go file:
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello, Gopher!")
}
My environment is as follows:
- I installed Go from scratch using the Windows installer:
$ go version
go version go1.11.2 windows/amd64
- Installed on C:Go
- Installed VSCode Go Extension: https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go
- Installed debugger:
go get -u github.com/derekparker/delve/cmd/dlv
- Checked with SystemPropertiesAdvanced:
- Local Variable GOPATH = %USERPROFILE%go
- Local Variable PATH adds %USERPROFILE%gobin
- System Variable PATH adds C:Gobin
- System Variable GOROOT = C:Go
- I have MinGW64, GitBash and MinGW 1.0 (However I don't see how that could affect running Go from VSCode)
- Running from cmd.exe runs the program without problems at all:
C:Scripts>go run hello_world.go
Hello, Gopher!
In VSCode settings my global go.gopath and go.goroot settings are:
// Specify GOPATH here to override the one that is set as environment variable. The inferred GOPATH from workspace root overrides this, if go.inferGopath is set to true.
"go.gopath": null
// Specifies the GOROOT to use when no environment variable is set.
"go.goroot": null
So I customized the variables from VSCode as follows:
{
"editor.renderControlCharacters": false,
"go.inferGopath": true,
"go.goroot": "C:\go",
}
Now this is the weird part. When I hit Ctrl+F5 compilation takes a "Example_c.c" file (?) and reports errors with that file (which I never created or even knew that existed):
# _/c_/Scripts
C:UsersMikeAppDataLocalTempgo-build530760830b001_x003.o: In function `main':
./Example_c.c:1: multiple definition of `main'
C:UsersMikeAppDataLocalTempgo-build530760830b001_cgo_main.o:/tmp/go-build/_cgo_main.c:1: first defined here
C:UsersMikeAppDataLocalTempgo-build530760830b001_x004.o: In function `main':
./Test_C-01.c:3: multiple definition of `main'
C:UsersMikeAppDataLocalTempgo-build530760830b001_cgo_main.o:/tmp/go-build/_cgo_main.c:1: first defined here
C:UsersMikeAppDataLocalTempgo-build530760830b001_x005.o: In function `main':
./Test_C-02.c:3: multiple definition of `main'
C:UsersMikeAppDataLocalTempgo-build530760830b001_cgo_main.o:/tmp/go-build/_cgo_main.c:1: first defined here
collect2: ld returned 1 exit status
# _/c_/Scripts
Example_c.c: In function 'main':
Example_c.c:2:3: warning: incompatible implicit declaration of built-in function 'printf'
Example_c.c:4:19: warning: incompatible implicit declaration of built-in function 'malloc'
Example_c.c:9:3: warning: incompatible implicit declaration of built-in function 'free'
exit status 2
Process exiting with code: 1
I already tried deleting all my temporary files and restarted VsCode multiple times. The whole experience to setup a Go environment to debug a hello world is really dissapointing.
What else can I check? Any hints?
go visual-studio-code vscode-settings
I just tried to execute a Hello World from VSCode 1.28.2 (Windows 8.1) in a C:Scriptshello_world.go file:
package main
import (
"fmt"
)
func main() {
fmt.Println("Hello, Gopher!")
}
My environment is as follows:
- I installed Go from scratch using the Windows installer:
$ go version
go version go1.11.2 windows/amd64
- Installed on C:Go
- Installed VSCode Go Extension: https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go
- Installed debugger:
go get -u github.com/derekparker/delve/cmd/dlv
- Checked with SystemPropertiesAdvanced:
- Local Variable GOPATH = %USERPROFILE%go
- Local Variable PATH adds %USERPROFILE%gobin
- System Variable PATH adds C:Gobin
- System Variable GOROOT = C:Go
- I have MinGW64, GitBash and MinGW 1.0 (However I don't see how that could affect running Go from VSCode)
- Running from cmd.exe runs the program without problems at all:
C:Scripts>go run hello_world.go
Hello, Gopher!
In VSCode settings my global go.gopath and go.goroot settings are:
// Specify GOPATH here to override the one that is set as environment variable. The inferred GOPATH from workspace root overrides this, if go.inferGopath is set to true.
"go.gopath": null
// Specifies the GOROOT to use when no environment variable is set.
"go.goroot": null
So I customized the variables from VSCode as follows:
{
"editor.renderControlCharacters": false,
"go.inferGopath": true,
"go.goroot": "C:\go",
}
Now this is the weird part. When I hit Ctrl+F5 compilation takes a "Example_c.c" file (?) and reports errors with that file (which I never created or even knew that existed):
# _/c_/Scripts
C:UsersMikeAppDataLocalTempgo-build530760830b001_x003.o: In function `main':
./Example_c.c:1: multiple definition of `main'
C:UsersMikeAppDataLocalTempgo-build530760830b001_cgo_main.o:/tmp/go-build/_cgo_main.c:1: first defined here
C:UsersMikeAppDataLocalTempgo-build530760830b001_x004.o: In function `main':
./Test_C-01.c:3: multiple definition of `main'
C:UsersMikeAppDataLocalTempgo-build530760830b001_cgo_main.o:/tmp/go-build/_cgo_main.c:1: first defined here
C:UsersMikeAppDataLocalTempgo-build530760830b001_x005.o: In function `main':
./Test_C-02.c:3: multiple definition of `main'
C:UsersMikeAppDataLocalTempgo-build530760830b001_cgo_main.o:/tmp/go-build/_cgo_main.c:1: first defined here
collect2: ld returned 1 exit status
# _/c_/Scripts
Example_c.c: In function 'main':
Example_c.c:2:3: warning: incompatible implicit declaration of built-in function 'printf'
Example_c.c:4:19: warning: incompatible implicit declaration of built-in function 'malloc'
Example_c.c:9:3: warning: incompatible implicit declaration of built-in function 'free'
exit status 2
Process exiting with code: 1
I already tried deleting all my temporary files and restarted VsCode multiple times. The whole experience to setup a Go environment to debug a hello world is really dissapointing.
What else can I check? Any hints?
go visual-studio-code vscode-settings
go visual-studio-code vscode-settings
edited Nov 13 at 19:39
Gama11
10.7k21945
10.7k21945
asked Nov 13 at 3:51
user869097
731312
731312
github.com/Microsoft/vscode-go/wiki/…
– 23k
Nov 13 at 3:57
add a comment |
github.com/Microsoft/vscode-go/wiki/…
– 23k
Nov 13 at 3:57
github.com/Microsoft/vscode-go/wiki/…
– 23k
Nov 13 at 3:57
github.com/Microsoft/vscode-go/wiki/…
– 23k
Nov 13 at 3:57
add a comment |
1 Answer
1
active
oldest
votes
Your GOPATH should point to "C:Scripts". Then point the "program" variable in launch.json to "C:Scripts" to run it in Debug Mode.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273523%2fvscode-go-extension-debugs-example-c-c-file-instead-of-actual-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Your GOPATH should point to "C:Scripts". Then point the "program" variable in launch.json to "C:Scripts" to run it in Debug Mode.
add a comment |
Your GOPATH should point to "C:Scripts". Then point the "program" variable in launch.json to "C:Scripts" to run it in Debug Mode.
add a comment |
Your GOPATH should point to "C:Scripts". Then point the "program" variable in launch.json to "C:Scripts" to run it in Debug Mode.
Your GOPATH should point to "C:Scripts". Then point the "program" variable in launch.json to "C:Scripts" to run it in Debug Mode.
answered Nov 13 at 5:34
viggy
370116
370116
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53273523%2fvscode-go-extension-debugs-example-c-c-file-instead-of-actual-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
github.com/Microsoft/vscode-go/wiki/…
– 23k
Nov 13 at 3:57