How to release binary library in go and organize source repository

392 views
Skip to first unread message

dlin

unread,
May 10, 2013, 12:23:26 AM5/10/13
to golan...@googlegroups.com
I try to build a library.
But, how to release it as binary library instead of source code?

GOPATH=/home/USER/go

I put source on /home/USER/prj/mylib/mylib.go  (I don't want put all project stuff in $GOPATH, because there contains other languages)
And make a symbolic link for it.
mkdir -p /home/USER/go/src/mycompany
ln -s /home/USER/prj/mylib/ /home/USER/go/src/mycompany/mylib

I can do 'go test' under  /home/USER/go/src/mycompany/mylib/

But, if I type 'go install' it response

go install: no install location for directory /home/USER/prj/mylib outside GOPATH

Any suggestion?

BTW, during google search, I found this URL, and the issue is accepted but not resolved for a year.
I suppose to harden released binary is important.

Tamás Gulácsi

unread,
May 10, 2013, 12:47:58 AM5/10/13
to golan...@googlegroups.com
Put the go source at $GOPATH/src/companydesignator/.../codelib - directly, or with symlink, maybe just the go source hierarchy.
And refer to the code as import "companydesignator/.../codelib"

That way go tools will find it.

Rodrigo Kochenburger

unread,
May 10, 2013, 1:56:47 AM5/10/13
to golan...@googlegroups.com
If you really don't want to use GOPATH, you can create your own build scripts by calling the compiler and linker directly.


That said, I strongly recommend adapting your project to conform to what the go tool expects. It will be much easier.

Dobrosław Żybort

unread,
May 10, 2013, 4:18:41 AM5/10/13
to golan...@googlegroups.com
You can use goxc for that.
It's cross compiler for Go (you can cc only if you don't use cgo).

https://github.com/laher/goxc#more-options
https://github.com/laher/goxc#outcome

By default, artifacts are generated and then immediately archived into (outputdir).
To set a destination root directory and artifact version number:

goxc -d=my/jekyll/site/downloads -pv=0.1.1

You can also use config files with goxc for faster repeatable builds
https://github.com/laher/goxc/wiki/config
 
Best regards,
Dobrosław Żybort

minux

unread,
May 10, 2013, 5:30:14 AM5/10/13
to dlin, golan...@googlegroups.com
On Fri, May 10, 2013 at 12:23 PM, dlin <dli...@gmail.com> wrote:
I try to build a library.
But, how to release it as binary library instead of source code?
simply put, releasing binary library without source code is not supported.

however, there is a hack. just put a dummy.go (with a correct package clause)
in corresponding source directory with mtime older than it's package.a file.

Dobrosław Żybort

unread,
May 10, 2013, 6:20:48 AM5/10/13
to golan...@googlegroups.com, dlin
Oh crap, I didn't read his mail properly. I thought he want to release main program binaries, not library.
Sorry about my previous mail.

I'm too tired today.
Reply all
Reply to author
Forward
0 new messages