An autocompletion daemon for the Go programming language

An autocompletion daemon for the Go programming language

VERY IMPORTANT: this project is not maintained anymore, look for alternatives or forks if you need Go autocompletion tool

IMPORTANT: consider switching to https://github.com/mdempsky/gocode if you have problems starting with Go version 1.10, due to changes in binary packages architecture (introduction of package cache) I'm not going to adjust gocode for it for quite some time. There is a higher chance that fork under the given link will have some solution to the problem sooner or later.

Gocode is a helper tool which is intended to be integrated with your source code editor, like vim, neovim and emacs. It provides several advanced capabilities, which currently includes:

  • Context-sensitive autocompletion

It is called daemon, because it uses client/server architecture for caching purposes. In particular, it makes autocompletions very fast. Typical autocompletion time with warm cache is 30ms, which is barely noticeable.

Also watch the demo screencast.

Gocode in vim

Gocode in emacs

Setup

  1. You should have a correctly installed Go compiler environment and your personal workspace ($GOPATH). If you have no idea what $GOPATH is, take a look here. Please make sure that your $GOPATH/bin is available in your $PATH. This is important, because most editors assume that gocode binary is available in one of the directories, specified by your $PATH environment variable. Otherwise manually copy the gocode binary from $GOPATH/bin to a location which is part of your $PATH after getting it in step 2.

    Do these steps only if you understand why you need to do them:

    export GOPATH=$HOME/goprojects

    export PATH=$PATH:$GOPATH/bin

  2. Then you need to get the appropriate version of the gocode, for 6g/8g/5g compiler you can do this:

    go get -u github.com/nsf/gocode (-u flag for "update")

    Windows users should consider doing this instead:

    go get -u -ldflags -H=windowsgui github.com/nsf/gocode

    That way on the Windows OS gocode will be built as a GUI application and doing so solves hanging window issues with some of the editors.

  3. Next steps are editor specific. See below.

Vim setup

Vim manual installation

Note: As of go 1.5 there is no $GOROOT/misc/vim script. Suggested installation is via vim-go plugin.

In order to install vim scripts, you need to fulfill the following steps:

  1. Install official Go vim scripts from $GOROOT/misc/vim. If you did that already, proceed to the step 2.

  2. Install gocode vim scripts. Usually it's enough to do the following:

    2.1. vim/update.sh

    update.sh script does the following:

    #!/bin/sh
    mkdir -p "$HOME/.vim/autoload"
    mkdir -p "$HOME/.vim/ftplugin/go"
    cp "${0%/*}/autoload/gocomplete.vim" "$HOME/.vim/autoload"
    cp "${0%/*}/ftplugin/go/gocomplete.vim" "$HOME/.vim/ftplugin/go"
    

    2.2. Alternatively, you can create symlinks using symlink.sh script in order to avoid running update.sh after every gocode update.

    symlink.sh script does the following:

    #!/bin/sh
    cd "${0%/*}"
    ROOTDIR=`pwd`
    mkdir -p "$HOME/.vim/autoload"
    mkdir -p "$HOME/.vim/ftplugin/go"
    ln -s "$ROOTDIR/autoload/gocomplete.vim" "$HOME/.vim/autoload/"
    ln -s "$ROOTDIR/ftplugin/go/gocomplete.vim" "$HOME/.vim/ftplugin/go/"
    
  3. Make sure vim has filetype plugin enabled. Simply add that to your .vimrc:

    filetype plugin on

  4. Autocompletion should work now. Use <C-x><C-o> for autocompletion (omnifunc autocompletion).

Using Vundle in Vim

Add the following line to your .vimrc:

Plugin 'nsf/gocode', {'rtp': 'vim/'}

And then update your packages by running :PluginInstall.

Using vim-plug in Vim

Add the following line to your .vimrc:

Plug 'nsf/gocode', { 'rtp': 'vim', 'do': '~/.vim/plugged/gocode/vim/symlink.sh' }

And then update your packages by running :PlugInstall.

Other

Alternatively take a look at the vundle/pathogen friendly repo: https://github.com/Blackrush/vim-gocode.

Neovim setup

Neovim manual installation

Neovim users should also follow Vim manual installation, except that you should goto gocode/nvim in step 2, and remember that, the Neovim configuration file is ~/.config/nvim/init.vim.

Using Vundle in Neovim

Add the following line to your init.vim:

Plugin 'nsf/gocode', {'rtp': 'nvim/'}

And then update your packages by running :PluginInstall.

Using vim-plug in Neovim

Add the following line to your init.vim:

Plug 'nsf/gocode', { 'rtp': 'nvim', 'do': '~/.config/nvim/plugged/gocode/nvim/symlink.sh' }

And then update your packages by running :PlugInstall.

Emacs setup

