add Travis CI, and pre-commit hooks
This commit is contained in:
1 parent
325a21f38d
commit
8d951f617b
3 files changed
+58
-11
No files matched your search
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
|
||||
GOFMT_FILES=$(gofmt -l .)
|
||||
if [ -n "${GOFMT_FILES}" ]; then
|
||||
printf >&2 'gofmt failed for the following files:\n%s\n\nplease run "gofmt -w ." on your changes before committing.\n' "${GOFMT_FILES}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GOLINT_ERRORS=$(golint ./... | grep -v "Id should be")
|
||||
if [ -n "${GOLINT_ERRORS}" ]; then
|
||||
printf >&2 'golint failed for the following reasons:\n%s\n\nplease run "golint ./..." on your changes before committing.\n' "${GOLINT_ERRORS}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
GOVET_ERRORS=$(go tool vet *.go 2>&1)
|
||||
if [ -n "${GOVET_ERRORS}" ]; then
|
||||
printf >&2 'go vet failed for the following reasons:\n%s\n\nplease run "go tool vet *.go" on your changes before committing.\n' "${GOVET_ERRORS}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#if [ -z "${NOTEST}" ]; then
|
||||
# printf >&2 'Running short tests...\n'
|
||||
# env GOTEST_ERRORS= go test -short -v | egrep 'PASS|ok'
|
||||
#
|
||||
# if [ $? -ne 0 ]; then
|
||||
# printf >&2 'go test failed, please fix before committing.\n'
|
||||
# exit 1
|
||||
# fi
|
||||
#fi
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
language: go
|
||||
go:
|
||||
- 1.8.x
|
||||
- 1.9.x
|
||||
- tip
|
||||
|
||||
before_install:
|
||||
- go get -u -v github.com/spf13/pflag github.com/spf13/viper github.com/ahmetb/govvv github.com/golang/lint/golint
|
||||
|
||||
script:
|
||||
- ./.pre-commit.sh
|
||||
- govvv build
|
||||
@@ -13,17 +13,25 @@ import (
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// AppName is the canonical name of this program
|
||||
const AppName = "Go-Fiche"
|
||||
|
||||
const slugMap = "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz0123456789"
|
||||
|
||||
var (
|
||||
GitCommit,
|
||||
GitBranch,
|
||||
GitState,
|
||||
BuildDate,
|
||||
Version string
|
||||
)
|
||||
// GitCommit holds the git commit message on compile time
|
||||
var GitCommit string
|
||||
|
||||
// GitBranch holds the active git branch on compile time
|
||||
var GitBranch string
|
||||
|
||||
// GitState holds the dirty-state on compile time
|
||||
var GitState string
|
||||
|
||||
// BuildDate date of compile
|
||||
var BuildDate string
|
||||
|
||||
// Version version string as contained in VERSION
|
||||
var Version string
|
||||
|
||||
func init() {
|
||||
pflag.BoolP("help", "h", false, "Prints this help message")
|
||||
@@ -66,8 +74,6 @@ func main() {
|
||||
}
|
||||
go handleConnection(conn)
|
||||
}
|
||||
time.Sleep(5)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func generateSlug(seed int64) string {
|
||||
@@ -119,10 +125,10 @@ func handleConnection(conn net.Conn) {
|
||||
log.Printf("0 bytes received, aborting...")
|
||||
os.Remove(slugFullpath)
|
||||
return
|
||||
} else {
|
||||
file.Close()
|
||||
}
|
||||
|
||||
file.Close()
|
||||
|
||||
log.Printf("Wrote %d bytes to %s", stat.Size(), slugFullpath)
|
||||
|
||||
conn.Write([]byte(fmt.Sprintf("%s://%s/%s\r\n", viper.GetString("uriprefix"), viper.GetString("domain"), slug)))
|
||||
|
||||
Reference in new issue
Block a user