package naming conventions on the dashboard

118 views
Skip to first unread message

Petar Maymounkov

unread,
Mar 29, 2011, 8:52:14 AM3/29/11
to golang-nuts
Hi all,

I want to make a small appeal regarding how you name your Go dashboard
packages.

Some people name their packages like this:

(1) github.com/myname/mypkg

others name them like this

(2) mypkg

To clarify, the global name of packages is what you write in your
Makefile, not in your
go files. The go files always just say "package mypkg".

Naming convention (2) is bad. It is bad because it pollutes the global
namespace and no
other open-source developer could use the same pkg name in a project
that uses your
pkg as well. This will soon become a common problem, because pkg names
are usually
short words like "http", "file", "conf", "crypto", etc.

Beyond this, it is in your best interest to use (1) because it carries
your copyright information
much further:

When someone downloads an open source project and sees

import "github.com/yourname/yourpkg"

They know where to go get the package (and hence you will be more
popular).
On the other hand, if they see

import "yourpkg"

They may have no idea what this package is, if the open-source project
they
downloaded is poorly documented.

A step further, I think it should be part of "goinstall" to check that
this naming convention
is enforced.

There is a one small problem with convention (1), which is that it
makes it
hard to switch between open source repositories, say from "github.com"
to "googlecode.com".

But this is hardly as much of an issue, in my opinion. And if you want
this level
of freedom, you should have your own domain "myopensource.org" and
goinstall
should (eventually) have a way of using non-standard open source
repositories (if
it doesn't already).

Comments?

--P

Russ Cox

unread,
Mar 29, 2011, 9:46:45 AM3/29/11
to Petar Maymounkov, golang-nuts
> A step further, I think it should be part of "goinstall" to check that
> this naming convention is enforced.

Goinstall already does this, because this convention
(import path = URL of code hosting repository) is how
goinstall finds the package in the first place.

Russ

John Asmuth

unread,
Mar 29, 2011, 10:00:37 AM3/29/11
to golan...@googlegroups.com, Petar Maymounkov, r...@golang.org
The confusion there might be an assumption that goinstall uses the provided makefile.

People other than Russ: It does not - goinstall ignores the provided makefile, and creates its own.

Petar Maymounkov

unread,
Mar 29, 2011, 11:16:44 AM3/29/11
to golan...@googlegroups.com, John Asmuth, r...@golang.org
Oh .. this is the problem.

I often like to fetch the code manually and to a 'make && make install'
myself.

I see.

--P

Reply all
Reply to author
Forward
0 new messages