Skip to content
This repository has been archived by the owner on Oct 27, 2021. It is now read-only.

Go1.11 Hangs when -source flag is provided #67

Closed
GeorgeMac opened this issue Oct 1, 2018 · 11 comments
Closed

Go1.11 Hangs when -source flag is provided #67

GeorgeMac opened this issue Oct 1, 2018 · 11 comments
Labels

Comments

@GeorgeMac
Copy link

See: fatih/vim-go#2001

I have the same issues here as @pavannaganna and I have an almost identical setup (r.e. Go version and OS).

For me it actually hangs and gives 0 suggestions. The only fix being to turn off the source flag via the g:go_gocode_propose_source = 0.

I only raise this issue as prior to moving to go1.11 I never even knew this option existed and now I depend on it. Otherwise, the hang up talking to gocode constantly messes up my vim buffer.

@stamblerre
Copy link
Collaborator

Do you have your $GOROOT set? I've noticed it works fine when I set a GOROOT, but I am able to reproduce this when I don't.

@stamblerre
Copy link
Collaborator

stamblerre commented Oct 11, 2018

Another question: Are you using a developer version of Go? I found that if I synced to before this change (golang/go@9f78aa7), then I had no problems, even if my GOROOT isn't set. Temporarily syncing to Go 1.11 or before that change may fix the problem.

Edit: The fix is to build gocode with the same version of Go that is in your $GOROOT. go/build recently had a new operating system added, so go/build can't compile a newer version of the source.

@GeorgeMac
Copy link
Author

GeorgeMac commented Oct 12, 2018

Hey @stamblerre ! Thanks for the tips. I have actually recompiled every thing with go1.11 and I still get this issue. But I haven't tried the $GOROOT thing, I will give the a go :D

I originally had the classic PANIC PANIC PANIC error when upgrading to go1.11 because of this very problem r.e. needing recompile with go1.11. So I nuked my build cache and bin / pkg folders and compiled everything fresh.

Will report back with my GOROOT findings ! I do compile Go from source, so I could very well be making things hard for myself 😂

