├── .hound.yml ├── .travis.yml ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── bin ├── setup └── vet └── circle.yml /.hound.yml: -------------------------------------------------------------------------------- 1 | go: 2 | enabled: true 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # See https://robots.thoughtbot.com/configure-travis-ci-for-go 2 | language: go 3 | sudo: false 4 | before_script: 5 | - bin/vet 6 | install: 7 | # Add Godeps dependencies to GOPATH and PATH 8 | - export GOPATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace:$GOPATH" 9 | - export PATH="${TRAVIS_BUILD_DIR}/Godeps/_workspace/bin:$PATH" 10 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ============ 3 | 4 | We love pull requests from everyone. 5 | By participating in this project, 6 | you agree to abide by the thoughtbot [code of conduct]. 7 | 8 | [code of conduct]: https://thoughtbot.com/open-source-code-of-conduct 9 | 10 | We expect everyone to follow the code of conduct 11 | anywhere in thoughtbot's project codebases, 12 | issue trackers, chatrooms, and mailing lists. 13 | 14 | Fork the repo. 15 | 16 | Get a working [Go installation], 17 | and clone the project into your [Go work environment] 18 | (that is, `$GOPATH/src/github.com/thoughtbot/$(REPO_NAME)`). 19 | 20 | [Go installation]: http://golang.org/doc/install 21 | [Go work environment]: http://golang.org/doc/code.html 22 | 23 | Run `bin/setup` to install the project's dependencies. 24 | 25 | If you add or update a dependency, 26 | run `godep save ./...` to vendor the changes. 27 | 28 | To test the `$(REPO_NAME)` package, run `go test ./...`. 29 | 30 | Make your change, with new passing tests. 31 | 32 | Push to your fork. Write a [good commit message][commit]. Submit a pull request. 33 | 34 | [commit]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html 35 | 36 | Others will give constructive feedback. 37 | This is a time for discussion and improvements, 38 | and making the necessary changes will be required before we can 39 | merge the contribution. 40 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Bernerd Schaefer and thoughtbot, inc. 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Go template 2 | =========== 3 | 4 | This is a starting point for a new Go project. 5 | 6 | It provides: 7 | 8 | * a working [Travis CI configuration](.travis.yml) 9 | * a working [CircleCI configuration](circle.yml) 10 | * a minimal [Hound configuration](.hound.yml) 11 | * a [`bin/setup`](bin/setup) script compatible with godep 12 | * a [`bin/vet`](bin/vet) script for running in CI 13 | or as a pre-commit hook. 14 | * a [CONTRIBUTING.md](CONTRIBUTING.md) based on 15 | [thoughtbot/templates](https://github.com/thoughtbot/templates) 16 | with accurate instructions for Go development. 17 | 18 | Contributing 19 | ------------ 20 | 21 | We love pull requests from everyone. 22 | By participating in this project, 23 | you agree to abide by the thoughtbot [code of conduct]. 24 | 25 | [code of conduct]: https://thoughtbot.com/open-source-code-of-conduct 26 | 27 | We expect everyone to follow the code of conduct 28 | anywhere in thoughtbot's project codebases, 29 | issue trackers, chatrooms, and mailing lists. 30 | 31 | License 32 | ------- 33 | 34 | Go template is Copyright (c) 2015-2017 thoughtbot, inc. It is free software, 35 | and may be redistributed under the terms specified in the [LICENSE] file. 36 | 37 | [LICENSE]: /LICENSE 38 | 39 | About 40 | ----- 41 | 42 | Go template is maintained by [thoughtbot's Go development team]. 43 | 44 | ![thoughtbot](http://presskit.thoughtbot.com/images/thoughtbot-logo-for-readmes.svg) 45 | 46 | Go template is maintained and funded by thoughtbot, inc. 47 | The names and logos for thoughtbot are trademarks of thoughtbot, inc. 48 | 49 | We love open source software! 50 | See [our other projects][community] 51 | or [hire us][hire] to help build your product. 52 | 53 | [thoughtbot's Go development team]: 54 | [community]: https://thoughtbot.com/community?utm_source=github 55 | [hire]: https://thoughtbot.com/hire-us?utm_source=github 56 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | set -e 4 | 5 | # Install godep 6 | go get github.com/tools/godep 7 | 8 | # Restore dependencies from Godeps if they exist 9 | [[ -f ./Godeps/Godeps.json ]] && godep restore 10 | -------------------------------------------------------------------------------- /bin/vet: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # 3 | # validates that the project is clean of formatting and vet errors. 4 | # symlink as .git/hooks/pre-commit to use as a pre-commit check. 5 | # 6 | 7 | function checkfmt() { 8 | gofiles=$(find . ! -path "*/_*" -name "*.go" | grep -Fv "./vendor/") 9 | [ -z "$gofiles" ] && return 0 10 | 11 | unformatted=$(gofmt -l $gofiles) 12 | [ -z "$unformatted" ] && return 0 13 | 14 | echo >&2 "Go files must be formatted with gofmt. Please run:" 15 | for filename in $unformatted; do 16 | echo >&2 " gofmt -w $filename" 17 | done 18 | 19 | return 1 20 | } 21 | 22 | function checkvet() { 23 | unvetted=$(go vet $(go list ./... | grep -v /vendor/) 2>&1 | grep -v "exit status") 24 | [ -z "$unvetted" ] && return 0 25 | 26 | echo >&2 "Go files must be vetted. Check these problems:" 27 | IFS=$'\n' 28 | for line in $unvetted; do 29 | echo >&2 " $line" 30 | done 31 | unset IFS 32 | 33 | return 1 34 | } 35 | 36 | checkfmt || fail=yes 37 | checkvet || fail=yes 38 | 39 | [ -z "$fail" ] || exit 1 40 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | # See https://robots.thoughtbot.com/configure-circleci-for-go 2 | machine: 3 | environment: 4 | IMPORT_PATH: "github.com/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME" 5 | MYGOPATH: "$(echo $GOPATH | cut -d : -f 1)" 6 | 7 | dependencies: 8 | pre: 9 | - go get github.com/tools/godep 10 | 11 | override: 12 | - mkdir -p "$MYGOPATH/src/$IMPORT_PATH" 13 | - rsync -azC --delete ./ "$MYGOPATH/src/$IMPORT_PATH/" 14 | 15 | test: 16 | pre: 17 | - cd $MYGOPATH/src/$IMPORT_PATH && bin/vet 18 | 19 | override: 20 | - godep go test ./... 21 | --------------------------------------------------------------------------------