sublime-go
sublime-go copied to clipboard
Error in lint.py
For some reason just the file name is being passed into the parse function in lint.py, where it is expecting the file path. So it's trying to split string and fails. Not sure what the fix is for this.
Traceback (most recent call last):
.../go/decorators.py", line 51, in <lambda>
.../go/decorators.py", line 57, in call
.../go/decorators.py", line 12, in tracer
.../go/lint.py", line 27, in run
.../go/lint.py", line 42, in parse
.../go/lint.py", line 106, in parse
ValueError: too many values to unpack (expected 3)
Can you provide some debug info?
- sublime text version (in the console:
sublime.version()) - go version (run
go env)
Also, what the directory structure looks like? is it a single window, single file or just a regular project with go.mod?
I have this issue as well and I think the problem is with finding the golint program which is likely installed in our GOPATH and not system-wide e.g. in /bin.
This is what I see in sublime console whenever I save a go file: (with sublime-go just freshly installed; no changes to configuration)
Traceback (most recent call last):
File "/Users/rsms/Library/Application Support/Sublime Text 3/Installed Packages/Golang.sublime-package/go/decorators.py", line 51, in <lambda>
File "/Users/rsms/Library/Application Support/Sublime Text 3/Installed Packages/Golang.sublime-package/go/decorators.py", line 57, in call
File "/Users/rsms/Library/Application Support/Sublime Text 3/Installed Packages/Golang.sublime-package/go/decorators.py", line 12, in tracer
File "/Users/rsms/Library/Application Support/Sublime Text 3/Installed Packages/Golang.sublime-package/go/lint.py", line 27, in run
File "/Users/rsms/Library/Application Support/Sublime Text 3/Installed Packages/Golang.sublime-package/go/lint.py", line 42, in parse
File "/Users/rsms/Library/Application Support/Sublime Text 3/Installed Packages/Golang.sublime-package/go/lint.py", line 106, in parse
ValueError: too many values to unpack (expected 3)
sublime.version() 3211
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/rsms/Library/Caches/go-build"
GOENV="/Users/rsms/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/rsms/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/rsms/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.15.3/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.15.3/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/rsms/src/ljus/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/lj/xnhllk113_7f71yqt5n7jmth0000gn/T/go-build309220068=/tmp/go-build -gno-record-gcc-switches -fno-common"
golint
$ which golint
/Users/rsms/go/bin/golint
PATH visible to sublime: import os; os.environ['PATH'] in sublime console yields /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin — note that dirname $(which golint) is NOT in this path. Also import os; os.environ['GOPATH'] yields KeyError: 'GOPATH'. AFAIK there is no way to alter the environment in Sublime Text (I do have "shell_environment": true in my ST settings.)
Offending line causing the error:
https://github.com/yields/sublime-go/blob/5c72dade32f45fb920c4b8f7907e41da806feb27/go/lint.py#L99-L106
The last line here with parameter filepath is a list. It comes from here:
https://github.com/yields/sublime-go/blob/5c72dade32f45fb920c4b8f7907e41da806feb27/go/buffer.py#L77-L81
You're trying to destruct a string (the filename) as a 3-element tuple/list.
Calls goes like this:
- https://github.com/yields/sublime-go/blob/5c72dade32f45fb920c4b8f7907e41da806feb27/go/commands.py#L54
- https://github.com/yields/sublime-go/blob/5c72dade32f45fb920c4b8f7907e41da806feb27/go/lint.py#L21
- https://github.com/yields/sublime-go/blob/5c72dade32f45fb920c4b8f7907e41da806feb27/go/buffer.py#L81
- https://github.com/yields/sublime-go/blob/5c72dade32f45fb920c4b8f7907e41da806feb27/go/lint.py#L27
- https://github.com/yields/sublime-go/blob/5c72dade32f45fb920c4b8f7907e41da806feb27/go/lint.py#L106 ← BOOM!