And what about C++? I have code in C++, but all functions are
available to C. Only the code inside the functions is C++, and
the header file is pure C. So I can compile this separately into
a library, and link it with Go, and it works.
Is there a way to have Go and C (and C++) files in one package
that can be installed with just "go get packagename"?
I know I can put all C code as a comment in a Go file, directly
above 'import "C"', but for large C files, I don't think that is
practical.
Take a look at:
https://github.com/mattn/go-v8
It compiles a small c++ library exposing a C interface and then use
CGO to compile the go package using the created C library.
I don't tested this package yet so don't know if it will compile in
the latest release.
"go get ...." can handle custom build steps, for such cases make is
your friend :)
--
André Moraes
http://andredevchannel.blogspot.com/
> Is there a way to have Go and C (and C++) files in one packageTake a look at:
> that can be installed with just "go get packagename"?
https://github.com/mattn/go-v8
It compiles a small c++ library exposing a C interface and then use
CGO to compile the go package using the created C library.
I don't tested this package yet so don't know if it will compile in
the latest release.
"go get ...." can handle custom build steps, for such cases make is
your friend :)
Typo here, the correct is:
"go get ...." can't handle custom build steps, for such cases make is
your friend :)
--
André Moraes
http://andredevchannel.blogspot.com/
The Makefile don't use anything special that would require gomake, so
the user can call vanilla "make" and build the required library.
>> https://github.com/mattn/go-v8The Makefile don't use anything special that would require gomake, so
>>
>> It compiles a small c++ library exposing a C interface and then use
>> CGO to compile the go package using the created C library.
>>
>> I don't tested this package yet so don't know if it will compile in
>> the latest release.
>
> We don't have gomake in Go 1.
the user can call vanilla "make" and build the required library.
Yes
> Ian has a pending change previously to support swig in the go tool.
> https://groups.google.com/d/msg/golang-dev/4Kaa2FahPrQ/huS0JNKMiicJ
> http://codereview.appspot.com/4287056/
>
> If/When this goes in, will it handle the OP's use-case?
I don't think so.
Ian