From 4f71f9f3c3a77e612f7b5099790d3985c502a6ef Mon Sep 17 00:00:00 2001 From: Guillermo Guerrero Date: Tue, 21 Jun 2016 00:37:57 +0200 Subject: [PATCH] Added main test. Trying goxc. --- .goxc.json | 15 +++++++++++++++ .travis.yml | 10 ++++++---- main.go | 17 +++++++++++++---- 3 files changed, 34 insertions(+), 8 deletions(-) create mode 100644 .goxc.json diff --git a/.goxc.json b/.goxc.json new file mode 100644 index 0000000..bd44c70 --- /dev/null +++ b/.goxc.json @@ -0,0 +1,15 @@ +{ + "AppName": "share", + "PackageVersion": "0.0.1", + "ArtifactsDest": "./dist", + "Tasks": [ + "go-vet", + "go-fmt", + "go-install", + "go-clean" + ], + "ConfigVersion": "0.9", + "Env": [ + "SHARE_MODE=release" + ] +} diff --git a/.travis.yml b/.travis.yml index 7f21fdf..74dbd45 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,12 +13,13 @@ matrix: - go: tip before_install: - - sudo apt-get install -qy libc6-dev-i386 - go get github.com/mattn/goveralls - go get golang.org/x/tools/cmd/cover - - go get github.com/mitchellh/gox - go get github.com/modocache/gover - - go get github.com/inconshreveable/mousetrap + - go get github.com/laher/goxc +# - sudo apt-get install -qy libc6-dev-i386 +# - go get github.com/mitchellh/gox +# - go get github.com/inconshreveable/mousetrap # - go get github.com/tcnksm/ghr install: @@ -35,6 +36,7 @@ script: - goveralls -coverprofile=gover.coverprofile -service travis-ci after_success: - - gox -cgo -output "dist/{{.OS}}_{{.Arch}}_{{.Dir}}" + - goxc +# - gox -cgo -output "dist/{{.OS}}_{{.Arch}}_{{.Dir}}" # - ghr -t $GITHUB_TOKEN -u $CIRCLE_PROJECT_USERNAME -r $CIRCLE_PROJECT_REPONAME --replace `git describe --tags` dist/ # - ghr --username tcnksm-sample --token $GITHUB_TOKEN --replace --prerelease --debug pre-release dist/ diff --git a/main.go b/main.go index 221bc79..28139fe 100644 --- a/main.go +++ b/main.go @@ -6,17 +6,26 @@ import ( log "github.com/Sirupsen/logrus" "github.com/devcows/share/cmd" + "github.com/gin-gonic/gin" ) func main() { // Log as JSON instead of the default ASCII formatter. log.SetFormatter(&log.JSONFormatter{}) - // Output to stderr instead of stdout, could also be a file. - log.SetOutput(os.Stderr) + if os.Getenv("SHARE_MODE") == "release" { + // Only log the warning severity or above. + log.SetLevel(log.WarnLevel) + gin.SetMode(gin.ReleaseMode) - // Only log the warning severity or above. - log.SetLevel(log.InfoLevel) + //TODO: Output to file instead of stdout. + //log.SetOutput(os.Stderr) + } else { + log.SetLevel(log.DebugLevel) + + // Output to stderr instead of stdout, could also be a file. + log.SetOutput(os.Stderr) + } if err := cmd.RootCmd.Execute(); err != nil { fmt.Println(err)