Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gogetdoc seems not to work when a go file has import "C" #39

Closed
leixure opened this issue Sep 16, 2018 · 1 comment
Closed

gogetdoc seems not to work when a go file has import "C" #39

leixure opened this issue Sep 16, 2018 · 1 comment

Comments

@leixure
Copy link

leixure commented Sep 16, 2018

foo.h

#ifndef __FOO_H__
#define __FOO_H__

inline void foo(void)
{
}

#endif//__FOO_H__

foo.go

// Package foo is just any package
package foo

/*
#include "foo.h"
*/
import "C"

// Foo calls the foo function in C
func Foo() {
    C.foo()
}

bar.go

package foo

// Bar calls Foo
func Bar() {
    Foo()
}

gogetdoc for foo.Foo and foo.Bar and see the former fails and the latter succeeds

$ gogetdoc -pos "foo.go:#125"
xxx/bar.go:5:2: undeclared name: Foo
gogetdoc: couldn't find foo.go in program
$ gogetdoc -pos "bar.go:#37"
import "xxx/foo"

func Bar()

Bar calls Foo

Now change bar.go to import "C"

package foo

/*
void bar()
{
}
*/
import "C"

// Bar calls Foo
func Bar() {
    C.bar()
}

then run gogetdoc for foo.Bar

 $ gogetdoc -pos "bar.go:#70"
gogetdoc: couldn't find bar.go in program
@zmb3
Copy link
Owner

zmb3 commented Sep 17, 2018

Cgo is not currently supported, so closing this as a duplicate of #33 and #21.

I didn't find the performance with Cgo enabled to be acceptable, but I'm hoping with the advent of go/packages (see #38) we'll be able to resolve that.

@zmb3 zmb3 closed this as completed Sep 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants