Giter Club home page Giter Club logo

godef's People

Contributors

heimonsy avatar hyangah avatar ianthehat avatar ijc avatar lukehoban avatar manishearth avatar myitcv avatar rogpeppe avatar uudashr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

godef's Issues

godef-jump doesn't work if package name doesn't match path name

I am importing a repo via import "github.com/tleyden/uqclient/libuqclient"

However, the code in the libuqclient package is declaring it's package name as follows:

package uqclient

(rather than what you might expect given the path name: package libuqclient)

The following code compiles fine:

uniqushClient := uqclient.NewUniqushClient(f.UniqushURL)

however I cannot run godef-jump to jump into the implementation of NewUniqushClient -- it gives me a "godef no declaration found" error.

In this case I was able to workaround this by changing the libuqclient package to declare it's package as libuqclient rather than uqclient, which fixed the godef-jump problem. However there might be other libraries outside of my control that has discrepancies between it's package name and it's path name.

Is it possible to make godef-jump handle these cases?

godef not working with type alias

When I use type alias with golang 1.9, I got error:

godef -t -i -f source.go -o 121
godef: no identifier found

source file:

type RedisOption = redis.Options

Or error:

godef -t -i -f source.go -o 594
godef: no declaration found for pkg.RedisOption

no declaration found for `tf "github.com/tensorflow/tensorflow/tensorflow/go"`

command to reproduce:

echo 'package foo; import tf "github.com/tensorflow/tensorflow/tensorflow/go"; func fn() { tf.NewGraph() }' | godef -i -o 90
parseLocalPackage error: no more package files found
godef: no declaration found for tf.NewGraph

I suspect it's because package name is not same as folder name (e.g., package name is tensorflow and folder name is go)

Cannot deal with [UTF-8 with BOM] files

Some of [my go-source-code] files are generated by other cmd-tools which could use the UTF-8 with BOM.
So, godef would fail to deal with such [go-source-code] files.

Godef doesn't build now that 9fans has moved to github?

I was setting up godef today on a new laptop and upon running go get github.com/rogpeppe/godef I received an error:

[user@localhost]$ go get code.google.com/p/rog-go/exp/cmd/godef
package code.google.com/p/rog-go/exp/cmd/godef
        imports 9fans.net/go/acme: unrecognized import path "9fans.net/go/acme"

seeing what appeared to be the issue, I changed the imports to in acme.go to:

"github.com/9fans/go/acme"

