Posts Tagged visual studio code

Fixing not working auto-completion for golang in Visual Studio Code

gophervsMy favorite code editor for GO  (Visual Studio Code with Go extenstion from lukehoban) on my Mac sometimes loses its intelligent behavior when suddenly code completion stops to work.

Usually just couple of commands in terminal recovers auto-completion back to life:

  1. Close Visual Studio Code
  2. Open terminal and stop gocode with gocode close
  3. Update gocode with the command `go get -u github.com/nsf/gocode`
  4. Start Visual Studio Code again and enjoy.

, , , , , ,

Leave a comment

How to debug if you use goapp instead of go

I recently switched my editor for GOLANG from Sublime Text to Visual Studio Code using it together with plugin vscode-go. It is working perfectly and now there is much more pleasant to code in this IDE using GO. But I still missed one feature: debugger. vscode-go supports  visual debugging using delve but the issue is that I’m developing with go both for google application engine (GAE) and creating also usual go programs, dalve refused to work when I was trying to debug usual GO programs using GOAPP (I have just a symlink from ‘go’ to ‘goapp’ in SDK, no separate go is installed) giving me the following error:

couldn't detect GO version

Looks like the parser of dalve couldn’t detect version of GO because google adds to it additional information and the output of the command ‘go version’ looks like

go1.6 (appengine-1.9.35)

instead of the standard

go1.6

So, I decided that it can be fixed easily and found this check in the file go_version.go

Next thing I did, I just added the code below  in the check to remove this part “(appengine-1.9.35)” from version information, the change should go in line 27 just after ‘if strings.HasPrefix(ver, go) {‘ in the file go_version.go

    indexStart := strings.Index(ver, "(")
    if indexStart > 0 {
        indexEnd := strings.Index(ver, ")")
        if indexEnd > indexStart {
            ver = ver[:indexStart] + ver[indexEnd+1:]
            ver = strings.Trim(ver, " ")
        }
    }

Then I compiled/installed dalve  again and my debugger inside of Visual Studio Code started to work!

Enjoy!

, , , , , ,

Leave a comment