News for hackers. Stuff that matters.
Re:Go 1.16 Release Notes by pansa2 on Tuesday February 16, 2021 @05:29PM (#26159579)
I’ve considered Go for writing command-line apps - mostly for conversion between domain-specific formats and standard ones (e.g. proprietary image format => png).

I think when considered in isolation, Go would be perfect for this. However, I haven’t used it because my existing code in this area is in C++ and I’m not sure how well the two languages interoperate.

Re:Go 1.16 Release Notes by _ph_ on Tuesday February 16, 2021 @05:37PM (#26159660)
Go interoperates pretty well with C - so you would have to create a thin C layer on top of your C++ code. This is one problem I constantly have with C++, it is pretty much its own world.

I have wrapped a large C++ library for Go it was a pretty straight forward process. I created a file with C callable functions that get passed pointers to the C++ objects and invoke the corresponding methods on that object. On the Go side pointer gets wrapped in a struct type for each C++ class and in the methods on that type I call the C functions. Works great.

Re:Go 1.16 Release Notes by pansa2 on Tuesday February 16, 2021 @05:54PM (#26159840)
> I have wrapped a large C++ library for Go

How well does it work the other way round - calling Go from C/C++? IIRC when I first looked into doing that, it wasn’t really possible - only threads that were started by Go could run Go code. In particular, `main` had to be in Go and couldn’t be in C++. Does that restriction still apply?

Re:Go 1.16 Release Notes by _ph_ on Tuesday February 16, 2021 @06:03PM (#26159952)
I have created shared libraries with Go which can be called from C, no problems. Those shared libraries can start their own goroutines quite fine and can call back into the C application. Usually it is a good idea to call back into the C application from the thread the Go function called from C was running.
Re:Go 1.16 Release Notes by eptcyka on Tuesday February 16, 2021 @06:30PM (#26160224)
Is there a way to bind a goroutine to a specific thread? Afaik, all C interop goes through a global lock because the runtime is weird.
Re:Go 1.16 Release Notes by pansa2 on Tuesday February 16, 2021 @06:35PM (#26160271)