And that started to help, but then all the 9fans packages are still importing things like 9fans.net/go/plan9 so the same problem kept arising. Eventually I changed all the 9fans.net/* imports to github.com/9fans/* and go get command completed successfully.

I may just be building this incorrectly or my setup could be broken, so let me know if that's the case! I'm running go 1.4.2 built from source on Fedora 21 64-bit. Let me know if there's any other info I can provide that will help.

net.LookupIP fails

Trying to find the definition of LookupIP in the following code fails:

package main
import "net"

var x = net.LookupIP

func main() {
}

Looking at the debug output, it's probably something to do with build tags:

2016/06/20 10:36:56 exprType tuple:false pkg: *ast.SelectorExpr net.LookupIP [
2016/06/20 10:36:56 exprType tuple:false pkg: *ast.Ident net [
2016/06/20 10:36:56 exprType tuple:false pkg: *ast.ImportSpec "net" [
2016/06/20 10:36:56 ] -> 0x0, Type{package "" *ast.ImportSpec "net"}
2016/06/20 10:36:56 ] -> 0xc42010d950, Type{package "" *ast.ImportSpec "net"}
2016/06/20 10:36:56 member Type{package "" *ast.ImportSpec "net"} 'LookupIP' {
2016/06/20 10:36:56     /home/rog/go/src/net/interface_bsdvar.go:12:2: cannot find identifier for package "golang.org/x/net/route": no buildable Go source files in /home/rog/go/src/vendor/golang.org/x/net/route
2016/06/20 10:36:56 } -> <nil>
2016/06/20 10:36:56 ] -> 0x0, Type{bad "" <nil> }
2016/06/20 10:36:56 exprType tuple:false pkg: *ast.SelectorExpr net.LookupIP [
2016/06/20 10:36:56 exprType tuple:false pkg: *ast.Ident net [
2016/06/20 10:36:56 exprType tuple:false pkg: *ast.ImportSpec "net" [
2016/06/20 10:36:56 ] -> 0x0, Type{package "" *ast.ImportSpec "net"}
2016/06/20 10:36:56 ] -> 0xc42010d950, Type{package "" *ast.ImportSpec "net"}
2016/06/20 10:36:56 member Type{package "" *ast.ImportSpec "net"} 'LookupIP' {
2016/06/20 10:36:56     /home/rog/go/src/net/interface_bsdvar.go:12:2: cannot find identifier for package "golang.org/x/net/route": no buildable Go source files in /home/rog/go/src/vendor/golang.org/x/net/route
2016/06/20 10:36:56 } -> <nil>
2016/06/20 10:36:56 ] -> 0x0, Type{bad "" <nil> }

fails to find declaration, sometimes

I use godef primarily by being a Microsoft VSCode go-extension user. I've noticed over the past few months that sometimes "go to declaration" does not work, and investigation has shown this to be an issue with godef (upon which the VSCode extension relies).

When I run godef in such a case, it just says "no declaration found". See below. First as a proof of proper configuration, here is an example of an expression that does work:

$ godef -f api/main.go environment.SetFromString
<PATH REDACTED>/environment.go:41:6

Here is an example of one of the offending expressions:

$ godef -f api/main.go state.Init
godef: no declaration found for state.Init

Finally, running the failed godef command with gogetdoc yields the proper results:

$ gogetdoc -pos api/main.go:#870
import "clarifai/state"

func Init()

Undocumented.

The offending cases all involve jumping to a function in another package, but in some cases this does work. In the cases where it works, it always works, and in the cases where it doesn't, it never seems to work.

I first filed an issue against vscode, which can be found here:
microsoft/vscode-go#702
It was recommended in that thread that I file an issue here, against godef.

[parser] problem with import path in go 1.8

I noticed a the following problem when updating Go from 1.7.1 to 1.8

  • resolving <pkg>.<identifier> in stdlib package pkg works as before,
  • when I am inside my own project, resolving <myPkg>.<myIdentifier> now fails (worked with go 1.7.1).

For example, in go1.7.1:

> godef -f src/dvol/sync.go sbd.E_SBD_IN_ERROR
/home/gerrit/go/srn/src/sbd/sbd.go:23:2

Now with go1.8:

> godef -f src/dvol/sync.go sbd.E_SBD_IN_ERROR
godef: no declaration found for sbd.E_SBD_IN_ERROR

Using git-bisect led to the following commit:

4170debb52d9bcf18b64c9e151c2be5cc453ff86 is the first bad commit
commit 4170debb52d9bcf18b64c9e151c2be5cc453ff86
Author: Roger Peppe <[email protected]>
Date:   Fri May 27 12:12:46 2016 +0100

    fix oops made when fixing tests

:040000 040000 61c3e32aacca3e994dcc36dd67d5b0d5fec31dba 66cf76b95266e8467dac8325ffeec2bffa93be86 M      go

This seems to point to 4170deb

However, since go/parser/parser.go imports go/build, I suspect that this has more to do with the changes in go/build.

cant find definition

if import some lib like ". github.com/a/b", can't goto definition which define in b.
function is also undefined.

// b.go
type GlobalConfig struct {
	Localaddr string
}
func InitGlobalVars(globalconfig *GlobalConfig) error {
}


// main.go
import (
. github.com/a/b
)
// can't goto definition
globalconfig := &GlobalConfig{}
// InitGlobalVars is undefined
InitGlobalVars(globalconfig)

vendor/ dir

I love godef, but it doesn't seem to notice when a vendor/ directory is being used.

godef: no declaration found when using dot import syntax

It works when the code looks like this.

file: main.go

package main

import (
    "fmt"
    "time"
)

func main() {
    ti := time.Now()
    fmt.Println(ti)
}
➜  godef -f=./main.go -o=68
/usr/local/Cellar/go/1.5/libexec/src/time/time.go:781:6

but it failed when the code change to this:

file: main.go

package main

import (
    "fmt"
    . "time"
)

func main() {
    ti := Now()
    fmt.Println(ti)
}
➜  godef -f=./main.go -o=65
parseLocalPackage error: no more package files found
godef: no declaration found for Now

Does godef support relative import path?

When I run
echo 'package foo; import "./httpproxy"; func main() { httpproxy.ListenTCP() }' | godef -i -o 60
in command line, I get parseLocalPackage error: no more package files found
godef: no declaration found for httpproxy.ListenTCP
error, and I am sure that httpproxy.ListenTCP is defined in a file inside ./httpproxy directory, so isn't relative import path supported?

go get -u -v github.com/rogpeppe/godef error

 anla@Anla  ~/go/src/golang-day-test master: go get -u -v github.com/rogpeppe/godef
github.com/rogpeppe/godef (download)
# cd /Users/anla/go/src/github.com/rogpeppe/godef; git pull --ff-only
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> master

package github.com/rogpeppe/godef: exit status 1

godef needs GOPATH set but this is not needed by Go 1.9 onwards

I have Go installed to a non-standard path. With Go 1.9 all you need is the go executable on the path and then Go figures everything out from there. However godef is not so clever and wants GOROOT to be set.

The following shows my Go environment with godef not working and then me setting GOROOT to get it working.

$ ls -l `which go`
lrwxrwxrwx 1 root root 29 Sep 12 11:01 /usr/bin/go -> /home/duncan/.go/go1.9/bin/go
$ set | fgrep GO
GOPATH=/home/duncan/.local
$ go version
go version go1.9 linux/amd64
$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/duncan/.local"
GORACE=""
GOROOT="/home/duncan/.go/go1.9"
GOTOOLDIR="/home/duncan/.go/go1.9/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build177033922=/tmp/go-build -gno-record-gcc-switches"
CXX="g++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
$ godef -f pkg/data/codebook/codebook.go csv.Reader
parseLocalPackage error: no more package files found
godef: no declaration found for csv.Reader
$ export GOROOT=/home/duncan/.go/go1.9
$ godef -f pkg/data/codebook/codebook.go csv.Reader
/home/duncan/.go/go1.9/src/encoding/csv/reader.go:90:6
$ set | fgrep GO
GOPATH=/home/duncan/.local
GOROOT=/home/duncan/.go/go1.9
$ 

Assembler error when installing godef

When I type go get github.com/rogpeppe/godef I got the following error:

# github.com/rogpeppe/godef/go/token
ar: `u' modifier ignored since `D' is the default (see `U')
# 9fans.net/go/plan9
/tmp/ccn2j9I2.s: Assembler messages:
/tmp/ccn2j9I2.s:1562: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:1687: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:2330: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:2335: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:2340: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:2728: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:2840: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:3039: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:3040: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:3168: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:3281: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:3483: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:3484: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:3836: Error: expected symbol name
/tmp/ccn2j9I2.s:3839: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:3839: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:3839: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:3840: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:3841: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:3842: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:4655: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:4660: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:5208: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:5447: Error: expected symbol name
/tmp/ccn2j9I2.s:5450: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:5450: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:5450: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:5451: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:5452: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:5453: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:5601: Error: expected symbol name
/tmp/ccn2j9I2.s:5604: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:5604: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:5604: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:5605: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:5606: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:5607: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:5608: Error: expected symbol name
/tmp/ccn2j9I2.s:5611: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:5611: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:5611: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:5612: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:5613: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:5614: Error: junk at end of line, first unrecognized character is `a'
/tmp/ccn2j9I2.s:7412: Error: expected symbol name
/tmp/ccn2j9I2.s:7413: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:7413: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:7413: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:7414: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:7457: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:7458: Error: expected symbol name
/tmp/ccn2j9I2.s:7459: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:7459: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:7459: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:7460: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:7513: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:7849: Error: expected symbol name
/tmp/ccn2j9I2.s:7850: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:7850: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:7850: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:7851: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:7941: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:7942: Error: expected symbol name
/tmp/ccn2j9I2.s:7943: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:7943: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:7943: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:7944: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:8934: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:8973: Error: expected symbol name
/tmp/ccn2j9I2.s:8974: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:8974: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:8974: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:8975: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:9207: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:9482: Error: expected symbol name
/tmp/ccn2j9I2.s:9483: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:9483: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:9483: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:9484: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:9701: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:9893: Error: expected symbol name
/tmp/ccn2j9I2.s:9894: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:9894: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:9894: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:9895: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:10100: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:10487: Error: expected symbol name
/tmp/ccn2j9I2.s:10488: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:10488: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:10488: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:10489: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:12196: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:12197: Error: expected symbol name
/tmp/ccn2j9I2.s:12198: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:12198: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:12198: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:12199: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:15699: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:15837: Error: expected symbol name
/tmp/ccn2j9I2.s:15838: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:15838: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:15838: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:15839: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:17603: Error: junk `ans_net_go_plan9.UnmarshalDir' after expression
/tmp/ccn2j9I2.s:17738: Error: junk `ans_net_go_plan9.UnmarshalDir' after expression
/tmp/ccn2j9I2.s:17989: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:17995: Error: expected symbol name
/tmp/ccn2j9I2.s:17996: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:17996: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:17996: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:17997: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:18452: Error: junk `ans_net_go_plan9.UnmarshalFcall' after expression
/tmp/ccn2j9I2.s:18526: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:18527: Error: expected symbol name
/tmp/ccn2j9I2.s:18528: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:18528: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:18528: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:18529: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:18570: Error: junk `ans_net_go_plan9.Bytes.pN24_9fans_net_go_plan9.Fcall' after expression
/tmp/ccn2j9I2.s:18702: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:19008: Error: expected symbol name
/tmp/ccn2j9I2.s:19009: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:19009: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:19009: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:19010: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:19056: Error: junk `ans_net_go_plan9.Qid$hash' after expression
/tmp/ccn2j9I2.s:19136: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:19137: Error: expected symbol name
/tmp/ccn2j9I2.s:19138: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:19138: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:19138: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:19139: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:19351: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:20887: Error: expected symbol name
/tmp/ccn2j9I2.s:20888: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:20888: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:20888: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:20889: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:20951: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:20952: Error: expected symbol name
/tmp/ccn2j9I2.s:20953: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:20953: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:20953: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:20954: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:21025: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s:21114: Error: expected symbol name
/tmp/ccn2j9I2.s:21115: Error: Missing symbol name in directive
/tmp/ccn2j9I2.s:21115: Error: unrecognized symbol type "9"
/tmp/ccn2j9I2.s:21115: Error: junk at end of line, first unrecognized character is `f'
/tmp/ccn2j9I2.s:21116: Error: junk at end of line, first unrecognized character is `9'
/tmp/ccn2j9I2.s:21196: Error: expected comma after name `' in .size directive
/tmp/ccn2j9I2.s: Error: local label `"9" (instance number 1 of a fb label)' is not defined
# github.com/rogpeppe/godef/go/scanner
ar: `u' modifier ignored since `D' is the default (see `U')
# github.com/rogpeppe/godef/go/ast
ar: `u' modifier ignored since `D' is the default (see `U')
# github.com/rogpeppe/godef/go/printer
ar: `u' modifier ignored since `D' is the default (see `U')
# github.com/rogpeppe/godef/go/parser
ar: `u' modifier ignored since `D' is the default (see `U')
# github.com/rogpeppe/godef/go/types
ar: `u' modifier ignored since `D' is the default (see `U')

I tried to git pull first and then install, I also tried to install 9fans package manually, but didn't find any workaround yet.

OS: Fedora 22 Linux 4.1.8-200.fc22.x86_64
Go version: go1.4.2 gccgo (GCC) 5.1.1 20150618 (Red Hat 5.1.1-4) linux/amd64

Thank you

Godef fails to locate local package files outside current working dir when using -i

When godef is used with the -i flag it fails to find definitions in other files from the buffer local package if it is located in the file system in a directory different than the current working directory. How to replicate:

Create a couple of directories:

mkdir -p godef_issue/pkg

Add the following as godef_issue/pkg/one.go:

package pkg

import "fmt"

func hello() {
    fmt.Println(definedInTwo)
}

This as `godef_issue/pkg/two.go':

package pkg

const definedInTwo = "Hello, I am defined in two.go"

Go to godef_issue and execute:

$ godef -f pkg/one.go 'definedInTwo'
pkg/two.go:3:7
$ cat pkg/one.go | godef -i 'definedInTwo'
parseLocalPackage error: no more package files found
godef: no declaration found for definedInTwo

I am providing a simple PR to fix it

godef crashes with panic: no object for _(0xc4205ab140) in go/test

I'm on the latest godef:

$ cd gocode/src/github.com/rogpeppe/
$ git log --oneline | head -n1
b692db1 Merge pull request #70 from uudashr/fix-indentation

installed with go 1.10 linux/amd64. godef crashes when querying the go/test/run.go file in the go repository, at tip:

$ cd go

$ git log --oneline | head -n1
3b0b8bcd68 test/codegen: port stack-related tests to codegen

$ cd test/
$ godef -f run.go baseGoFile
panic: no object for _(0xc4205d89e0)

goroutine 1 [running]:
github.com/rogpeppe/godef/go/parser.(*parser).parseSwitchStmt(0xc42044de40, 0x0, 0x0)
	/home/adonizetti/gocode/src/github.com/rogpeppe/godef/go/parser/parser.go:1707 +0x8f5
github.com/rogpeppe/godef/go/parser.(*parser).parseStmt(0xc42044de40, 0x0, 0x0)
	/home/adonizetti/gocode/src/github.com/rogpeppe/godef/go/parser/parser.go:1922 +0x467
github.com/rogpeppe/godef/go/parser.(*parser).parseStmtList(0xc42044de40, 0xc42026c500, 0x5, 0x8)
	/home/adonizetti/gocode/src/github.com/rogpeppe/godef/go/parser/parser.go:977 +0x85
github.com/rogpeppe/godef/go/parser.(*parser).parseBody(0xc42044de40, 0xc42018c5c0, 0x0)
	/home/adonizetti/gocode/src/github.com/rogpeppe/godef/go/parser/parser.go:991 +0xb4
github.com/rogpeppe/godef/go/parser.(*parser).parseFuncDecl(0xc42044de40, 0x0)
	/home/adonizetti/gocode/src/github.com/rogpeppe/godef/go/parser/parser.go:2147 +0x311
github.com/rogpeppe/godef/go/parser.(*parser).parseDecl(0xc42044de40, 0x0, 0x0)
	/home/adonizetti/gocode/src/github.com/rogpeppe/godef/go/parser/parser.go:2182 +0x132
github.com/rogpeppe/godef/go/parser.(*parser).parseFile(0xc42044de40, 0x0)
	/home/adonizetti/gocode/src/github.com/rogpeppe/godef/go/parser/parser.go:2246 +0x237
github.com/rogpeppe/godef/go/parser.ParseFile(0xc420098340, 0xc4204b7730, 0xe, 0x0, 0x0, 0x0, 0xc4200865c0, 0x651050, 0xc420451100, 0x0, ...)
	/home/adonizetti/gocode/src/github.com/rogpeppe/godef/go/parser/interface.go:155 +0x190
main.parseLocalPackage(0x7ffec70704d3, 0x6, 0xc420437180, 0xc4200865c0, 0x651050, 0x0, 0x0, 0x0)
	/home/adonizetti/gocode/src/github.com/rogpeppe/godef/godef.go:329 +0x3ca
main.main()
	/home/adonizetti/gocode/src/github.com/rogpeppe/godef/godef.go:113 +0x3a4

This does not happen if the run.go file is copied elsewhere and then queried.

godef: no declaration found for fmt.Println

I am using Emacs go-mode with godef, but M-x godef can't find declarations in golang standard packages while it works for third party packages in $GOPATH, what am I doing wrong ?

when the package name is different form import name it can't work?

package main

import (
    "net/http"

    "github.com/googollee/go-socket.io"
    "listome.com/log"
)

func main() {
    server, err := socketio.NewServer(nil)
    if err != nil {
        log.Fatal(err)
    }
    server.On("connection", func(so socketio.Socket) {
        log.Info("on connection")
        so.Join("paint_game")

        so.On("paint", func(msg string) {
            // log.Info("painting:", msg)
            log.Info("broadcast:", so.BroadcastTo("paint_game", "painting", msg))
        })
        so.On("disconnection", func() {
            log.Info("on disconnect")
        })
    })
    server.On("error", func(so socketio.Socket, err error) {
        log.Error("error:", err)
    })

    http.Handle("/socket.io/", server)
    http.Handle("/", http.FileServer(http.Dir("./")))
    log.Info("Serving at localhost:5000...")
    log.Fatal(http.ListenAndServe(":5000", nil))

}

godef -f main.go 'socketio.NewServer'
parseLocalPackage error: no more package files found
godef: no declaration found for socketio.NewServer

when I add import name,

package main

import (
    "net/http"

    socketio "github.com/googollee/go-socket.io"
    "listome.com/log"
)

func main() {
    server, err := socketio.NewServer(nil)
    if err != nil {
        log.Fatal(err)
    }
    server.On("connection", func(so socketio.Socket) {
        log.Info("on connection")
        so.Join("paint_game")

        so.On("paint", func(msg string) {
            // log.Info("painting:", msg)
            log.Info("broadcast:", so.BroadcastTo("paint_game", "painting", msg))
        })
        so.On("disconnection", func() {
            log.Info("on disconnect")
        })
    })
    server.On("error", func(so socketio.Socket, err error) {
        log.Error("error:", err)
    })

    http.Handle("/socket.io/", server)
    http.Handle("/", http.FileServer(http.Dir("./")))
    log.Info("Serving at localhost:5000...")
    log.Fatal(http.ListenAndServe(":5000", nil))

}

godef -f main.go 'socketio.NewServer'
/home/lstbao/work/listomego/src/github.com/googollee/go-socket.io/server.go:17:6

It can work well.

Unable to parse implicitely typed map struct keys, when imported from other package

Category

Bug report

Environment and versions used

  • Golang version: 1.9
  • Operating System: Mac OSX Sierra
  • godef version: current master @ b692db1

NB:

  • $GOPATH and $GOROOT are correctly setup
  • The bug should not be platform dependent

Issue

When a map that maps a struct to another struct is defined, if the map keys are typed implicitely, and the package is imported by another package, godef throws an error

Steps to reproduce

(A github repo is linked below for the test)

  • Create a new directory, for example $GOPATH/src/test
  • Create a main.go file :
package main

import "fmt"
import "test/someotherpackage"

func main() {
    fmt.Println(someotherpackage.Map)
}
  • Create another package, for example $GOPATH/src/test/someotherpackage
  • Create a test.go file :
package someotherpackage

type Test struct {
    X int
    Y int
}

var Map = map[Test]struct{}{
    {1,2} : struct{}{},
    {1,2} : struct{}{},
    {1,2} : struct{}{},
}
  • Run :
godef -debug -f main.go someotherpackage.Map

This produces the following stacktrace :

Stacktrace
2017/10/20 19:50:04 exprType tuple:false pkg: *ast.SelectorExpr someotherpackage.Map [
2017/10/20 19:50:04 exprType tuple:false pkg: *ast.Ident someotherpackage [
2017/10/20 19:50:04 exprType tuple:false pkg: *ast.ImportSpec "test/someotherpackage" [
2017/10/20 19:50:04 ] -> 0x0, Type{package "" *ast.ImportSpec "test/someotherpackage"}
2017/10/20 19:50:04 ] -> 0xc420011a40, Type{package "" *ast.ImportSpec "test/someotherpackage"}
2017/10/20 19:50:04 member Type{package "" *ast.ImportSpec "test/someotherpackage"} 'Map' {
2017/10/20 19:50:04 	$GOPATH/src/test/someotherpackage/test.go:9:11: expected '}', found ':'
2017/10/20 19:50:04 	$GOPATH/src/test/someotherpackage/test.go:10:5: expected declaration, found '{'
2017/10/20 19:50:04 	$GOPATH/src/test/someotherpackage/test.go:11:5: expected declaration, found '{'
2017/10/20 19:50:04 	$GOPATH/src/test/someotherpackage/test.go:12:1: expected declaration, found '}'
2017/10/20 19:50:04 } -> <nil>
2017/10/20 19:50:04 ] -> 0x0, Type{bad "" <nil> }
parseLocalPackage error: no more package files found
2017/10/20 19:50:04 exprType tuple:false pkg: *ast.SelectorExpr someotherpackage.Map [
2017/10/20 19:50:04 exprType tuple:false pkg: *ast.Ident someotherpackage [
2017/10/20 19:50:04 exprType tuple:false pkg: *ast.ImportSpec "test/someotherpackage" [
2017/10/20 19:50:04 ] -> 0x0, Type{package "" *ast.ImportSpec "test/someotherpackage"}
2017/10/20 19:50:04 ] -> 0xc420011a40, Type{package "" *ast.ImportSpec "test/someotherpackage"}
2017/10/20 19:50:04 member Type{package "" *ast.ImportSpec "test/someotherpackage"} 'Map' {
2017/10/20 19:50:04 	$GOPATH/src/test/someotherpackage/test.go:9:11: expected '}', found ':'
2017/10/20 19:50:04 	$GOPATH/src/test/someotherpackage/test.go:10:5: expected declaration, found '{'
2017/10/20 19:50:04 	$GOPATH/src/test/someotherpackage/test.go:11:5: expected declaration, found '{'
2017/10/20 19:50:04 	$GOPATH/src/test/someotherpackage/test.go:12:1: expected declaration, found '}'
2017/10/20 19:50:04 } -> <nil>
2017/10/20 19:50:04 ] -> 0x0, Type{bad "" <nil> }
godef: no declaration found for someotherpackage.Map

Expected behaviour

It should find the declaration for someotherpackage.Map, as this is valid go syntax. The code compiles and runs fine !

Reproducible demo

The test can be found here : https://github.com/Gandem/test-issue-godef

Cloning the repo in $GOPATH/test should work to reproduce the issue.

Note : godef -debug -f test.go Map works fine when the command is run from $GOPATH/test/someotherpackage

can not go build godef.go

when I go build godef.go,It prompts the error log like this:

command-line-arguments

.\godef.go:55: undefined: acmeFile
.\godef.go:59: undefined: acmeCurrentFile

why? how can I init the acmeFIle?

Types are incorrect when omitting the value while ranging over a slice

This is picking up: microsoft/vscode-go#1242

I found an issue in godef where the first argument when ranging over a slice will be incorrect when you omit the value (i.e. use the index only).

Consider the following program:

package main

import (
	"fmt"
)

func main() {
	s := []string{"a", "b", "c"}
	for index, char := range s {
		fmt.Println(index, char)
	}
	for index := range s {
		fmt.Println(index)
	}
}

I will get int, string for the first loop, but bool for the second one:

frederik@fr-xps:~/projects/go/src/github.com/m90/test$ cat main.go 
package main

import (
	"fmt"
)

func main() {
	s := []string{"a", "b", "c"}
	for index, char := range s {
		fmt.Println(index, char)
	}
	for index := range s {
		fmt.Println(index)
	}
}

frederik@fr-xps:~/projects/go/src/github.com/m90/test$ godef -o 84 -f main.go -t
main.go:9:6
index int
frederik@fr-xps:~/projects/go/src/github.com/m90/test$ godef -o 89 -f main.go -t
main.go:9:13
char string
frederik@fr-xps:~/projects/go/src/github.com/m90/test$ godef -o 144 -f main.go -t
main.go:12:6
index bool

Godef rogue goroutines on macOS Sierra

I have been running godef in VSCode and it will routinely eat up %200 of my cpu. I know that go has had a few different issues with the other release candidates but so far I have only had an issue with this application. Let me know if there is any other information you need!

macOS Sierra Version 10.12
go version go1.7.1 darwin/amd64

Are CGO projects supported?

I found out go-mode.el didn't allow me to use godef on exactly those symbols defined in CGO files.
It can be boiled down to that godef will not report this definition:

package test

/*
#include <stdio.h>
*/
import "C"

