If/when we ever set up an Akaros organization on github to host our
various Akaros related repos (I know there is some opposition to this
for some reason), I'll move it there. I have 2 or three other repos
that would fit nicely there as well.
--
~Kevin
In general, 'go build' will try and build whatever package you tell it
to, and if that package builds an executable (i.e. it has a package
'main'), then it will drop a copy of that executable in the current
directory with the same name as the package you are building. In your
case, I'm assuming you are sitting in the
$GOPATH/src/github.com/klueska/gonetp directory and trying to run this
command. As such, it will try and place an executable at this
location named 'gonetp-server'. Since you already have a folder there
by that name, it's throwing errors. What you really want is 'go
install', which will do the same thing as 'go build', except install
the executable into the 'bin' directory of the GOPATH, rather than the
current directory.
In general, 'go build' and 'go install' will recognize ANY path you
pass it as a path relative to the 'src' directory in GOPATH. The name
'github.com' is not necessarily special (it's just the convention used
by 'go get' when installing packages). You could just as easily
create your own project directly under $GOPATH/src/ and everything
would work the same.
That being said, you probably don't want to have to specify the whole
'github.com/klueska/gonetp/gonetp-server' path every time you want to
build and install your package. The go tools allow you to have a
(somewhat) normal workflow to modify the code, build it, and have it
installed -- you just have to know the right incantations. You have
to be explicit about the fact that you want go to build/install things
from somewhere other than the GOPATH.
For example, the following should work:
cd $GOPATH/src/github.com/klueska/gonetp/gonetp-server
... hack away ...
go install
This says build the package in the current directory and install it
into the GOPATH. By not passing any path at all, go know to run 'go
install' over all of the files from the current directory instead of
something relative to the GOPATH. 'go build' would actually work here
as well, but (as before), it would create a local executable (called
'main' this time because the file is called 'main.go'), instead of
installing it into the GOPATH. Probably not what you want.
The following should work as well:
cd $GOPATH/src/github.com/klueska/gonetp/
go install ./gonetp-server
The './' is important so that go recognizes the thing you are trying
to build is in a folder relative to the current directory, rather
relative to the GOPATH.
To rebuild all of the code bundled in this repo, would require the following:
cd $GOPATH/src/github.com/klueska/gonetp/
go install ./gonetp-server
go install ./gonetp-client
go install ./utilization
As a side note, 'go install' and 'go build' are identical for the
'utilization' package because it doesn't have a 'main' package (i.e.
no executable will result from building it). No matter which command
you run, it will be installed in $GOPATH/pkg
--
~Kevin
--
~Kevin
// +build akaros
directive at the top of the file. That should do the trick.
--
~Kevin
It's actually because I mistakenly put the copyright notice in c-style
comments /* */. The copyright should be in go style comments //. If
the copyright was in go style comments (which it actually should be),
then the build directive could go below it. The c-style comments are
valid because that is where you typically put Cgo variables and
functions. As such, the build directive needs to come before it.
I was thinking of changing the copyright notices anyway. It's better
practice to have a short 3 liner with the copyright line, the author,
and a pointer to a LICENSE file. The LICENSE file can then hold all
the info currently below the author line in the notice.
Kevin
--
~Kevin