Giter Club home page Giter Club logo

Comments (7)

sky126 avatar sky126 commented on June 15, 2024 14

github.com\rogpeppe\godef\go\parser\parser.go

// p.error(path.Pos(), fmt.Sprintf("cannot find identifier for package %q: %v", litToString(path), err))

fixed this

from godef.

muirdm avatar muirdm commented on June 15, 2024 1

#44 fixed this issue for me.

from godef.

walktall avatar walktall commented on June 15, 2024
godef -debug -f /usr/local/Cellar/go/1.6.2/libexec/src/log/syslog/syslog.go -o 3403
2016/07/05 13:57:07 exprType tuple:false pkg: *ast.SelectorExpr net.Dial [
2016/07/05 13:57:07 exprType tuple:false pkg: *ast.Ident net [
2016/07/05 13:57:07 exprType tuple:false pkg: *ast.ImportSpec "net" [
2016/07/05 13:57:07 ] -> 0x0, Type{package "" *ast.ImportSpec "net"}
2016/07/05 13:57:07 ] -> 0xc8201de690, Type{package "" *ast.ImportSpec "net"}
2016/07/05 13:57:07 member Type{package "" *ast.ImportSpec "net"} 'Dial' {
2016/07/05 13:57:07     /usr/local/Cellar/go/1.6.2/libexec/src/net/cgo_android.go:10:8: cannot find identifier for package "C": cannot find package "C" in any of:
    /usr/local/Cellar/go/1.6.2/libexec/src/vendor/C (vendor tree)
    /usr/local/Cellar/go/1.6.2/libexec/src/C (from $GOROOT)
    /Users/Zhiheng/Workspace/go/src/C (from $GOPATH)
2016/07/05 13:57:07 } -> <nil>
2016/07/05 13:57:07 ] -> 0x0, Type{bad "" <nil> }
2016/07/05 13:57:07 exprType tuple:false pkg: *ast.SelectorExpr net.Dial [
2016/07/05 13:57:07 exprType tuple:false pkg: *ast.Ident net [
2016/07/05 13:57:07 exprType tuple:false pkg: *ast.ImportSpec "net" [
2016/07/05 13:57:07 ] -> 0x0, Type{package "" *ast.ImportSpec "net"}
2016/07/05 13:57:07 ] -> 0xc8201de690, Type{package "" *ast.ImportSpec "net"}
2016/07/05 13:57:07 member Type{package "" *ast.ImportSpec "net"} 'Dial' {
2016/07/05 13:57:07     /usr/local/Cellar/go/1.6.2/libexec/src/net/cgo_android.go:10:8: cannot find identifier for package "C": cannot find package "C" in any of:
    /usr/local/Cellar/go/1.6.2/libexec/src/vendor/C (vendor tree)
    /usr/local/Cellar/go/1.6.2/libexec/src/C (from $GOROOT)
    /Users/Zhiheng/Workspace/go/src/C (from $GOPATH)
2016/07/05 13:57:07 } -> <nil>
2016/07/05 13:57:07 ] -> 0x0, Type{bad "" <nil> }
godef: no declaration found for net.Dial

Is this one related here?

from godef.

hotpxl avatar hotpxl commented on June 15, 2024

I'm having a related issue on Arch Linux with go1.6.3 linux/amd64

When I try godef --debug -f abc.go net.DialTimeout, it returns

2016/07/27 20:45:52 exprType tuple:false pkg: *ast.SelectorExpr net.DialTimeout [
2016/07/27 20:45:52 exprType tuple:false pkg: *ast.Ident net [
2016/07/27 20:45:52 exprType tuple:false pkg: *ast.ImportSpec "net" [
2016/07/27 20:45:52 ] -> 0x0, Type{package "" *ast.ImportSpec "net"}
2016/07/27 20:45:52 ] -> 0xc820143a40, Type{package "" *ast.ImportSpec "net"}
2016/07/27 20:45:52 member Type{package "" *ast.ImportSpec "net"} 'DialTimeout' {
2016/07/27 20:45:52     /usr/lib/go/src/net/conf_netcgo.go:14:8: cannot find identifier for package "C": cannot find package "C" in any of:
        /usr/lib/go/src/vendor/C (vendor tree)
        /usr/lib/go/src/C (from $GOROOT)
        /home/hotpxl/go/src/C (from $GOPATH)
2016/07/27 20:45:52 } -> <nil>
2016/07/27 20:45:52 ] -> 0x0, Type{bad "" <nil> }
2016/07/27 20:45:52 exprType tuple:false pkg: *ast.SelectorExpr net.DialTimeout [
2016/07/27 20:45:52 exprType tuple:false pkg: *ast.Ident net [
2016/07/27 20:45:52 exprType tuple:false pkg: *ast.ImportSpec "net" [
2016/07/27 20:45:52 ] -> 0x0, Type{package "" *ast.ImportSpec "net"}
2016/07/27 20:45:52 ] -> 0xc820143a40, Type{package "" *ast.ImportSpec "net"}
2016/07/27 20:45:52 member Type{package "" *ast.ImportSpec "net"} 'DialTimeout' {
2016/07/27 20:45:52     /usr/lib/go/src/net/conf_netcgo.go:14:8: cannot find identifier for package "C": cannot find package "C" in any of:
        /usr/lib/go/src/vendor/C (vendor tree)
        /usr/lib/go/src/C (from $GOROOT)
        /home/hotpxl/go/src/C (from $GOPATH)
2016/07/27 20:45:52 } -> <nil>
2016/07/27 20:45:52 ] -> 0x0, Type{bad "" <nil> }
godef: no declaration found for net.DialTimeout

Looks like it's having problems importing cgo

from godef.

rongyi avatar rongyi commented on June 15, 2024

master branch still has this problem?

from godef.

bboreham avatar bboreham commented on June 15, 2024

It seems to me that there is a mismatch between two implementations of "exclude files that are not for the current architecture".

One is in godef/go/types/goodarch.go:goodOSArch(), which decides purely on the file name.
The other is in go/build/build.go:shouldBuild() via Context.match() which looks at // +build lines.

So for the example at the top the former decides /home/rog/go/src/net/interface_bsdvar.go is ok, and the latter decides there are no files to parse in /home/rog/go/src/vendor/golang.org/x/net/route, because they are all excluded by +build directives.

Given that build.Default.Import() returns a set of Go files and ignored Go files, could we not use them instead of the isGoFile logic?

from godef.

rogpeppe avatar rogpeppe commented on June 15, 2024

Fixed by #62

from godef.

Related Issues (20)

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.