func Testing() string {
	return "testing"
}

However, if the import "C" line is included in the comment, the definition is reported correctly.

... using Go 1.7.3
main prg:

package main

import (
	"fmt"
	"test"
)

func main() {
	fmt.Println(test.Testing())
}

vgo support?

Seems a lot of tools use godef to do resolution of their symbols when jumping to sources. With vgo's support for multiple versions in $GOPATH/src/v this seems like something godef could really help with. Any plans to add support for this given that vgo is moving forward? (I'm willing to help though I'm not sure I understand the tools well enough to do so)

Missing dependency due to a build tag?

Go noob here, so I'm not entirely sure this bug belongs to godef, but we'll start here. My issue is that the emacs go-mode invokes godef and isn't able to find the declaration for a function in the spf13/cobra library, even though I know it's installed. This gist shows the output when godef's -debug flag is passed: https://gist.github.com/b1c4d48bcefbffa573f2da9ed605033c

It appears that godef is complaining about a missing mousetrap dependency. I believe this is missing because cobra's command_win.go file includes a +build windows tag, and I'm on linux.

Am I making any sense? Let me know if this bug is more appropriate in either go-mode's or cobra's repo. Thanks!

Go to Definition is not considering the GOHOSTOS' when the function is defined for multiple GOHOSTOS'

