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

cmd/go2go: can't import C #42645

Closed
EMurray16 opened this issue Nov 16, 2020 · 1 comment
Closed

cmd/go2go: can't import C #42645

EMurray16 opened this issue Nov 16, 2020 · 1 comment

Comments

@EMurray16
Copy link

What version of Go are you using (go version)?

$ go version
go version devel +2298dab082 Thu Oct 22 00:19:08 2020 +0000

Does this issue reproduce with the latest release?

I think this is the latest commit on the dev.go2go branch.

What operating system and processor architecture are you using (go env)?

$ go env
darwin/amd64

What did you do?

I maintain a package that uses cgo and could benefit from generics. I decided to create a branch to see how I liked the generics (for what it's worth: thumbs up so far!), but I started having issues with import "C".

I created a very small Hello World example that gives me the same issues I see with my "real world" package. Single file package with the name hello.go2.

package main

// #include <stdio.h>
//
// void Hello() {
// 	printf("Hello World\n");
// }
import "C"

func main() {
	C.Hello()
}

What did you expect to see?

Hello World

If I change the file extension from .go2 to .go and do a normal go run, this is indeed what I see.

What did you see instead?

type checking failed for main
/var/folders/k6/8msxm8_x7ldbknfzp7cyzn680000gn/T/go2go-run942322282/hello.go2:8:8: could not import C (unknown import path "C": internal error: module loader did not resolve import)
@ianlancetaylor
Copy link
Contributor

Sorry, the go2go tool was for experimentation, and does not support cgo. We do not plan to extend it to add cgo support.

If the generics proposal is approved, the real implementation will of course support cgo.

@golang golang locked and limited conversation to collaborators Nov 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants