I am working towards finishing a small project in go and my thoughts have turned to how I will package it up and release the code. The latest release of go has made some changes to goinstall so that code installed by you as a user can be kept separate from the base installation of go.
The first step in using goinstall is to create a directory structure for your local source, packages and binaries. This can be done like this
You can then create a GOPATH variable:
Now any go projects can be placed in the
directory and installed locally, you don’t even need to write makefiles.
Now create a file
in the directory:
Now this code can be installed locally making it available to your other go projects:
You can also create executable programs:
Create a file called
Install and run the program:
So no Makefiles are needed! I would still create Makefiles because you will need them if you want to use gotest to run your unit tests.