Delve is not working during debugging golang in vs code












0















I am learning golang and try to debug a sample code which comes from one of my golang book. It is very strange that delve debugger is not working as expected.



enter image description here



As you can see in this picture, I can set break point at line 83 and continue to run program to this break point. On the left panel, I can see the variables and call stack are displayed. But when I step into next statement from that break point, the debugger seems to be stopped. All the
variables are cleared out but call stack still showing me the problem is running like picture below:



enter image description here



I also tried delve debugger in command line (out side vs-code), I got the same issue on the same break point.



VS-Code launch.json like below:



{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "${fileDirname}",
"env": {},
"args": ,
"trace": true
}
]
}


Go version: 1.10.3 windows/amd64



Delve debugger version: 1.1.0



VS-Code version: 1.29.0



Do I need other configuration?



I attach source code here, you can give a try and see what happen on your machine.



Source Code:



package main

import (
"bufio"
"fmt"
"io"
"log"
"os"
"path/filepath"
"regexp"
)

func filenamesFromCmdLine() (inFilename, outFilename string, err error) {
if len(os.Args) > 1 && (os.Args[1] == "-h" || os.Args[1] == "--help") {
err = fmt.Errorf("Usage: %s [<]infile.txt [>]outfile.txt", filepath.Base(os.Args[0]))
return "", "", err
}

if len(os.Args) > 1 {
inFilename = os.Args[1]
}
if len(os.Args) > 2 {
outFilename = os.Args[2]
}
if inFilename != "" && inFilename == outFilename {
log.Fatal("won't overwrite the infile")
}

return inFilename, outFilename, nil
}

func americanise(inFile io.Reader, outFile io.Writer) (err error) {

reader := bufio.NewReader(inFile)
writer := bufio.NewWriter(outFile)
defer func() {
if err == nil {
err = writer.Flush()
}
}()

var replacer func(string) string

wordRx := regexp.MustCompile("[A-Za-z]+")
eof := false
for !eof {
var line string
line, err = reader.ReadString('n')
if err == io.EOF {
err = nil
eof = true
} else if err != nil {
return err
}
line = wordRx.ReplaceAllStringFunc(line, replacer)
if _, err = writer.WriteString(line); err != nil {
return err
}
}

return nil
}

func main() {
inFilename, outFilename, err := filenamesFromCmdLine()
if err != nil {
fmt.Println(err)
os.Exit(0)
}

//why we initialize them to stdin and stdout?
//the file object has been set to os.Stdin and os.Stdout
inFile, outFile := os.Stdin, os.Stdout

if inFilename != "" {
//os.Open() returns *os.File that can be used for reading the file.
if inFile, err = os.Open(inFilename); err != nil {
log.Fatal(err)
}
//defer inFile.Close()
}

if outFilename != "" {
//create a new file or truncate to zero length for existing file
if outFile, err = os.Create(outFilename); err != nil {
log.Fatal(err)
}
defer outFile.Close()
}

if err = americanise(inFile, outFile); err != nil {
log.Fatal(err)
}
}