From @zignd on April 15, 2017 18:42

I was using Windows, I tried to Go to Definition on a call to the rename function (internal function in the os package), and the function definition for Plan 9 opened in my editor.

The rename function has definitions in GOROOT/src/os/file_plan9.go, GOROOT/src/os/file_unix.go, and in GOROOT/src/os/file_windows.go.

I was expecting the extension to open the definition from the GOROOT/src/os/file_windows.go file.

Copied from original issue: microsoft/vscode-go#927

Error with github.com/bugsnag/bugsnag-go

As already discussed here:
bugsnag/bugsnag-go#14 (comment)

Also with the modified command I get this error:

$ ~/src/github.com/bugsnag/bugsnag-go o godef -t -debug -f ./doc.go Configure
2015/02/09 22:21:31 exprType tuple:false pkg: *ast.Ident Configure [
2015/02/09 22:21:31 ] -> 0x0, Type{bad "" }
godef: no declaration found for Configure

Thank you

Incorrect function declaration for methods

From microsoft/vscode-go#634 by @heliorosa

For the following program, the declaration for bigAdd is shown as bigAdd func(x, y *Int) *Int instead of bigAdd func(z, x, y *Int) *Int.

package main

import (
	"fmt"
	"math/big"
)

func main() {
	bigAdd := (*big.Int).Add
	a := big.NewInt(1)
	b := big.NewInt(2)
	c := bigAdd(new(big.Int), a, b)
	fmt.Println(a)
	fmt.Println(b)
	fmt.Println(c)
}

