[master] Special treatment for "C" package. #44

wants to merge 2 commits into


None yet

6 participants

hotpxl commented Jul 27, 2016

Fixes #41 (at least for me).

import "C" is not a real package. So godef cannot correctly parse any package that says import "C". This adds a special treatment for this package and circumvents this problem.

TargetLiu commented Aug 1, 2016 edited

It works, for me, thx

applee commented Aug 22, 2016

It has no effect in go1.7 linux/amd64.

hotpxl commented Aug 22, 2016

@applee How does it look on your side? It's a hard-coded workaround for "C". It cannot jump to definition on "C" but at least parses for other definitions.


this worked for me

@@ -1967,6 +1967,9 @@ func parseImportSpec(p *parser, doc *ast.CommentGroup, decl *ast.GenDecl, _ int)
if declIdent == nil {
filename := p.fset.Position(path.Pos()).Filename
name, err := p.pathToName(litToString(path), filepath.Dir(filename))
+ if litToString(path) == "C" {
liggitt Sep 27, 2016

maybe only do this if name is also "" (and would therefore fail otherwise)?

hotpxl Sep 28, 2016

That sounds reasonable.

@muirrn muirrn referenced this pull request Oct 3, 2016

net.LookupIP fails #41

muirrn commented Oct 3, 2016

This fixed it for me as well. Can this be merged?

@buaazp buaazp referenced this pull request in buaazp/Godef Oct 10, 2016

Godef can't find decalrations under `net` package #18

Ambrevar commented Nov 8, 2016 edited

I had the same issue with https://github.com/aarzilli/golua. This PR fixes it. (On 1.7 as well, btw.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment