-
For the package
newmathit’s the same as (later 2.)$ mkdir $GOPATH/src/github.com/username/newmath $ cd $GOPATH/src/github.com/username/newmath $ git init $ ... more git setup $ touch sqrt.go $ gvim sqrt.go $ git add sqrt.go $ git commit -a -m 'Inital commit' $ git pushNow people can do
$ go get github.com/username/newmathand
import "github.com/username/newmath"should now work in their sources. The package will be installed on
demand automatically. -
I’ll assume that the
hellocommand and thenewmathpackage are
not related, or not enough tightly related to belong to a single
repository.$ mkdir $GOPATH/src/github.com/username/hello $ cd $GOPATH/src/github.com/username/hello $ git init $ ... more git setup $ touch hello.go $ gvim hello.go $ git add hello.go $ git commit -a -m 'Inital commit' $ git pushNow people can do
$ go get github.com/username/hello $ go install github.com/username/helloto install your command
hello. -
- It makes almost no sense to publish the content of
$GOPATH/pkgat
the hosting service. - It makes some sense to publish the content of
$GOPATH/binat the hosting service. But I discourage this practice for obvious
reasons. Additionally, if you’re publishing the sources – the
binaries are not necessary and everybody can build their (trusted)
own.
- It makes almost no sense to publish the content of
You seem to be perhaps still a bit confused by the term ‘workspace’. A workspace is quite often existing only once at the developer’s machine, yet it the typically contains several repositories. Some authored by the developer, others “go getted” from the Internet. To publish a whole wokspace in this case makes little sense.
However, there are people using a separate workspace per project or per repository or maybe even per package. I don’t know what the benefits are. Or better said, I think that there are none compared to the single workspace, defined by, say export GOPATH=$HOME (as is my case for years w/o any trouble with it for years).