cannot find definition of code in vendor directory

  1. create main.go in gopath
package main

import (
	"go.uber.org/zap"
)

func main() {
	logger, _ := zap.NewProduction()
	defer logger.Sync()

	logger.Info("haha")
}
  1. run dep ensure -add "go.uber.org/zap"

  2. use vim, open main.go, jump to line 11, under Info of logger.Info, and run :YcmCompleter GoTo,
    got RuntimeError: Can't find a definition.

  3. ycmd says: RuntimeError: Command godef -i -f=main.go -json -o=126 failed with code 2 and error "godef: no declaration found for logger.Info".

  4. run it in command:

$ godef -i -f=main.go -o=126 < main.go
parseLocalPackage error: no more package files found
godef: no declaration found for logger.Info

ref: ycm-core/YouCompleteMe#2985 (comment)

Jump to definition of a specific implementation of interface functions

Often I want to debug an interface, but I'm really debugging one of its implementations..

When I look at code that calls funcs on that interface, and I jump to definition, I jump to the type definition.. Would it be possible to drop somewhere a file, or annotate with some comments for temporary indirection of jumps to that interface, to a specific implementation instead ?

Ex:

type Plugin interface {
    Boo()
}

type Plugin1 struct {}
func (p *Plugin1) Boo() {}