In order to install emacs script, you need to fulfill the following steps:

  1. Install auto-complete-mode

  2. Copy emacs/go-autocomplete.el file from the gocode source distribution to a directory which is in your 'load-path' in emacs.

  3. Add these lines to your .emacs:

    (require 'go-autocomplete)
    (require 'auto-complete-config)
    (ac-config-default)
    

Also, there is an alternative plugin for emacs using company-mode. See emacs-company/README for installation instructions.

If you're a MacOSX user, you may find that script useful: https://github.com/purcell/exec-path-from-shell. It helps you with setting up the right environment variables as Go and gocode require it. By default it pulls the PATH, but don't forget to add the GOPATH as well, e.g.:

(when (memq window-system '(mac ns))
  (exec-path-from-shell-initialize)
  (exec-path-from-shell-copy-env "GOPATH"))

Options

You can change all available options using gocode set command. The config file uses json format and is usually stored somewhere in ~/.config/gocode directory. On windows it's stored in the appropriate AppData folder. It's suggested to avoid modifying config file manually, do that using the gocode set command.

gocode set lists all options and their values.

gocode set <option> shows the value of that option.

gocode set <option> <value> sets the new value for that option.

  • propose-builtins

    A boolean option. If true, gocode will add built-in types, functions and constants to autocompletion proposals. Default: false.

  • lib-path

    A string option. Allows you to add search paths for packages. By default, gocode only searches $GOPATH/pkg/$GOOS_$GOARCH and $GOROOT/pkg/$GOOS_$GOARCH in terms of previously existed environment variables. Also you can specify multiple paths using ':' (colon) as a separator (on Windows use semicolon ';'). The paths specified by lib-path are prepended to the default ones.

  • autobuild

    A boolean option. If true, gocode will try to automatically build out-of-date packages when their source files are modified, in order to obtain the freshest autocomplete results for them. This feature is experimental. Default: false.

  • force-debug-output

    A string option. If is not empty, gocode will forcefully redirect the logging into that file. Also forces enabling of the debug mode on the server side. Default: "" (empty).

  • package-lookup-mode

    A string option. If go, use standard Go package lookup rules. If gb, use gb-specific lookup rules. See https://github.com/constabulary/gb for details. Default: go.

  • close-timeout

    An integer option. If there have been no completion requests after this number of seconds, the gocode process will terminate. Defaults to 1800 (30 minutes).

  • unimported-packages

    A boolean option. If set to true, gocode will try to import certain known packages automatically for identifiers which cannot be resolved otherwise. Currently only a limited set of standard library packages are supported. Default: false.

  • partials

    A boolean option. If set to false, gocode will not filter autocompletion results based on entered prefix before the cursor. Instead it will return all available autocompletion results viable for a given context. Whether this option is set to true or false, gocode will return a valid prefix length for output formats which support it. Setting this option to a non-default value may result in editor misbehaviour. Default: true.

  • ignore-case

    A boolean option. If set to true, gocode will perform case-insensitive matching when doing prefix-based filtering. Default: false.

  • class-filtering

    A boolean option. Enables or disables gocode's feature where it performs class-based filtering if partial input matches corresponding class keyword: const, var, type, func, package. Default: true.

Debugging

If something went wrong, the first thing you may want to do is manually start the gocode daemon with a debug mode enabled and in a separate terminal window. It will show you all the stack traces, panics if any and additional info about autocompletion requests. Shutdown the daemon if it was already started and run a new one explicitly with a debug mode enabled:

gocode close

gocode -s -debug

Please, report bugs, feature suggestions and other rants to the github issue tracker of this project.

Developing

There is Guide for IDE/editor plugin developers.

If you have troubles, please, contact me and I will try to do my best answering your questions. You can contact me via email. Or for short question find me on IRC: #go-nuts @ freenode.

Misc

  • It's a good idea to use the latest git version always. I'm trying to keep it in a working state.
  • Use go install (not go build) for building a local source tree. The objects in pkg/ are needed for Gocode to work.
Comments
  • Vim plugin works only when I run

    Vim plugin works only when I run "gocode -s"

    Hi. Vim plugin works only when I run "gocode -s" (server process). Even when vim is working and I run "gocode -s" in shell - autocompletion start working, when I stop - autocompletion doesn't work.

    $GOPATH/bin is in the path gocode plugin is in the runtimepath (using pathogen)

    Already got the latest version of gocode and rebuilded

    Can you help?

  • package_bin: support type alias

    package_bin: support type alias

    The golang/go master branch has been merged dev.typealias. Backport of golang/[email protected]

    Spec:

    • https://tip.golang.org/ref/spec#Types
    • https://tip.golang.org/ref/spec#Type_declarations

  • The only autocompletion I get is PANIC

    The only autocompletion I get is PANIC

    Hello,

    Just installed gocode a few minutes earlier and all attempts to get it to work in vim failed. Ultimately, I started a server manually (gocode -s) and then using the gocode client in command line, I tried: "gocode autocomplete math.F" and that resulted in a:

    Found 1 candidates:
      PANIC PANIC PANIC
    

    Verifying the server window that showed:

    panic: runtime error: index out of range
    1(runtime.panic): /usr/local/go/src/pkg/runtime/panic.c:248
    2(runtime.panicstring): /usr/local/go/src/pkg/runtime/panic.c:478
    3(runtime.panicindex): /usr/local/go/src/pkg/runtime/panic.c:433
    4(main.(*tok_collection).find_decl_beg): /home/alex/.go/src/github.com/nsf/gocode/ripper.go:39
    5(main.(*tok_collection).find_outermost_scope): /home/alex/.go/src/github.com/nsf/gocode/ripper.go:102
    6(main.(*tok_collection).rip_off_decl): /home/alex/.go/src/github.com/nsf/gocode/ripper.go:116
    7(main.rip_off_decl): /home/alex/.go/src/github.com/nsf/gocode/ripper.go:133
    8(main.(*auto_complete_file).process_data): /home/alex/.go/src/github.com/nsf/gocode/autocompletefile.go:55
    9(main.(*auto_complete_context).apropos): /home/alex/.go/src/github.com/nsf/gocode/autocompletecontext.go:241
    10(main.server_auto_complete): /home/alex/.go/src/github.com/nsf/gocode/server.go:128
    11(main.(*RPC).RPC_auto_complete): /home/alex/.go/src/github.com/nsf/gocode/rpc.go:26
    12(runtime.call64): /usr/local/go/src/pkg/runtime/asm_amd64.s:340
    13(reflect.Value.call): /usr/local/go/src/pkg/reflect/value.go:474
    14(reflect.Value.Call): /usr/local/go/src/pkg/reflect/value.go:345
    15(net/rpc.(*service).call): /usr/local/go/src/pkg/net/rpc/server.go:381
    16(runtime.goexit): /usr/local/go/src/pkg/runtime/proc.c:1389
    

    I am using Go version: go version devel +f4d1cb8d9a91 Thu Sep 19 22:34:33 2013 +1000 linux/amd64

    Please let me know if there's any other info I can provide.

    Thank you, really looking forward to using this in Vim :)

  • gocode doesn't complete external packages

    gocode doesn't complete external packages

    Probably It is my bad, however I could not make gocode complete the external packages. It works perfectly for the std packages. I tried setting lib-path to /root/Code/_gocode/pkg/linux_amd64/ but It did not help.

    [email protected]:/# cat /proc/version
    Linux version 3.11.0-12-generic ([email protected]) (gcc version 4.8.1 (Ubuntu/Linaro 4.8.1-10ubuntu7) ) #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013
    [email protected]:/# go version
    go version go1.2.1 linux/amd64
    
  • gocode only works when run manually

    gocode only works when run manually

    Hi, I hope this isn't a duplicate; I read through a bunch of the existing issues, tried searching, and generally did my due diligence before reporting. Apologies if I missed something. I'm not getting any completions from the default gocode server. When I close the server and run gocode -s, completions work fine. Without running gocode -s, the log output looks like this:

    2016/09/26 11:03:52 Go project path: .
    2016/09/26 11:03:52 Got autocompletion request for '/private/tmp/main.go'
    2016/09/26 11:03:52 Cursor at: 52
    2016/09/26 11:03:52 -------------------------------------------------------
    package main
    
    import (
            "fmt"
    )
    
    func main() {
            fmt.#Println
    }
    2016/09/26 11:03:52 -------------------------------------------------------
    2016/09/26 11:03:52 Found "fmt" at "/Users/cweber/.gvm/gos/go1.7.1/pkg/darwin_amd64/fmt.a"
    2016/09/26 11:03:52 Error parsing input file (inner block):
    2016/09/26 11:03:52  4:6: expected selector or type assertion, found ';'
    2016/09/26 11:03:52  4:7: expected ';', found 'IDENT' Println
    2016/09/26 11:03:52  5:2: expected ';', found 'EOF'
    2016/09/26 11:03:52  5:2: expected '}', found 'EOF'
    

    With gocode -s, I see:

    2016/09/26 11:09:26 Go project path: .
    2016/09/26 11:09:26 Got autocompletion request for '/private/tmp/main.go'
    2016/09/26 11:09:26 Cursor at: 52
    2016/09/26 11:09:26 -------------------------------------------------------
    package main
    
    import (
            "fmt"
    )
    
    func main() {
            fmt.#
    }
    2016/09/26 11:09:26 -------------------------------------------------------
    2016/09/26 11:09:26 Found "fmt" at "/Users/cweber/.gvm/gos/go1.7.1/pkg/darwin_amd64/fmt.a"
    2016/09/26 11:09:26 Error parsing input file (inner block):
    2016/09/26 11:09:26  4:6: expected selector or type assertion, found ';'
    2016/09/26 11:09:26 extracted expression tokens: fmt
    2016/09/26 11:09:26 Offset: 0
    2016/09/26 11:09:26 Number of candidates found: 25
    2016/09/26 11:09:26 Candidates are:
    2016/09/26 11:09:26   func Errorf(format string, a ...interface{}) error
    2016/09/26 11:09:26   func Fprint(w !io!io.Writer, a ...interface{}) (n int, err error)
    2016/09/26 11:09:26   func Fprintf(w !io!io.Writer, format string, a ...interface{}) (n int, err error)
    2016/09/26 11:09:26   func Fprintln(w !io!io.Writer, a ...interface{}) (n int, err error)
    2016/09/26 11:09:26   func Fscan(r !io!io.Reader, a ...interface{}) (n int, err error)
    2016/09/26 11:09:26   func Fscanf(r !io!io.Reader, format string, a ...interface{}) (n int, err error)
    2016/09/26 11:09:26   func Fscanln(r !io!io.Reader, a ...interface{}) (n int, err error)
    2016/09/26 11:09:26   func Print(a ...interface{}) (n int, err error)
    2016/09/26 11:09:26   func Printf(format string, a ...interface{}) (n int, err error)
    2016/09/26 11:09:26   func Println(a ...interface{}) (n int, err error)
    2016/09/26 11:09:26   func Scan(a ...interface{}) (n int, err error)
    2016/09/26 11:09:26   func Scanf(format string, a ...interface{}) (n int, err error)
    2016/09/26 11:09:26   func Scanln(a ...interface{}) (n int, err error)
    2016/09/26 11:09:26   func Sprint(a ...interface{}) string
    2016/09/26 11:09:26   func Sprintf(format string, a ...interface{}) string
    2016/09/26 11:09:26   func Sprintln(a ...interface{}) string
    2016/09/26 11:09:26   func Sscan(str string, a ...interface{}) (n int, err error)
    2016/09/26 11:09:26   func Sscanf(str string, format string, a ...interface{}) (n int, err error)
    2016/09/26 11:09:26   func Sscanln(str string, a ...interface{}) (n int, err error)
    2016/09/26 11:09:26   type Formatter interface
    2016/09/26 11:09:26   type GoStringer interface
    2016/09/26 11:09:26   type ScanState interface
    2016/09/26 11:09:26   type Scanner interface
    2016/09/26 11:09:26   type State interface
    2016/09/26 11:09:26   type Stringer interface
    2016/09/26 11:09:26 =======================================================
    

    Here's the output from nvim --version:

    NVIM 0.1.3
    Build type: RelWithDebInfo
    Compilation: /usr/local/Library/ENV/4.3/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DDISABLE_LOG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -DHAVE_CONFIG_H -I/tmp/neovim-20160707-73611-1gf4v6g/neovim-0.1.3/build/config -I/tmp/neovim-20160707-73611-1gf4v6g/neovim-0.1.3/src -I/tmp/neovim-20160707-73611-1gf4v6g/neovim-0.1.3/deps-build/usr/include -I/tmp/neovim-20160707-73611-1gf4v6g/neovim-0.1.3/deps-build/usr/include -I/tmp/neovim-20160707-73611-1gf4v6g/neovim-0.1.3/deps-build/usr/include/luajit-2.0 -I/tmp/neovim-20160707-73611-1gf4v6g/neovim-0.1.3/deps-build/usr/include -I/tmp/neovim-20160707-73611-1gf4v6g/neovim-0.1.3/deps-build/usr/include -I/tmp/neovim-20160707-73611-1gf4v6g/neovim-0.1.3/deps-build/usr/include -I/tmp/neovim-20160707-73611-1gf4v6g/neovim-0.1.3/deps-build/usr/include -I/usr/local/opt/gettext/include -I/usr/include -I/usr/include -I/tmp/neovim-20160707-73611-1gf4v6g/neovim-0.1.3/build/src/nvim/auto -I/tmp/neovim-20160707-73611-1gf4v6g/neovim-0.1.3/build/include
    Compiled by [email protected]
    
    Optional features included (+) or not (-): +acl   +iconv    +jemalloc
    For differences from Vim, see :help vim-differences
    
       system vimrc file: "$VIM/sysinit.vim"
      fall-back for $VIM: "/usr/local/Cellar/neovim/0.1.3/share/nvim"
    

    My default shell is zsh (if that might affect anything)?

    OSX version 10.11.6

  • got client protocol error

    got client protocol error "use of closed network connection"

    I updated gocode using go get method (go version weekly.2012-02-14 +43cf9b39b647) and found that autocomplete does not work neither in MacVim nor in "sublime text 2". As result of small research I found that gocode sometimes fail with error

    
    

    I start gocode -s and run gocode test.0001 10 times test command and result log in gist https://gist.github.com/1860772

    mac osx: 10.7.3 (lion,64) macvim: 7.3 (64) sublime text 2: build 2165

  • [WIP] import declaration autocomplete

    [WIP] import declaration autocomplete

    This closes issue #257. Work in progress right now.

    Detection of being inside an import statement is done. Here is a testing file.

    package main
    
    import "fmt"
    
    import f "fmt"
    
    import . "fmt"
    
    import (
        "fmt"
    )
    
    import (
        "fmt"
        "log"
    )
    
    import (
        f "fmt"
        l "log"
    )
    
    import (
        . "fmt"
        l "log"
    )
    
    import (
        "fmt"; "log"
    )
    
    import (
        . "fmt"; l "log"
    )
    
    import _ "fmt"
    
    import (
      "io/
    )
    

    I just need to take cc.partial and return all import paths that match.

  • struct problems by new binary format

    struct problems by new binary format

    I found two bugs.

    First, It's simple. maybe it's not related new binary format.

    package main
    
    type TestStruct struct {
        Name string
    }
    
    func NewTestStruct(name string) *TestStruct {
        return &TestStruct{
            Name: name,
        }
    }
    
    // This line
    func (t *
    
    func (t *TestStruct) Test(name string) error {
        t.Name = name
    
        return nil
    }
    

    If type any character after pointer (e.g. func (t *T), gocode occur PANIC. But if that situation, works fine.

    1. func (t T
      • no poitner
    2. Remove func (t *TestStruct) Test(name string) error function block
      • e.g. comment out
    3. Move func (t * to end of file
    4. 152 byte offset

    3 is this situation.

    .
    .
    func (t *TestStruct) Test(name string) error {
        t.Name = name
    
        return nil
    }
    
    func (t *T
    
    

    gist: https://gist.github.com/zchee/0789790800f77ad9fa2d06783bc31de2#file-struct-go byte offset: 151 (include any charactor e.g. T) cmd: gocode --in ./struct.go autocomplete 151

    Next is an edge case(?). It's related new binary format. I tried https://github.com/nsf/gocode/issues/305#issuecomment-219234073 workaround. works fine.

    Sorry, I tried several code, but I could not find another case. If I found other case, will comment.

    This sample is simple code for remote connection to delve headless server.

    package main
    
    import "github.com/derekparker/delve/service/rpc2"
    
    const addr = "localhost:41222" // d:4 l:12 v:22
    
    func pointerStruct() {
        client := rpc2.NewClient(addr)
        bp, _ := client.GetBreakpoint(-1)
    
        bp.
    }
    

    gist: https://gist.github.com/zchee/0789790800f77ad9fa2d06783bc31de2#file-delve-go byte offset: 210 cmd: gocode --in ./delve.go autocomplete 210

    Does not return any complete word after bp.. Expected behavior is return that struct values. https://github.com/derekparker/delve/blob/master/service/api/types.go#L35-L69 but actual behavior is Nothing to complete..

    Please comment if you need other information. Thanks.

  • Gocode showing panic as the only completion

    Gocode showing panic as the only completion

    I am using gocode with the spacemacs-go contribution layer. Compiler verson is Go 1.4. Gocode is showing panic as the only completion.

    Here's the log:

    package main
    
    import (
        "database/sql"
        "github.com/codegangsta/negroni"
        "github.com/julienschmidt/httprouter"
        _ "github.com/mattn/go-sqlite3"
        "github.com/unrolled/render"
        "golang.org/x/crypto/bcrypt"
        "log"
        "net/http"
    )
    
    type Book struct {
        // ISBN     string
        Title    string
        Author   string
        Price    float32
        Location string
    }
    
    type Env struct {
        db *sql.DB
        db#
    }
    
    func SetupDB() *sql.DB {
        db, err := sql.Open("sqlite3", "database.sqlite") //TODO: implement SSL
        PanicIf(err, "SetupDB")
        return db
    }
    
    func main() {
        log.Println("Hello World")
        db := SetupDB
        n := negroni.Classic()
        router := httprouter.New()
        ren := render.New(render.Options{
            Extensions: []string{".html"},
        })
        router.POST("/login", db.LoginHandler)
        n.UseHandler(router)
        n.Run(":3001")
    
    }
    
    func (db *sql.DB) LoginHandler(resp http.ResponseWriter, req *http.Request, p httprouter.Params) {
        email := req.FormValue("email")
        password := req.FormValue("password")
        log.Println(email, password)
    
    }
    
    func PanicIf(err error, errorMsg string) {
        if err != nil {
            log.Println("Error at "+errorMsg+":", err)
            panic(err)
        }
    }
    
    func LogError(err error, errorMsg string) {
        if err != nil {
            log.Println("Error at "+errorMsg+":", err)
        }
    }
    2015/08/26 18:38:01 -------------------------------------------------------
    2015/08/26 18:38:01 Found "database/sql" at "/usr/local/go/pkg/linux_386/database/sql.a"
    2015/08/26 18:38:01 Found "github.com/codegangsta/negroni" at "/home/immortalin/Development/Go/pkg/linux_386/github.com/codegangsta/negroni.a"
    2015/08/26 18:38:01 Found "github.com/julienschmidt/httprouter" at "/home/immortalin/Development/Go/pkg/linux_386/github.com/julienschmidt/httprouter.a"
    2015/08/26 18:38:01 Found "github.com/mattn/go-sqlite3" at "/home/immortalin/Development/Go/pkg/linux_386/github.com/mattn/go-sqlite3.a"
    2015/08/26 18:38:01 Found "github.com/unrolled/render" at "/home/immortalin/Development/Go/pkg/linux_386/github.com/unrolled/render.a"
    2015/08/26 18:38:01 Found "golang.org/x/crypto/bcrypt" at "/home/immortalin/Development/Go/pkg/linux_386/golang.org/x/crypto/bcrypt.a"
    2015/08/26 18:38:01 Found "log" at "/usr/local/go/pkg/linux_386/log.a"
    2015/08/26 18:38:01 Found "net/http" at "/usr/local/go/pkg/linux_386/net/http.a"
    panic: interface conversion: ast.Expr is *ast.SelectorExpr, not *ast.Ident
    1(runtime.call16): /usr/local/go/src/runtime/asm_386.s:412
    2(runtime.gopanic): /usr/local/go/src/runtime/panic.go:387
    3(runtime.assertI2T): /usr/local/go/src/runtime/iface.go:181
    4(main.method_of): /home/immortalin/Development/Go/src/github.com/nsf/gocode/decl.go:327
    5(main.funcĀ·009): /home/immortalin/Development/Go/src/github.com/nsf/gocode/declcache.go:128
    6(main.foreach_decl): /home/immortalin/Development/Go/src/github.com/nsf/gocode/decl.go:1309
    7(main.append_to_top_decls): /home/immortalin/Development/Go/src/github.com/nsf/gocode/declcache.go:147
    8(main.(*auto_complete_file).process_data): /home/immortalin/Development/Go/src/github.com/nsf/gocode/autocompletefile.go:75
    9(main.(*auto_complete_context).apropos): /home/immortalin/Development/Go/src/github.com/nsf/gocode/autocompletecontext.go:247
    10(main.server_auto_complete): /home/immortalin/Development/Go/src/github.com/nsf/gocode/server.go:155
    11(main.(*RPC).RPC_auto_complete): /home/immortalin/Development/Go/src/github.com/nsf/gocode/rpc.go:26
    12(runtime.call32): /usr/local/go/src/runtime/asm_386.s:413
    13(reflect.Value.call): /usr/local/go/src/reflect/value.go:419
    14(reflect.Value.Call): /usr/local/go/src/reflect/value.go:296
    15(net/rpc.(*service).call): /usr/local/go/src/net/rpc/server.go:382
    16(runtime.goexit): /usr/local/go/src/runtime/asm_386.s:2287
    
  • vim configue syntax error

    vim configue syntax error

    hi, when c+x, c+o , error happens, and exit without complete. error information as follows:

    Error detected while processing function gocomplete#Complete: line 3: E15: Invalid expression: Press ENTER or type command to continue Error detected while processing function gocomplete#Complete: line 3: E15: Invalid expression: Press ENTER or type command to continue Error detected while processing function gocomplete#Complete: line 4: E121: Undefined variable: g:gocomplete_completions Press ENTER or type command to continue Error detected while processing function gocomplete#Complete: line 4: E15: Invalid expression: col('.') - g:gocomplete_completions[0] - 1 Error detected while processing function gocomplete#Complete: line 7: E121: Undefined variable: g:gocomplete_completions Press ENTER or type command to continue Error detected while processing function gocomplete#Complete: line 7: E15: Invalid expression: g:gocomplete_completions[1]

  • Alis of package name in Eclipse

    Alis of package name in Eclipse

    import newName "package"
    
    func main() {
        package.xxx // <-- work fine.
        newName.    // <-- not work
    }
    

    The alis name of package won't autocomplete at all.

    Version Eclipse: Build id: 20130225-0426 (Juno) Golipse: 0.7.6v439 Gocode: Newest Version ( Today ) Go: go1.1

  • GOCODE DOES NOT WORK WITH OR WITHOUT GOMODULES ENABLED

    GOCODE DOES NOT WORK WITH OR WITHOUT GOMODULES ENABLED

    This error shows up constantly all the time, tried to solved it for 10 hours but does not work:

    Error parsing input file (outer block):
    2020/08/20 07:26:52  /mnt/data/data/go/src/private/pgtableinvoice/pgtableinvoice.go:323:9: expected selector or type assertion, found ';'
    2020/08/20 07:26:52 gbimporter: no package found for ./commonmessage: can't find import: "/mnt/data/data/go/src/private/pgtableinvoice/commonmessage"
    2020/08/20 07:26:52 gbimporter: no package found for ./logger: can't find import: "/mnt/data/data/go/src/private/pgtableinvoice/logger"
    2020/08/20 07:26:52 gbimporter: no package found for ./postgresdb: can't find import: "/mnt/data/data/go/src/private/pgtableinvoice/postgresdb"
    

    go version go1.14.5 linux/amd64

    Want to re-produce it yourself? Just install Spacemaces from develop or master branch, your gocode won't give 1 correct suggestion for imported packages whether or not they are using gomodules.

  • runtime: goroutine stack exceeds 1000000000-byte limit

    runtime: goroutine stack exceeds 1000000000-byte limit

    $ gocode -s -debug 2019/11/21 12:24:15 Go project path: . runtime: goroutine stack exceeds 1000000000-byte limit fatal error: stack overflow

    runtime stack: runtime.throw(0xa3c87d, 0xe) /usr/lib/go/src/runtime/panic.go:774 +0x72 runtime.newstack() /usr/lib/go/src/runtime/stack.go:1046 +0x6e9 runtime.morestack() /usr/lib/go/src/runtime/asm_amd64.s:449 +0x8f

    goroutine 34 [running]: runtime.newMarkBits(0x55, 0x0) /usr/lib/go/src/runtime/mheap.go:1933 +0x349 fp=0xc021110320 sp=0xc021110318 pc=0x429ab9 runtime.heapBits.initSpan(0x7f42e126e300, 0x20300000000000, 0x7f42e13cbfff, 0x7f42e01a43d8) /usr/lib/go/src/runtime/mbitmap.go:792 +0x74 fp=0xc0211103a0 sp=0xc021110320 pc=0x4171b4 runtime.(*mcentral).grow(0xf29af8, 0x0) /usr/lib/go/src/runtime/mcentral.go:264 +0x13e fp=0xc0211103e0 sp=0xc0211103a0 pc=0x41986e runtime.(*mcentral).cacheSpan(0xf29af8, 0xc000034000) /usr/lib/go/src/runtime/mcentral.go:106 +0x2fe fp=0xc021110440 sp=0xc0211103e0 pc=0x4192ce runtime.(*mcache).refill(0x7f42e33dd008, 0xf) /usr/lib/go/src/runtime/mcache.go:138 +0x85 fp=0xc021110460 sp=0xc021110440 pc=0x418d75 runtime.(*mcache).nextFree(0x7f42e33dd008, 0x7f42e33dd00f, 0x0, 0x16, 0xa87108) /usr/lib/go/src/runtime/malloc.go:854 +0x87 fp=0xc021110498 sp=0xc021110460 pc=0x40d847 runtime.mallocgc(0x60, 0x959020, 0x44a801, 0xc00143629f) /usr/lib/go/src/runtime/malloc.go:1022 +0x793 fp=0xc021110538 sp=0xc021110498 pc=0x40e183 runtime.makeslice(0x959020, 0x0, 0x58, 0x41) /usr/lib/go/src/runtime/slice.go:49 +0x6c fp=0xc021110568 sp=0xc021110538 pc=0x446d0c strings.(*Builder).grow(...) /usr/lib/go/src/strings/builder.go:67 strings.(*Builder).Grow(...) /usr/lib/go/src/strings/builder.go:81 strings.Join(0xc021110750, 0x2, 0x2, 0xa2dc36, 0x1, 0x41, 0xc000c21de0) /usr/lib/go/src/strings/strings.go:438 +0x4ca fp=0xc021110640 sp=0xc021110568 pc=0x4f455a path/filepath.join(0xc021110750, 0x2, 0x2, 0xa2dc00, 0x1) /usr/lib/go/src/path/filepath/path_unix.go:45 +0xa7 fp=0xc021110688 sp=0xc021110640 pc=0x4fb007 path/filepath.Join(...) /usr/lib/go/src/path/filepath/path.go:210 github.com/visualfc/gocode/vendor/github.com/visualfc/fastmod.(*Package).load(0xc000fc6c60, 0xc00ba7be90) /home/user/.go/src/github.com/visualfc/gocode/vendor/github.com/visualfc/fastmod/fastmod.go:232 +0x475 fp=0xc0211107b0 sp=0xc021110688 pc=0x6a42f5 github.com/visualfc/gocode/vendor/github.com/visualfc/fastmod.(*Package).load(0xc000fc6c60, 0xc00ba7bce0) /home/user/.go/src/github.com/visualfc/gocode/vendor/github.com/visualfc/fastmod/fastmod.go:239 +0x2ab fp=0xc0211108d8 sp=0xc0211107b0 pc=0x6a412b github.com/visualfc/gocode/vendor/github.com/visualfc/fastmod.(*Package).load(0xc000fc6c60, 0xc00ba7bb90) ... ... ... ... ... /home/user/.go/src/github.com/visualfc/gocode/vendor/github.com/visualfc/fastmod/fastmod.go:239 +0x2ab fp=0xc021110a00 sp=0xc0211108d8 pc=0x6a412b github.com/visualfc/gocode/vendor/github.com/visualfc/fastmod.(*Package).load(0xc000fc6c60, 0xc00baf7bc0) /home/user/.go/src/github.com/visualfc/gocode/vendor/github.com/visualfc/fastmod/fastmod.go:239 +0x2ab fp=0xc021116e98 sp=0xc021116d70 pc=0x6a412b created by net/rpc.(*Server).ServeCodec /usr/lib/go/src/net/rpc/server.go:474 +0x42b

    goroutine 1 [IO wait, 1 minutes]: internal/poll.runtime_pollWait(0x7f42e014ee08, 0x72, 0xffffffffffffffff) /usr/lib/go/src/runtime/netpoll.go:184 +0x55 internal/poll.(*pollDesc).wait(0xc0001d0198, 0x72, 0x1000, 0x1000, 0xffffffffffffffff) /usr/lib/go/src/internal/poll/fd_poll_runtime.go:87 +0x45 internal/poll.(*pollDesc).waitRead(...) /usr/lib/go/src/internal/poll/fd_poll_runtime.go:92 internal/poll.(*FD).Read(0xc0001d0180, 0xc000241000, 0x1000, 0x1000, 0x0, 0x0, 0x0) /usr/lib/go/src/internal/poll/fd_unix.go:169 +0x1cf net.(*netFD).Read(0xc0001d0180, 0xc000241000, 0x1000, 0x1000, 0x10ea, 0x10ea, 0x10) /usr/lib/go/src/net/fd_unix.go:202 +0x4f net.(*conn).Read(0xc0001bc020, 0xc000241000, 0x1000, 0x1000, 0x0, 0x0, 0x0) /usr/lib/go/src/net/net.go:184 +0x68 bufio.(*Reader).Read(0xc0001b4180, 0xc0001be050, 0x1, 0x9, 0x6bed9d, 0xc0001d0280, 0xc0001b83a0) /usr/lib/go/src/bufio/bufio.go:226 +0x26a io.ReadAtLeast(0xb29aa0, 0xc0001b4180, 0xc0001be050, 0x1, 0x9, 0x1, 0x6c60d0, 0xc0001d0280, 0x10) /usr/lib/go/src/io/io.go:310 +0x87 io.ReadFull(...) /usr/lib/go/src/io/io.go:329 encoding/gob.decodeUintReader(0xb29aa0, 0xc0001b4180, 0xc0001be050, 0x9, 0x9, 0x203000, 0x0, 0xc0002559c0, 0x203000) /usr/lib/go/src/encoding/gob/decode.go:120 +0x6f encoding/gob.(*Decoder).recvMessage(0xc0001d0280, 0xc0002460d0) /usr/lib/go/src/encoding/gob/decoder.go:81 +0x57 encoding/gob.(*Decoder).decodeTypeSequence(0xc0001d0280, 0xc000255900, 0x40dd06) /usr/lib/go/src/encoding/gob/decoder.go:143 +0x10c encoding/gob.(*Decoder).DecodeValue(0xc0001d0280, 0x946300, 0xc0001b87c0, 0x16, 0x0, 0x0) /usr/lib/go/src/encoding/gob/decoder.go:211 +0x10b encoding/gob.(*Decoder).Decode(0xc0001d0280, 0x946300, 0xc0001b87c0, 0x40100, 0xc0000b33d8) /usr/lib/go/src/encoding/gob/decoder.go:188 +0x16d net/rpc.(*gobServerCodec).ReadRequestHeader(0xc0001b63c0, 0xc0001b87c0, 0x941100, 0xc0001b87a0) /usr/lib/go/src/net/rpc/server.go:397 +0x45 net/rpc.(*Server).readRequestHeader(0xc0000b33b0, 0xb36fc0, 0xc0001b63c0, 0xc0001b87a0, 0x16, 0xc0002460d0, 0x7f42e014a901, 0x0, 0x0) /usr/lib/go/src/net/rpc/server.go:583 +0x67 net/rpc.(*Server).readRequest(0xc0000b33b0, 0xb36fc0, 0xc0001b63c0, 0xc0000b33b0, 0xc0001be048, 0xc0001be060, 0xc0001c8380, 0xc0001b8120, 0x940f40, 0xc0002460d0, ...) /usr/lib/go/src/net/rpc/server.go:543 +0x5a net/rpc.(*Server).ServeCodec(0xc0000b33b0, 0xb36fc0, 0xc0001b63c0) /usr/lib/go/src/net/rpc/server.go:458 +0x97 net/rpc.(*Server).ServeConn(0xc0000b33b0, 0x7f42e010a008, 0xc0001bc020) /usr/lib/go/src/net/rpc/server.go:449 +0x158 net/rpc.ServeConn(...) /usr/lib/go/src/net/rpc/server.go:667 main.(*daemon).loop(0xc0001f8280) /home/username/.go/src/github.com/visualfc/gocode/server.go:111 +0x1ee main.do_server(0x0) /home/username/.go/src/github.com/visualfc/gocode/server.go:49 +0x12f main.main() /home/username/.go/src/github.com/visualfc/gocode/gocode.go:70 +0xbd

    goroutine 20 [chan receive, 1 minutes]: main.new_file_reader.func1(0xc0001c2048) /home/username/.go/src/github.com/visualfc/gocode/utils.go:246 +0x71 created by main.new_file_reader /home/username/.go/src/github.com/visualfc/gocode/utils.go:243 +0x87

    goroutine 22 [chan send, 1 minutes]: main.(*daemon).loop.func1(0xc0001f8280, 0xc000210060) /home/username/.go/src/github.com/visualfc/gocode/server.go:100 +0x45 created by main.(*daemon).loop /home/username/.go/src/github.com/visualfc/gocode/server.go:94 +0x7c

  • In order for company-go to work with foreign packages, it requires a `-source` flag

    In order for company-go to work with foreign packages, it requires a `-source` flag

    Per mdempsky/gocode#32, a -source flag needs to be passed to this forked version of gocode in order for it to find references in foreign packages.

    Since company-go in MELPA comes from this repo, it puts us in a strange position since nsf/gocode doesn't supports this flag. With Go's own Language Server Protocol server in development, the need for the gocode tool may "soon" be obviated. Have you considered splitting out the emacs packages into their own repos?

  • GOCODE PANIC: Please check your code by

    GOCODE PANIC: Please check your code by "go build"

    I installed go1.11 and then go get nsf/gocode when I got a new linux environment. After I config go autocomplete in emacs, gocode encounter a panic. My colleague also encounter the same problem in vscode. The message is GOCODE PANIC: Please check your code by "go build"

    go 1.10 and 1.9 work well with gocode.

Related tags
Emacs mode for the Go programming language

This is go-mode, the Emacs mode for editing Go code. It is a complete rewrite of the go-mode that shipped with Go 1.0.3 and before, and was part of Go

Dec 24, 2022
Delve is a debugger for the Go programming language.
Delve is a debugger for the Go programming language.

The GitHub issue tracker is for bugs only. Please use the developer mailing list for any feature proposals and discussions. About Delve Installation L

Dec 29, 2022
Web-based IDE for the Go language
Web-based IDE for the Go language

Welcome to godev! The aim of this project is to develop a premier Go language IDE hosted in a web interface. This was inspired by the way that the god

Nov 30, 2022
A Go language server.

A Go Language Server based on the Go Extension for Visual Studio Code Wraps the VSCode Go extension from Microsoft into a language server, such that i

Dec 6, 2022
kubectl-fzf provides a fast and powerful fzf autocompletion for kubectl
kubectl-fzf provides a fast and powerful fzf autocompletion for kubectl

Kubectl-fzf kubectl-fzf provides a fast and powerful fzf autocompletion for kubectl. Table of Contents Kubectl-fzf Table of Contents Features Requirem

Nov 3, 2021
Floppa programming language inspired by the brainf*ck programming language. Created just for fun and you can convert your brainf*ck code to floppa code.

Floppa Programming Language Created just for fun. But if you want to contribute, why not? Floppa p.l. inspired by the brainf*ck programming language.

Oct 20, 2022
T# Programming Language. Something like Porth, Forth but written in Go. Stack-oriented programming language.

The T# Programming Language WARNING! THIS LANGUAGE IS A WORK IN PROGRESS! ANYTHING CAN CHANGE AT ANY MOMENT WITHOUT ANY NOTICE! Something like Forth a

Jun 29, 2022
Yayx programming language is begginer friendly programming language.
Yayx programming language is begginer friendly programming language.

Yayx Yayx programming language is begginer friendly programming language. What have yayx: Easy syntax Dynamic types Can be compiled to outhers program

Dec 27, 2021
Yayx programming language is begginer friendly programming language.

Yayx Yayx programming language is begginer friendly programming language. What have yayx: Easy syntax Dynamic types Can be compiled to outhers program

May 20, 2022
Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

Advent of Code 2021 Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved

Dec 2, 2021
Jan 4, 2022
A repository for showcasing my knowledge of the Google Go (2009) programming language, and continuing to learn the language.

Learning Google Golang (programming language) Not to be confused with the Go! programming language by Francis McCabe I don't know very much about the

Nov 6, 2022
A repository for showcasing my knowledge of the Go! (2003) programming language, and continuing to learn the language.
A repository for showcasing my knowledge of the Go! (2003) programming language, and continuing to learn the language.

Learning Go! (programming language) Not to be confused with Google Golang (2009) I don't know too much about the Go! programming language, but I know

Oct 22, 2022
Daemon based on liblxc offering a REST API to manage containers
Daemon based on liblxc offering a REST API to manage containers

LXD LXD is a next generation system container and virtual machine manager. It offers a unified user experience around full Linux systems running insid

Jan 9, 2023
dyndns client daemon

README for dyndnscd =================== dyndnscd is the dyndns client daemon. It is a daemon that continually polls for IP address changes an in the

Sep 29, 2021
Resolver (DNS) cache daemon.
Resolver (DNS) cache daemon.

RESCACHED(1) Manual Page NAME rescached - DNS resolver cache daemon. Table of Contents SYNOPSIS OPTIONS DESCRIPTION FEATURES BEHIND THE DNS HOW CACHE

Nov 17, 2022
A simple daemon which will watch files on your filesystem, mirror them to MFS, automatically update related pins, and update related IPNS keys.
A simple daemon which will watch files on your filesystem, mirror them to MFS, automatically update related pins, and update related IPNS keys.

ipfs-sync is a simple daemon which will watch files on your filesystem, mirror them to MFS, automatically update related pins, and update related IPNS keys, so you can always access your directories from the same address. You can use it to sync your documents, photos, videos, or even a website!

Dec 30, 2022
Kubernetes Reboot Daemon
Kubernetes Reboot Daemon

kured - Kubernetes Reboot Daemon Introduction Kubernetes & OS Compatibility Installation Configuration Reboot Sentinel File & Period Setting a schedul

Jan 3, 2023
cod is a completion daemon for bash/fish/zsh

Cod is a completion daemon for {bash,fish,zsh}. It detects usage of --help commands parses their output and generates auto-completions for your shell.

Dec 25, 2022
A modern IRC server (daemon/ircd) written in Go.
A modern IRC server (daemon/ircd) written in Go.

Oragono is a modern IRC server written in Go. Its core design principles are: Being simple to set up and use Combining the features of an ircd, a serv

Dec 31, 2022