importing "C" is not supported by GopherJS

155 views
Skip to first unread message

Patrick Lismore

unread,
Aug 25, 2016, 8:41:57 AM8/25/16
to GopherJS

Hi 

I am compiling a project from go to javascript and one of my files is throwing this exception.



func
(e *ImportCError) Error() string {
 
return e.pkgPath + `: importing "C" is not supported by GopherJS`
 
}

Can someone explain a little bit more on what is happening when the above gets triggered.

thanks P

Patrick Lismore

unread,
Aug 25, 2016, 8:45:20 AM8/25/16
to GopherJS
In my go file there is an import

import "C"

Ian Lance Taylor

unread,
Aug 25, 2016, 11:24:13 AM8/25/16
to Patrick Lismore, GopherJS
import "C" is used by cgo, which is used to call between Go and C; see  https://blog.golang.org/c-go-cgo .

Apaprently GopherJS does not support C code, which is not surprising.

Ian

Dmitri Shuralyov

unread,
Sep 11, 2016, 1:41:52 AM9/11/16
to GopherJS, patrick...@gmail.com
Hey Patrick,

Ian is right. GopherJS does not support cgo.

I've noticed that it's not actually documented anywhere, so I've filed an issue (https://github.com/gopherjs/gopherjs/issues/515) and made a PR (https://github.com/gopherjs/gopherjs/pull/516) to fix that.
Reply all
Reply to author
Forward
0 new messages