I am writing an application in Go. However on every platform my code will utilize external program compiled from another project in another language (e.g. C++ in Windows, Objective-C for Mac etc). This external executable is called with os/exec
exec.Command
function.
I can package my software with no problem, however one issue persists is that using go run
will result in this file missing.
Is there a way to tell go
that it should include external file (and preferably also build it from source) whenever I do $ go run myproj
?
AFAIK, go run
simply builds binary under a tmp directory, however it won't include any external files such as images etc. So for example when you have two files: $GOPATH/src/main/main.go
and $GOPATH/ext-tool.bin
and main.go
content is:
package main
import "os/exec"
func main() {
cmd := exec.Command("./ext-tool.bin")
err := cmd.Run()
if err != nil {
os.Exit(1)
}
}