Please read this if you intend to develop on gsctl.
- Go environment (
brew install go
). Check theGOVERSION
variable in theMakefile
for the required version. - GNU Make
git
- Docker
Make sure you have the $GOPATH
environment variable set.
$ echo $GOPATH
/Users/johndoe/go
Go to right location, then check out:
$ mkdir -p $GOPATH/src/github.com/giantswarm
$ cd $GOPATH/src/github.com/giantswarm
$ git clone https://github.com/giantswarm/gsctl.git
$ cd gsctl
So the repo content will end up in $GOPATH/src/github.com/giantswarm/gsctl
.
Dependencies are managed using the Go modules tooling.
This means the GO111MODULE
environment variable has to be set to auto
or yes
.
One option is to execute the program via go run
, like in this example:
# ensure packr binary is up-to-date
$ packr
$ go run main.go info
Or you can first build a binary and then execute it.
$ go build && ./gsctl info
To build a binary for your platform like the release build would do, do this:
$ make clean
$ make
$ make install
The Makefile
provides a few shortcuts.
To execute all Go unit tests:
make gotest
To quickly run a number of commands:
make test
For the sso
command, gsctl needs to run a local webserver and show nicely formated
html to the user. These html files are found in this folder.
The files get compiled into a binary file in the oidc
package
by running the packr
command.
To learn more about packr
, visit: https://github.com/gobuffalo/packr
Before pushing any changes, please:
- Let
gofmt
format your code - Do a
golint .
check and act on recommendations before pushing.
See Command Blueprint for a scaffold of a command file.
We use specific error objects and dedicated matcher functions to assert them. Example:
var NotLoggedInError = errgo.New("user not logged in")
// IsNotLoggedInError asserts NotLoggedInError.
func IsNotLoggedInError(err error) bool {
return errgo.Cause(err) == NotLoggedInError
}
See RELEASE.md