Browse Source

Add the pre-commit hooks and development instructions

kegan/github
Mark Haines 9 years ago
parent
commit
26f95fdeb8
  1. 25
      README.md
  2. 5
      hooks/install.sh
  3. 9
      hooks/pre-commit
  4. 2
      src/github.com/matrix-org/go-neb/api.go
  5. 2
      src/github.com/matrix-org/go-neb/goneb.go

25
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
```

5
hooks/install.sh

@ -0,0 +1,5 @@
#! /bin/bash
DOT_GIT="$(dirname $0)/../.git"
ln -s "../../hooks/pre-commit" "$DOT_GIT/hooks/pre-commit"

9
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

2
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"
)

2
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"

Loading…
Cancel
Save