VsCode Go extension debugs Example_c.c file instead of actual file












0














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?










share|improve this question
























  • github.com/Microsoft/vscode-go/wiki/…
    – 23k
    Nov 13 at 3:57
















0














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?










share|improve this question
























  • github.com/Microsoft/vscode-go/wiki/…
    – 23k
    Nov 13 at 3:57














0












0








0







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?










share|improve this question















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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


















  • 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












1 Answer
1






active

oldest

votes


















0














Your GOPATH should point to "C:Scripts". Then point the "program" variable in launch.json to "C:Scripts" to run it in Debug Mode.






share|improve this answer





















    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
    });


    }
    });














    draft saved

    draft discarded


















    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









    0














    Your GOPATH should point to "C:Scripts". Then point the "program" variable in launch.json to "C:Scripts" to run it in Debug Mode.






    share|improve this answer


























      0














      Your GOPATH should point to "C:Scripts". Then point the "program" variable in launch.json to "C:Scripts" to run it in Debug Mode.






      share|improve this answer
























        0












        0








        0






        Your GOPATH should point to "C:Scripts". Then point the "program" variable in launch.json to "C:Scripts" to run it in Debug Mode.






        share|improve this answer












        Your GOPATH should point to "C:Scripts". Then point the "program" variable in launch.json to "C:Scripts" to run it in Debug Mode.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 13 at 5:34









        viggy

        370116




        370116






























            draft saved

            draft discarded




















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Guess what letter conforming each word

            Port of Spain

            Run scheduled task as local user group (not BUILTIN)