diff --git a/README.md b/README.md index 2b4c24f..791e492 100644 --- a/README.md +++ b/README.md @@ -72,3 +72,28 @@ check that the server is still running. curl -X GET localhost:4050/test {} + +# Developing on go-neb. + +There's a bunch more tools this project uses when developing in order to do things like linting. Some of them are bundled with go (fmt and vet) but some are not. You should install the ones which are not: + +```bash +go get github.com/golang/lint/golint +go get github.com/fzipp/gocyclo +``` + +You can then install the pre-commit hook: + +```bash +./hooks/install.sh +``` + +## Viewing the API docs. + +``` +# Start a documentation server listening on :6060 +GOPATH=$GOPATH:$(pwd) godoc -v -http=localhost:6060 & + +# Open up the documentation for go-neb in a browser. +sensible-browser http://localhost/pkg/github.com/matrix-org/go-neb +``` diff --git a/hooks/install.sh b/hooks/install.sh new file mode 100755 index 0000000..f8aa331 --- /dev/null +++ b/hooks/install.sh @@ -0,0 +1,5 @@ +#! /bin/bash + +DOT_GIT="$(dirname $0)/../.git" + +ln -s "../../hooks/pre-commit" "$DOT_GIT/hooks/pre-commit" \ No newline at end of file diff --git a/hooks/pre-commit b/hooks/pre-commit new file mode 100755 index 0000000..d9ffbfb --- /dev/null +++ b/hooks/pre-commit @@ -0,0 +1,9 @@ +#! /bin/bash + +set -eu + +golint src/... +go fmt ./src/... +go tool vet --shadow ./src +gocyclo -over 12 src/ +gb test diff --git a/src/github.com/matrix-org/go-neb/api.go b/src/github.com/matrix-org/go-neb/api.go index 75d3319..a97ec7b 100644 --- a/src/github.com/matrix-org/go-neb/api.go +++ b/src/github.com/matrix-org/go-neb/api.go @@ -2,9 +2,9 @@ package main import ( "encoding/json" - "github.com/matrix-org/go-neb/errors" "github.com/matrix-org/go-neb/clients" "github.com/matrix-org/go-neb/database" + "github.com/matrix-org/go-neb/errors" "net/http" ) diff --git a/src/github.com/matrix-org/go-neb/goneb.go b/src/github.com/matrix-org/go-neb/goneb.go index 602a8ed..9143f45 100644 --- a/src/github.com/matrix-org/go-neb/goneb.go +++ b/src/github.com/matrix-org/go-neb/goneb.go @@ -4,8 +4,8 @@ import ( log "github.com/Sirupsen/logrus" "github.com/matrix-org/go-neb/clients" "github.com/matrix-org/go-neb/database" - _ "github.com/matrix-org/go-neb/services/echo" "github.com/matrix-org/go-neb/server" + _ "github.com/matrix-org/go-neb/services/echo" _ "github.com/mattn/go-sqlite3" "net/http" _ "net/http/pprof"