I’m writing a library in Go. I’m planning to distribute it, and with a main requirement of ’ without source codes '.
For testing, I have created two workspaces like following,
My first workspace (WS1) is the actual dummy library, which has some utility functions. Second workspace (WS2) has main function which uses the package (lib.a) from WS1.
Everything was working good until I remove the sources from WS1. If I remove the directory /lib/src.go in WS1, I’m getting the following error during go build,
main.go:5:2: cannot find package “lib” in any of: /usr/local/go/src/pkg/lib (from $GOROOT) …/Testing/ws1/src/lib (from $GOPATH)
The above message indicates us that we should keep the source files as well. Precompiled binary packages alone cannot be used directly .
Based on few suggestions online, we may keep some dummy sources with timestamp value lesser than binary packages’ timestamp. But, this doesn’t seems to be a feasible solution for us. What happens if timestamp of the dummy sources got updated unfortunately?
I have seen similar issue discussed here, https://github.com/golang/go/issues/2775
- Distributing the sources is the only possibility in Golang?
- Why Go is not providing a provision for using ‘.a’ files directly?
- If keeping the source is mandatory for Go, why this small thing is not mentioned anywhere in Go? (or) Am I missing something here?
Thanks in advance for your help guys!