Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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,

WS1

  • bin/
  • pkg/linux_amd64/lib.a
  • src/lib/src.go

WS2

  • bin/
  • pkg/
  • src/main/main.go

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

My Questions:

  1. Distributing the sources is the only possibility in Golang?

  2. Why Go is not providing a provision for using '.a' files directly?

  3. 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!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
776 views
Welcome To Ask or Share your Answers For Others

1 Answer

Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...