EDIT: My $GOROOT is set appropriately :(
Another update, I went to where I have Go checked out and that commit (golang/go@9f78aa7) doesn't exist for me.

@stamblerre
Copy link
Collaborator

Hm, so I would recommend syncing to head on the Go source in your $GOROOT and then re-building gocode using that version of go. Make sure you run gocode close before trying it again. It should work at that point.

@GeorgeMac
Copy link
Author

So I just:

  1. checked out go1.11.1 and built from source
  2. go version: go version go1.11.1 darwin/amd64
  3. go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/admin/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/admin/go"
GOPROXY=""
GORACE=""
GOROOT="/Users/admin/dist/go"
GOTMPDIR=""
GOTOOLDIR="/Users/admin/dist/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
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/9k/c2skyh6565q8005str8r1b9w0000gn/T/go-build994193747=/tmp/go-build -gno-record-gcc-switches -fno-common"
  1. remove the g:go_gocode_propose_source = 0 option I had configured
  2. Deleted $GOPATH/pkg/darwin/github.com/mdempsky/gocode and $GOPATH/bin/gocode
  3. Ran go clean --cache
  4. Ran go get -u github.com/mdempsky/gocode
  5. Ran gocode close and gocode exit (for good measure 😂 )

And then I get this:
https://asciinema.org/a/05QggV9z2qcrLvcDknQFMcCq9

🤔 It doesn't stall anymore at least. Just still don't get any suggestions.

@stamblerre
Copy link
Collaborator

stamblerre commented Oct 12, 2018

The g:go_gocode_propose_source = 1 option should still work, but this seems really weird since you are just completing a locally defined struct.

Do you mind running gocode -s -debug and sending me the output of that? Just run gocode close then gocode -s -debug and then try to complete something.

@GeorgeMac
Copy link
Author

GeorgeMac commented Oct 15, 2018

@stamblerre good shout! I actually get suggestions shown in the debug output:

2018/10/15 09:03:44 Got autocompletion request for '/Users/admin/go/src/github.com/georgemac/legs/legs.go'
2018/10/15 09:03:44 Cursor at: 1158
2018/10/15 09:03:44 -------------------------------------------------------
package legs

import "testing"

// Runner can run a test given a pointer to a testing.T
type Runner interface {
	Run(t *testing.T)
}

// RunnerFunc is a helper type which implements
// Runner and delegates to the decorated function
type RunnerFunc func(t *testing.T)

// Run delegates down to the called on function `r`
func (r RunnerFunc) Run(t *testing.T) { r(t) }

// Case interface describes the set of things
// that can return a name string and are a Runner
type Case interface {
	Name() string
	Runner
}

// CommonCase implements Case
// Name returns the field CaseName
// Run delegates down to the embedded Runner
type CommonCase struct {
	name string
	Runner
}

// NewCase returns a pointer to a CommonCase, which
// implements the Case interface.
func NewCase(name string, runner Runner) *CommonCase {
	return &CommonCase{
		name:   name,
		Runner: runner,
	}
}

// Name returns the CaseName field string
func (c *CommonCase) Name() string { return c.name }

// Table is a slice of Case
type Table []Case

// Run takes a pointer to a testing.T and calls run on
// all the Case types in the Table slice.
func (table Table) Run(t *testing.T) {
    t.#
	for _, testCase := range table {
		t.Run(testCase.Name(), testCase.Run)
	}
}
2018/10/15 09:03:44 -------------------------------------------------------
2018/10/15 09:03:44 Error parsing input file (outer block):
2018/10/15 09:03:44  /Users/admin/go/src/github.com/georgemac/legs/legs.go:50:7: expected selector or type assertion, found ';'
2018/10/15 09:03:44  /Users/admin/go/src/github.com/georgemac/legs/legs.go:51:2: expected ';', found 'for'
2018/10/15 09:03:45 Elapsed duration: 552.552348ms
2018/10/15 09:03:45 Offset: 0
2018/10/15 09:03:45 Number of candidates found: 17
2018/10/15 09:03:45 Candidates are:
2018/10/15 09:03:45   func Error(args ...interface{})
2018/10/15 09:03:45   func Errorf(format string, args ...interface{})
2018/10/15 09:03:45   func Fail()
2018/10/15 09:03:45   func FailNow()
2018/10/15 09:03:45   func Failed() bool
2018/10/15 09:03:45   func Fatal(args ...interface{})
2018/10/15 09:03:45   func Fatalf(format string, args ...interface{})
2018/10/15 09:03:45   func Helper()
2018/10/15 09:03:45   func Log(args ...interface{})
2018/10/15 09:03:45   func Logf(format string, args ...interface{})
2018/10/15 09:03:45   func Name() string
2018/10/15 09:03:45   func Parallel()
2018/10/15 09:03:45   func Run(name string, f func(t *testing.T)) bool
2018/10/15 09:03:45   func Skip(args ...interface{})
2018/10/15 09:03:45   func SkipNow()
2018/10/15 09:03:45   func Skipf(format string, args ...interface{})
2018/10/15 09:03:45   func Skipped() bool
2018/10/15 09:03:45 =======================================================

🤔 does this mean the problem is likely further upstream? Somewhere between gocode and vim?

@stamblerre
Copy link
Collaborator

Did you trigger the autocompletion through Vim? It seems strange that Vim wouldn't show these results. What other settings do you have for gocode in Vim?

@GeorgeMac
Copy link
Author

None that is the weirdest thing. The only setting that triggers the lack of a suggestion in vim is the g:go_gocode_propose_source = 1. So strange.

@stamblerre
Copy link
Collaborator

Hm, so sounds like this must be a https://github.com/fatih/vim-go bug. I'd recommend filing your case there and linking this discussion there. I'm going to close this for now.

@GeorgeMac
Copy link
Author

Thank you for your time 🙇

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants