I want to build small module like dll and share with other developer. They will use it they can’t modify or vire code
Yes you can do like this
create a main.go file:
package main
import "C"
//export Add
func Add(a, b int) int {
return a + b
}
func main() {}
then build with
Linux:
go build -buildmode=c-shared -o mylib.so main.go
Windows:
go build -buildmode=c-shared -o mylib.dll main.go
macOS:
go build -buildmode=c-shared -o mylib.dylib main.go
Thank . How to use inside another golang application
You cannot. Binary-only package support was dropped after go1.12. Discussion is here
You can try and use plugins, but it’s not exactly the same as building binary package.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.