func main() {
    plugplug := Plugin(&Plugin1{})
    plugplug.Boo()
}

Attempting to jump to Boo's definition, we get to the Plugin interface. I'd like to jump to Plugin1's Boo() instead.. since I'm working on that one.

Could it have something like:

// godef: Plugin1
//  or
// godef: otherpkg.Plugin1
//  or
// godef: github.com/bob/dylan:Plugin1
//  or something ?
type Plugin interface{
   ...

that'd be so awesome!

thanks

Symbolic link problem

godef currently supports vendor. But when the src in $GOPATH is linked by a symbolic link, godef does not work.

Always 'fatal error: unexpected signal during runtime execution'

Here is the error message in vim quickfix window.

|| fatal error: unexpected signal during runtime execution
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/runtime/panic.go:547 +0x90 fp=0xc82019ce00 sp=0xc82019cde8
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/runtime/sigpanic_unix.go:12 +0x5a fp=0xc82019ce50 sp=0xc82019ce00
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/runtime/internal/atomic/atomic_amd64x.go:26 +0x5 fp=0xc82019ce58 sp=0xc82019ce50
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/runtime/lfstack.go:38 +0x6d fp=0xc82019ce90 sp=0xc82019ce58
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/runtime/mgcwork.go:341 +0x3b fp=0xc82019cec0 sp=0xc82019ce90
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/runtime/mgcwork.go:97 +0x20 fp=0xc82019ced8 sp=0xc82019cec0
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/runtime/mgcwork.go:141 +0x38 fp=0xc82019cf08 sp=0xc82019ced8
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/runtime/mgcmark.go:833 +0x22a fp=0xc82019cf40 sp=0xc82019cf08
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/runtime/mgc.go:1433 +0x25f fp=0xc82019cfb8 sp=0xc82019cf40
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/runtime/asm_amd64.s:1998 +0x1 fp=0xc82019cfc0 sp=0xc82019cfb8
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/runtime/mgc.go:1330 +0x92
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:907 +0x55b
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:519 +0x535
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/cmd/guru/definition.go:74 +0xa75
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/cmd/guru/guru.go:102 +0x728
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/cmd/guru/main.go:213 +0x902
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:907 +0x55b
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:1000 +0x100
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:975 +0x1d0
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:956 +0x2b
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:958 +0x1d4
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:907 +0x55b
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:1000 +0x100
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:975 +0x1d0
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:956 +0x2b
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:958 +0x1d4
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:907 +0x55b
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:1000 +0x100
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:975 +0x1d0
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:956 +0x2b
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:958 +0x1d4
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:907 +0x55b
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:1000 +0x100
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:975 +0x1d0
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:956 +0x2b
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:958 +0x1d4
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/expr.go:914 +0x416
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/expr.go:1115 +0x63b
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/expr.go:945 +0x7d
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/expr.go:1494 +0x86
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/expr.go:915 +0x46d
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/expr.go:1115 +0x63b
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/expr.go:945 +0x7d
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/expr.go:1494 +0x86
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/expr.go:1150 +0xea8
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/expr.go:945 +0x7d
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/expr.go:1472 +0x63
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/expr.go:1466 +0x3f
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/decl.go:158 +0x3b9
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/decl.go:81 +0x474
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/resolver.go:418 +0x22a
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/check.go:225 +0xfc
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:1009 +0x13f
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:975 +0x1d0
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:956 +0x2b
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:958 +0x1d4
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/check.go:339 +0xa0
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:426 +0x92b
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:150 +0x2a5
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/decl.go:300 +0x104
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/decl.go:87 +0x6a5
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/decl.go:283 +0x4d4
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/decl.go:232 +0x287
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/decl.go:84 +0x651
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:36 +0x38f
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:217 +0x151
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:132 +0x88
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:140 +0x5b
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:276 +0xfc3
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:132 +0x88
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:648 +0x208
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:270 +0x12fa
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:132 +0x88
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/decl.go:210 +0x211
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/decl.go:84 +0x651
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:36 +0x38f
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:217 +0x151
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:132 +0x88
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:140 +0x5b
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:276 +0xfc3
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:132 +0x88
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:648 +0x208
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:270 +0x12fa
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:132 +0x88
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/decl.go:210 +0x211
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/decl.go:84 +0x651
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:36 +0x38f
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:217 +0x151
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/typexpr.go:132 +0x88
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/decl.go:210 +0x211
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/decl.go:84 +0x651
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/resolver.go:418 +0x22a
|| 	/usr/local/Cellar/go/1.6.2/libexec/src/go/types/check.go:225 +0xfc
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:1009 +0x13f
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:975 +0x1d0
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:956 +0x2b
|| 	/Users/Lime/Documents/workspace/GoProject/src/golang.org/x/tools/go/loader/loader.go:958 +0x1d4

Cannot jump to definition of instance methods

godef does not seem to support jumping to the definition of an instance method.

Given this example:

package main

import "fmt"

type foo struct{}

func (f *foo) Public() string {
    return "I am a method on foo"
}

func main() {
    f := &foo{}
    fmt.Println(f.Public())
}
$ godef -f ./godef_bug.go 'foo.Public'
./godef_bug.go:7:15

$ godef -f ./godef_bug.go 'f.Public'
godef: no declaration found for f.Public

in practice, I'm using godef in go-plus in atom, and it's always attempting lookup on an instance.

Error installing go def

08:30:56 ✗ HellX:~/.vim/bundle >go install github.com/rogpeppe/godef
# 9fans.net/go/plan9
/tmp/cc9KFhN9.s: Assembler messages:
/tmp/cc9KFhN9.s:2905: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:2993: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:3185: Error: expected symbol name
/tmp/cc9KFhN9.s:3186: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:3186: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:3186: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:3187: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:3230: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:3653: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:3658: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:3663: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:3972: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:4059: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:4229: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:4230: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:4342: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:4430: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:4628: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:4629: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:4637: Error: expected symbol name
/tmp/cc9KFhN9.s:4638: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:4638: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:4638: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:4639: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:4692: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:5021: Error: expected symbol name
/tmp/cc9KFhN9.s:5022: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:5022: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:5022: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:5023: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:5106: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:5185: Error: expected symbol name
/tmp/cc9KFhN9.s:5188: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:5188: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:5188: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:5189: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:5190: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:5191: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:5193: Error: expected symbol name
/tmp/cc9KFhN9.s:5194: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:5194: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:5194: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:5195: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:5968: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:6007: Error: expected symbol name
/tmp/cc9KFhN9.s:6008: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:6008: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:6008: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:6009: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:6215: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:6707: Error: expected symbol name
/tmp/cc9KFhN9.s:6708: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:6708: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:6708: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:6709: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:6888: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:7065: Error: expected symbol name
/tmp/cc9KFhN9.s:7066: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:7066: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:7066: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:7067: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:7264: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:7738: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:7743: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:8259: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:8271: Error: expected symbol name
/tmp/cc9KFhN9.s:8272: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:8272: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:8272: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:8273: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:9778: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:9779: Error: expected symbol name
/tmp/cc9KFhN9.s:9782: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:9782: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:9782: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:9783: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:9784: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:9785: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:9787: Error: expected symbol name
/tmp/cc9KFhN9.s:9788: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:9788: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:9788: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:9789: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:12579: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:12717: Error: expected symbol name
/tmp/cc9KFhN9.s:12718: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:12718: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:12718: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:12719: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:14305: Error: junk `ans_net_go_plan9.UnmarshalDir' after expression
/tmp/cc9KFhN9.s:14424: Error: junk `ans_net_go_plan9.UnmarshalDir' after expression
/tmp/cc9KFhN9.s:14647: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:14648: Error: expected symbol name
/tmp/cc9KFhN9.s:14651: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:14651: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:14651: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:14652: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:14653: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:14654: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:14660: Error: expected symbol name
/tmp/cc9KFhN9.s:14661: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:14661: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:14661: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:14662: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:15004: Error: junk `ans_net_go_plan9.UnmarshalFcall' after expression
/tmp/cc9KFhN9.s:15042: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:15043: Error: expected symbol name
/tmp/cc9KFhN9.s:15046: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:15046: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:15046: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:15047: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:15048: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:15049: Error: junk at end of line, first unrecognized character is `a'
/tmp/cc9KFhN9.s:15051: Error: expected symbol name
/tmp/cc9KFhN9.s:15052: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:15052: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:15052: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:15053: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:15089: Error: junk `ans_net_go_plan9.Bytes.pN24_9fans_net_go_plan9.Fcall' after expression
/tmp/cc9KFhN9.s:15168: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:15169: Error: expected symbol name
/tmp/cc9KFhN9.s:15170: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:15170: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:15170: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:15171: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:15217: Error: junk `ans_net_go_plan9.Qid$hash' after expression
/tmp/cc9KFhN9.s:15297: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:15298: Error: expected symbol name
/tmp/cc9KFhN9.s:15299: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:15299: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:15299: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:15300: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:15537: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:15655: Error: expected symbol name
/tmp/cc9KFhN9.s:15656: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:15656: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:15656: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:15657: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:15719: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:15720: Error: expected symbol name
/tmp/cc9KFhN9.s:15721: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:15721: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:15721: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:15722: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:15793: Error: expected comma after name `' in .size directive
/tmp/cc9KFhN9.s:16109: Error: expected symbol name
/tmp/cc9KFhN9.s:16110: Error: Missing symbol name in directive
/tmp/cc9KFhN9.s:16110: Error: unrecognized symbol type "9"
/tmp/cc9KFhN9.s:16110: Error: junk at end of line, first unrecognized character is `f'
/tmp/cc9KFhN9.s:16111: Error: junk at end of line, first unrecognized character is `9'
/tmp/cc9KFhN9.s:16135: Error: expected comma after name `' in .size directive
08:31:35 ✗ HellX:~/.vim/bundle >

cannot compile on windows

when compile on win64 platform, show this error:

# github.com/rogpeppe/godef/vendor/9fans.net/go/plan9/client
compile: reading input: EOF

platform : Windows 10 64-bit
go : 1.7.6.windows-amd64 \ 1.8.3.windows-amd64 \ 1.8.3.windows-386 (I tried 3 versions)

Stuck running at 100% CPU

I was running this version. I don't see anything in the commit log about relevant fixes, so I'm posting this in case it's useful.

godef is taking about 1.5 cores, and never finishes:

$ ps aux | grep godef                
alex             57986  67.6  0.0 573401376   2608   ??  R    12:31PM  35:49.10 /Users/alex/.go/bin/godef -t -i -f /Users/alex/.go/src/github.com/t11e/picaxe/resources/http_test.go -o 350

This is the file it's choking on. However, godef was started an hour ago, and I have been actively working on that file, so the offset is no longer correct.

Here is a macOS spindump of the process. (S3 is down right now, so I can't upload to Github.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.