package location in file system

136 views
Skip to first unread message

Norbert Roos

unread,
May 4, 2012, 12:39:48 PM5/4/12
to golan...@googlegroups.com
Hello,

Are there any recommendations where go packages should be installed in
the file system, like C libraries go into /lib or /usr/lib?

I would like to use a path independent of $GOPATH or $GOROOT..

Norbert

Kyle Lemons

unread,
May 4, 2012, 1:32:23 PM5/4/12
to Norbert Roos, golan...@googlegroups.com
What's your goal?  If you want it to be usable with other go packages, it'll have to be in GOPATH or GOROOT.  If you are devising some sort of dynamic loading scenario, I still think those would be good choices.  If you're talking about installing a binary for users to use, then the conventions of the operating system or the user's preferences should be respected (so probably /usr/local/bin if installed as root and not a part of a distro package, ~/bin if installed by a user). 

Paul Borman

unread,
May 4, 2012, 2:49:53 PM5/4/12
to Kyle Lemons, Norbert Roos, golan...@googlegroups.com
Here are the probably locations (depending on your system and sysadmin)

/opt/bin
/opt/local/bin
/usr/local/bin
/usr/contrib/bin
/usr/bin
/bin

I am sure there will be many "but we use /myplace/bin" out there as well.

Kyle has it right, though.  /usr/local/bin is the most likely but follow the convention of the system.

    -Paul

Thomas Bushnell, BSG

unread,
May 6, 2012, 11:49:17 AM5/6/12
to Norbert Roos, golan...@googlegroups.com

The File Hierarchy Standard.

Norbert Roos

unread,
May 7, 2012, 4:50:22 AM5/7/12
to golan...@googlegroups.com
On 05/04/2012 07:32 PM, Kyle Lemons wrote:

>> Are there any recommendations where go packages should be installed in the
>> file system, like C libraries go into /lib or /usr/lib?
>>
>> I would like to use a path independent of $GOPATH or $GOROOT..
>
>
> What's your goal?

I'm having two projects using mutual go packages. Prior to compiling
either of the projects, the go packages must be installed in the file
system somewhere. In the end, the two projects and the go packages
should each go into a separate deb package, with the projects depending
on the go packages deb package. For the deb file, the go packages need
to be in a fixed location.

Norbert

Norbert Roos

unread,
May 7, 2012, 4:54:36 AM5/7/12
to golan...@googlegroups.com
On 05/04/2012 08:49 PM, Paul Borman wrote:

> Here are the probably locations (depending on your system and sysadmin)
>
> /opt/bin
> /opt/local/bin
> ...

But the packages are not executables, they are libraries (to be linked
statically). So i would more expect something like /lib or /usr/lib.

The question is: Is it fine to put them right there, or do other
concepts exist, like /usr/lib/go/ specifically for go packages?

Norbert

Norbert Roos

unread,
May 7, 2012, 4:56:25 AM5/7/12
to golan...@googlegroups.com
On 05/06/2012 05:49 PM, Thomas Bushnell, BSG wrote:

> The File Hierarchy Standard.

It doesn't mention go packages. Is it ok to put them side-by-side to C
libraries in e.g. /usr/lib?

Norbert

Carlos Castillo

unread,
May 7, 2012, 12:03:40 PM5/7/12
to golan...@googlegroups.com
It's probably not a good idea to put go packages in a location where C libraries exist, because they can be easily mistaken for C libraries as they have the same file format (ELF on linux, PE on windows, MACH-O on darwin, etc...), and naming convention (*.a).

Go binary packages are for the most part a caching mechanism between go source code, and linking executables. They are not needed by compiled programs (as go-code is statically linked), and if you are building your own programs, you should have the source lying about in your GOPATH. They are also generally not binary compatible between go versions, and are rebuilt by the go-tool if the source code is changed. This behavior is generally inconsistent with how libraries in C are used.

Unless you are looking to provide proprietary packages written in go, it makes the most sense to use the conventions in place and use a public code hosting site, as your code will be usable by anyone on any platform go supports, and you will never need to mix the concerns of the go tool, your package manager, and your OS.
Reply all
Reply to author
Forward
0 new messages