Search code examples
gosublimetext3sublimelinter

GoType issues with SublimeLinter


I'm a bit new to Go, and I've been trying to use the SublimeLinter-contrib-gotype package to lint my files. It works well for the most part, but for some reason it throws an error if I try to import a Go package from GitHub. I've been trying to use the simple example from the Echo framework. When I run the code, it works fine but for some reason the linter is causing issues.

It throws an error saying:

could not import github.com/labstack/echo (can't find import: )

I've already run the go get github.com/labstack/echo command, but it doesn't seem to have helped.

I've attached a screenshot as well:

And here is a link to the code I was using.


Solution

  • I'd faced the same problem. Try running

    launchctl setenv GOPATH $GOPATH

    and restarting ST, this won't work after a reboot.

    Source

    If you use Go Sublime, the following should work better.

    Sublime Text menu > Preferences > Package Settings > GoSublime > Settings - Default / User

    "shell": ["/usr/bin/bash"],
    "env": {"GOPATH": "/Users/username/gopath/"},