nsf / gocode

An autocompletion daemon for the Go programming language
MIT License
5.01k stars 656 forks source link

Gocode panic: Go 1.9.2 #488

Closed luckcolors closed 6 years ago

luckcolors commented 6 years ago

Hello! I've just recently updated go to the latest version 1.9.2 and gocode doesn't work anymore. I've already tried re installing gocode and to clean the GOPATH/pkg directory but the problem still occurs.

2017/12/30 21:13:19 -------------------------------------------------------
package main

import "github.com/labstack/echo"

func main() {
        e := echo.new()
        e.#
}
2017/12/30 21:13:19 -------------------------------------------------------
2017/12/30 21:13:19 Import path "github.com/labstack/echo" was not resolved
2017/12/30 21:13:19 Gocode's build context is:
2017/12/30 21:13:19  GOROOT: I:\DevTools\Go
2017/12/30 21:13:19  GOPATH: I:\Gopath
2017/12/30 21:13:19  GOOS: windows
2017/12/30 21:13:19  GOARCH: amd64
2017/12/30 21:13:19  BzlProjectRoot: ""
2017/12/30 21:13:19  GBProjectRoot: ""
2017/12/30 21:13:19  lib-path: ""
2017/12/30 21:13:19 Error parsing input file (inner block):
2017/12/30 21:13:19  5:4: expected selector or type assertion, found ';'
2017/12/30 21:13:19 extracted expression tokens: e
panic: runtime error: invalid memory address or nil pointer dereference
1(runtime.call32): I:/DevTools/Go/src/runtime/asm_amd64.s:509
2(runtime.gopanic): I:/DevTools/Go/src/runtime/panic.go:491
3(runtime.panicmem): I:/DevTools/Go/src/runtime/panic.go:63
4(runtime.sigpanic): I:/DevTools/Go/src/runtime/signal_windows.go:161
5(main.(*auto_complete_context).apropos): I:/Gopath/src/github.com/nsf/gocode/autocompletecontext.go:384
6(main.server_auto_complete): I:/Gopath/src/github.com/nsf/gocode/server.go:202
7(main.(*RPC).RPC_auto_complete): I:/Gopath/src/github.com/nsf/gocode/rpc.go:26
8(runtime.call64): I:/DevTools/Go/src/runtime/asm_amd64.s:510
9(reflect.Value.call): I:/DevTools/Go/src/reflect/value.go:434
10(reflect.Value.Call): I:/DevTools/Go/src/reflect/value.go:302
11(net/rpc.(*service).call): I:/DevTools/Go/src/net/rpc/server.go:381
12(runtime.goexit): I:/DevTools/Go/src/runtime/asm_amd64.s:2337

Let me know if you need more info, the go code is just the tiny snippet present in the log already. :)

nsf commented 6 years ago

I fixed that particular panic, but it won't help you in your case. Because this:

2017/12/30 21:13:19 Import path "github.com/labstack/echo" was not resolved

Make sure GOPATH is correct and everything. Or maybe you haven't go get the package yet.

luckcolors commented 6 years ago

You're right. My bad i forgot to go get it. I've also noticed the typo of e.new() not being e.New().

2017/12/30 22:33:04 -------------------------------------------------------
package main

import "github.com/labstack/echo"

func main() {
        e := echo.New()
        e.An#
        e.Logger.Fatal(e.Start(":1323"))
}
2017/12/30 22:33:04 -------------------------------------------------------
2017/12/30 22:33:04 Found "github.com/labstack/echo" at "I:\\Gopath\\pkg\\windows_amd64\\github.com\\labstack\\echo.a"
2017/12/30 22:33:04 extracted expression tokens: e
2017/12/30 22:33:04 Offset: 2
2017/12/30 22:33:04 Number of candidates found: 1
2017/12/30 22:33:04 Candidates are:
2017/12/30 22:33:04   func Any(path string, handler !I:\Gopath\pkg\windows_amd64\github.com\labstack\echo.a!echo.HandlerFunc, middleware ...!I:\Gopath\pkg\windows_amd64\github
.com\labstack\echo.a!echo.MiddlewareFunc) []*!I:\Gopath\pkg\windows_amd64\github.com\labstack\echo.a!echo.Route
2017/12/30 22:33:04 =======================================================

I suppose this log now means it's working as intended (even if in atom go plus says otherwise). It prints this there:

[2, [{"class": "func", "name": "Any", "type": "func(path string, handler !I:\Gopath\pkg\windows_amd64\github.com\labstack\echo.a!echo.HandlerFunc, middleware ...!I:\Gopath\pkg\windows_amd64\github.com\labstack\echo.a!echo.MiddlewareFunc) []*!I:\Gopath\pkg\windows_amd64\github.com\labstack\echo.a!echo.Route", "package": "github.com/labstack/echo"}]]

Can you confirm that?

nsf commented 6 years ago

Yes, there will be some noise in the output if you run gocode in debug mode. E.g.

!I:\Gopath\pkg\windows_amd64\github.com\labstack\echo.a!echo.HandlerFunc

It includes full lib path here which is normally stripped away on output. But other than that it seems to be working.

luckcolors commented 6 years ago

Ok thanks! Gocode seems to work perfectly now. :)