share|improve this question





























    0















    I am learning golang and try to debug a sample code which comes from one of my golang book. It is very strange that delve debugger is not working as expected.



    enter image description here



    As you can see in this picture, I can set break point at line 83 and continue to run program to this break point. On the left panel, I can see the variables and call stack are displayed. But when I step into next statement from that break point, the debugger seems to be stopped. All the
    variables are cleared out but call stack still showing me the problem is running like picture below:



    enter image description here



    I also tried delve debugger in command line (out side vs-code), I got the same issue on the same break point.



    VS-Code launch.json like below:



    {
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
    {
    "name": "Launch",
    "type": "go",
    "request": "launch",
    "mode": "auto",
    "program": "${fileDirname}",
    "env": {},
    "args": ,
    "trace": true
    }
    ]
    }


    Go version: 1.10.3 windows/amd64



    Delve debugger version: 1.1.0



    VS-Code version: 1.29.0



    Do I need other configuration?



    I attach source code here, you can give a try and see what happen on your machine.



    Source Code:



    package main

    import (
    "bufio"
    "fmt"
    "io"
    "log"
    "os"
    "path/filepath"
    "regexp"
    )

    func filenamesFromCmdLine() (inFilename, outFilename string, err error) {
    if len(os.Args) > 1 && (os.Args[1] == "-h" || os.Args[1] == "--help") {
    err = fmt.Errorf("Usage: %s [<]infile.txt [>]outfile.txt", filepath.Base(os.Args[0]))
    return "", "", err
    }

    if len(os.Args) > 1 {
    inFilename = os.Args[1]
    }
    if len(os.Args) > 2 {
    outFilename = os.Args[2]
    }
    if inFilename != "" && inFilename == outFilename {
    log.Fatal("won't overwrite the infile")
    }

    return inFilename, outFilename, nil
    }

    func americanise(inFile io.Reader, outFile io.Writer) (err error) {

    reader := bufio.NewReader(inFile)
    writer := bufio.NewWriter(outFile)
    defer func() {
    if err == nil {
    err = writer.Flush()
    }
    }()

    var replacer func(string) string

    wordRx := regexp.MustCompile("[A-Za-z]+")
    eof := false
    for !eof {
    var line string
    line, err = reader.ReadString('n')
    if err == io.EOF {
    err = nil
    eof = true
    } else if err != nil {
    return err
    }
    line = wordRx.ReplaceAllStringFunc(line, replacer)
    if _, err = writer.WriteString(line); err != nil {
    return err
    }
    }

    return nil
    }

    func main() {
    inFilename, outFilename, err := filenamesFromCmdLine()
    if err != nil {
    fmt.Println(err)
    os.Exit(0)
    }

    //why we initialize them to stdin and stdout?
    //the file object has been set to os.Stdin and os.Stdout
    inFile, outFile := os.Stdin, os.Stdout

    if inFilename != "" {
    //os.Open() returns *os.File that can be used for reading the file.
    if inFile, err = os.Open(inFilename); err != nil {
    log.Fatal(err)
    }
    //defer inFile.Close()
    }

    if outFilename != "" {
    //create a new file or truncate to zero length for existing file
    if outFile, err = os.Create(outFilename); err != nil {
    log.Fatal(err)
    }
    defer outFile.Close()
    }

    if err = americanise(inFile, outFile); err != nil {
    log.Fatal(err)
    }
    }









    share|improve this question



























      0












      0








      0


      1






      I am learning golang and try to debug a sample code which comes from one of my golang book. It is very strange that delve debugger is not working as expected.



      enter image description here



      As you can see in this picture, I can set break point at line 83 and continue to run program to this break point. On the left panel, I can see the variables and call stack are displayed. But when I step into next statement from that break point, the debugger seems to be stopped. All the
      variables are cleared out but call stack still showing me the problem is running like picture below:



      enter image description here



      I also tried delve debugger in command line (out side vs-code), I got the same issue on the same break point.



      VS-Code launch.json like below:



      {
      // Use IntelliSense to learn about possible attributes.
      // Hover to view descriptions of existing attributes.
      // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
      "version": "0.2.0",
      "configurations": [
      {
      "name": "Launch",
      "type": "go",
      "request": "launch",
      "mode": "auto",
      "program": "${fileDirname}",
      "env": {},
      "args": ,
      "trace": true
      }
      ]
      }


      Go version: 1.10.3 windows/amd64



      Delve debugger version: 1.1.0



      VS-Code version: 1.29.0



      Do I need other configuration?



      I attach source code here, you can give a try and see what happen on your machine.



      Source Code:



      package main

      import (
      "bufio"
      "fmt"
      "io"
      "log"
      "os"
      "path/filepath"
      "regexp"
      )

      func filenamesFromCmdLine() (inFilename, outFilename string, err error) {
      if len(os.Args) > 1 && (os.Args[1] == "-h" || os.Args[1] == "--help") {
      err = fmt.Errorf("Usage: %s [<]infile.txt [>]outfile.txt", filepath.Base(os.Args[0]))
      return "", "", err
      }

      if len(os.Args) > 1 {
      inFilename = os.Args[1]
      }
      if len(os.Args) > 2 {
      outFilename = os.Args[2]
      }
      if inFilename != "" && inFilename == outFilename {
      log.Fatal("won't overwrite the infile")
      }

      return inFilename, outFilename, nil
      }

      func americanise(inFile io.Reader, outFile io.Writer) (err error) {

      reader := bufio.NewReader(inFile)
      writer := bufio.NewWriter(outFile)
      defer func() {
      if err == nil {
      err = writer.Flush()
      }
      }()

      var replacer func(string) string

      wordRx := regexp.MustCompile("[A-Za-z]+")
      eof := false
      for !eof {
      var line string
      line, err = reader.ReadString('n')
      if err == io.EOF {
      err = nil
      eof = true
      } else if err != nil {
      return err
      }
      line = wordRx.ReplaceAllStringFunc(line, replacer)
      if _, err = writer.WriteString(line); err != nil {
      return err
      }
      }

      return nil
      }

      func main() {
      inFilename, outFilename, err := filenamesFromCmdLine()
      if err != nil {
      fmt.Println(err)
      os.Exit(0)
      }

      //why we initialize them to stdin and stdout?
      //the file object has been set to os.Stdin and os.Stdout
      inFile, outFile := os.Stdin, os.Stdout

      if inFilename != "" {
      //os.Open() returns *os.File that can be used for reading the file.
      if inFile, err = os.Open(inFilename); err != nil {
      log.Fatal(err)
      }
      //defer inFile.Close()
      }

      if outFilename != "" {
      //create a new file or truncate to zero length for existing file
      if outFile, err = os.Create(outFilename); err != nil {
      log.Fatal(err)
      }
      defer outFile.Close()
      }

      if err = americanise(inFile, outFile); err != nil {
      log.Fatal(err)
      }
      }









      share|improve this question
















      I am learning golang and try to debug a sample code which comes from one of my golang book. It is very strange that delve debugger is not working as expected.



      enter image description here



      As you can see in this picture, I can set break point at line 83 and continue to run program to this break point. On the left panel, I can see the variables and call stack are displayed. But when I step into next statement from that break point, the debugger seems to be stopped. All the
      variables are cleared out but call stack still showing me the problem is running like picture below:



      enter image description here



      I also tried delve debugger in command line (out side vs-code), I got the same issue on the same break point.



      VS-Code launch.json like below:



      {
      // Use IntelliSense to learn about possible attributes.
      // Hover to view descriptions of existing attributes.
      // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
      "version": "0.2.0",
      "configurations": [
      {
      "name": "Launch",
      "type": "go",
      "request": "launch",
      "mode": "auto",
      "program": "${fileDirname}",
      "env": {},
      "args": ,
      "trace": true
      }
      ]
      }


      Go version: 1.10.3 windows/amd64



      Delve debugger version: 1.1.0



      VS-Code version: 1.29.0



      Do I need other configuration?



      I attach source code here, you can give a try and see what happen on your machine.



      Source Code:



      package main

      import (
      "bufio"
      "fmt"
      "io"
      "log"
      "os"
      "path/filepath"
      "regexp"
      )

      func filenamesFromCmdLine() (inFilename, outFilename string, err error) {
      if len(os.Args) > 1 && (os.Args[1] == "-h" || os.Args[1] == "--help") {
      err = fmt.Errorf("Usage: %s [<]infile.txt [>]outfile.txt", filepath.Base(os.Args[0]))
      return "", "", err
      }

      if len(os.Args) > 1 {
      inFilename = os.Args[1]
      }
      if len(os.Args) > 2 {
      outFilename = os.Args[2]
      }
      if inFilename != "" && inFilename == outFilename {
      log.Fatal("won't overwrite the infile")
      }

      return inFilename, outFilename, nil
      }

      func americanise(inFile io.Reader, outFile io.Writer) (err error) {

      reader := bufio.NewReader(inFile)
      writer := bufio.NewWriter(outFile)
      defer func() {
      if err == nil {
      err = writer.Flush()
      }
      }()

      var replacer func(string) string

      wordRx := regexp.MustCompile("[A-Za-z]+")
      eof := false
      for !eof {
      var line string
      line, err = reader.ReadString('n')
      if err == io.EOF {
      err = nil
      eof = true
      } else if err != nil {
      return err
      }
      line = wordRx.ReplaceAllStringFunc(line, replacer)
      if _, err = writer.WriteString(line); err != nil {
      return err
      }
      }

      return nil
      }

      func main() {
      inFilename, outFilename, err := filenamesFromCmdLine()
      if err != nil {
      fmt.Println(err)
      os.Exit(0)
      }

      //why we initialize them to stdin and stdout?
      //the file object has been set to os.Stdin and os.Stdout
      inFile, outFile := os.Stdin, os.Stdout

      if inFilename != "" {
      //os.Open() returns *os.File that can be used for reading the file.
      if inFile, err = os.Open(inFilename); err != nil {
      log.Fatal(err)
      }
      //defer inFile.Close()
      }

      if outFilename != "" {
      //create a new file or truncate to zero length for existing file
      if outFile, err = os.Create(outFilename); err != nil {
      log.Fatal(err)
      }
      defer outFile.Close()
      }

      if err = americanise(inFile, outFile); err != nil {
      log.Fatal(err)
      }
      }






      go delve






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 16 '18 at 1:26







      Jeffrey Yang

















      asked Nov 15 '18 at 8:57









      Jeffrey YangJeffrey Yang

      163




      163
























          2 Answers
          2






          active

          oldest

          votes


















          1














          Unfortunately Delve in VS-Code does not handle "GoTo Next Step" well when you are executing multiple go routines with each waiting for going to Next Step. One workaround I use is that I put another debug point where I want the debugging to stop and then select "Continue" option.






          share|improve this answer































            0














            I'm not sure about your situation but there was a bug in vscode-go previous versions. Does your version 0.7.0 ?






            share|improve this answer
























            • yes, my vscode-go plugin version is 0.7.0, btw, i tried delve debugger in command line (outside vs code), but I got the same issue.

              – Jeffrey Yang
              Nov 15 '18 at 12:23











            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%2f53315661%2fdelve-is-not-working-during-debugging-golang-in-vs-code%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Unfortunately Delve in VS-Code does not handle "GoTo Next Step" well when you are executing multiple go routines with each waiting for going to Next Step. One workaround I use is that I put another debug point where I want the debugging to stop and then select "Continue" option.






            share|improve this answer




























              1














              Unfortunately Delve in VS-Code does not handle "GoTo Next Step" well when you are executing multiple go routines with each waiting for going to Next Step. One workaround I use is that I put another debug point where I want the debugging to stop and then select "Continue" option.






              share|improve this answer


























                1












                1








                1







                Unfortunately Delve in VS-Code does not handle "GoTo Next Step" well when you are executing multiple go routines with each waiting for going to Next Step. One workaround I use is that I put another debug point where I want the debugging to stop and then select "Continue" option.






                share|improve this answer













                Unfortunately Delve in VS-Code does not handle "GoTo Next Step" well when you are executing multiple go routines with each waiting for going to Next Step. One workaround I use is that I put another debug point where I want the debugging to stop and then select "Continue" option.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 15 '18 at 11:50









                viggyviggy

                370118




                370118

























                    0














                    I'm not sure about your situation but there was a bug in vscode-go previous versions. Does your version 0.7.0 ?






                    share|improve this answer
























                    • yes, my vscode-go plugin version is 0.7.0, btw, i tried delve debugger in command line (outside vs code), but I got the same issue.

                      – Jeffrey Yang
                      Nov 15 '18 at 12:23
















                    0














                    I'm not sure about your situation but there was a bug in vscode-go previous versions. Does your version 0.7.0 ?






                    share|improve this answer
























                    • yes, my vscode-go plugin version is 0.7.0, btw, i tried delve debugger in command line (outside vs code), but I got the same issue.

                      – Jeffrey Yang
                      Nov 15 '18 at 12:23














                    0












                    0








                    0







                    I'm not sure about your situation but there was a bug in vscode-go previous versions. Does your version 0.7.0 ?






                    share|improve this answer













                    I'm not sure about your situation but there was a bug in vscode-go previous versions. Does your version 0.7.0 ?







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Nov 15 '18 at 9:41









                    MagiqMagiq

                    213




                    213













                    • yes, my vscode-go plugin version is 0.7.0, btw, i tried delve debugger in command line (outside vs code), but I got the same issue.

                      – Jeffrey Yang
                      Nov 15 '18 at 12:23



















                    • yes, my vscode-go plugin version is 0.7.0, btw, i tried delve debugger in command line (outside vs code), but I got the same issue.

                      – Jeffrey Yang
                      Nov 15 '18 at 12:23

















                    yes, my vscode-go plugin version is 0.7.0, btw, i tried delve debugger in command line (outside vs code), but I got the same issue.

                    – Jeffrey Yang
                    Nov 15 '18 at 12:23





                    yes, my vscode-go plugin version is 0.7.0, btw, i tried delve debugger in command line (outside vs code), but I got the same issue.

                    – Jeffrey Yang
                    Nov 15 '18 at 12:23


















                    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.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53315661%2fdelve-is-not-working-during-debugging-golang-in-vs-code%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

                    Bressuire

                    Vorschmack

                    Quarantine