generated from WillAbides/goproject-tmpl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e1ff51e
Showing
18 changed files
with
384 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: ci | ||
on: [push] | ||
jobs: | ||
cibuild: | ||
name: cibuild | ||
runs-on: ubuntu-18.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-go@v2 | ||
with: | ||
go-version: '~1.14.0' | ||
- run: script/generate --check | ||
- run: script/test | ||
- run: script/lint |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
tmp/ | ||
bin/ | ||
.bindown/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# configure golangci-lint | ||
# see https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml | ||
issues: | ||
exclude-use-default: false | ||
exclude-rules: | ||
- path: _test\.go | ||
linters: | ||
- dupl | ||
- gosec | ||
- goconst | ||
linters: | ||
enable: | ||
- golint | ||
- gosec | ||
- interfacer | ||
- unconvert | ||
- gocyclo | ||
- goconst | ||
- goimports | ||
- gocritic | ||
- gofumpt | ||
linters-settings: | ||
gocritic: | ||
enabled-tags: | ||
- style | ||
- diagnostic | ||
- performance | ||
errcheck: | ||
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; | ||
# default is false: such cases aren't reported by default. | ||
check-blank: true | ||
govet: | ||
# report about shadowed variables | ||
check-shadowing: true | ||
gocyclo: | ||
# minimal code complexity to report, 30 by default | ||
min-complexity: 15 | ||
maligned: | ||
# print struct with more effective memory layout or not, false by default | ||
suggest-new: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2020 WillAbides | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
GOCMD=go | ||
GOBUILD=$(GOCMD) build | ||
PATH := "${CURDIR}/bin:$(PATH)" | ||
|
||
.PHONY: gobuildcache | ||
|
||
bin/golangci-lint: | ||
script/bindown install $(notdir $@) | ||
|
||
bin/shellcheck: | ||
script/bindown install $(notdir $@) | ||
|
||
bin/gobin: | ||
script/bindown install $(notdir $@) | ||
|
||
HANDCRAFTED_REV := 082e94edadf89c33db0afb48889c8419a2cb46a9 | ||
bin/handcrafted: bin/gobin | ||
GOBIN=${CURDIR}/bin \ | ||
bin/gobin github.com/willabides/handcrafted@$(HANDCRAFTED_REV) | ||
|
||
GOFUMPT_REV := 4fd085cb6d5fb7ec2bb2c6fc8039ec3a48355807 | ||
bin/gofumpt: bin/gobin | ||
GOBIN=${CURDIR}/bin \ | ||
bin/gobin mvdan.cc/gofumpt@$(GOFUMPT_REV) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# goproject-tmpl | ||
|
||
[![godoc](https://godoc.org/github.com/WillAbides/goproject-tmpl?status.svg)](https://godoc.org/github.com/WillAbides/goproject-tmpl) | ||
[![ci](https://github.com/WillAbides/goproject-tmpl/workflows/ci/badge.svg?branch=main&event=push)](https://github.com/WillAbides/goproject-tmpl/actions?query=workflow%3Aci+branch%3Amaster+event%3Apush) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
systems: | ||
- darwin/amd64 | ||
- linux/amd64 | ||
dependencies: | ||
gobin: | ||
template: origin#gobin | ||
vars: | ||
version: 0.0.14 | ||
golangci-lint: | ||
template: origin#golangci-lint | ||
vars: | ||
version: 1.28.2 | ||
shellcheck: | ||
template: origin#shellcheck | ||
vars: | ||
version: 0.7.1 | ||
templates: | ||
origin#gobin: | ||
url: https://github.com/myitcv/gobin/releases/download/v{{.version}}/{{.os}}-{{.arch}} | ||
archive_path: '{{.os}}-{{.arch}}' | ||
bin: gobin | ||
required_vars: | ||
- version | ||
systems: | ||
- darwin/386 | ||
- darwin/amd64 | ||
- freebsd/386 | ||
- freebsd/amd64 | ||
- freebsd/arm | ||
- linux/386 | ||
- linux/amd64 | ||
- linux/arm | ||
- netbsd/386 | ||
- netbsd/amd64 | ||
- netbsd/arm | ||
- openbsd/386 | ||
- openbsd/amd64 | ||
- windows/386 | ||
- windows/amd64 | ||
origin#golangci-lint: | ||
url: https://github.com/golangci/golangci-lint/releases/download/v{{.version}}/golangci-lint-{{.version}}-{{.os}}-{{.arch}}{{.urlsuffix}} | ||
archive_path: golangci-lint-{{.version}}-{{.os}}-{{.arch}}/golangci-lint{{.archivepathsuffix}} | ||
bin: golangci-lint | ||
link: true | ||
vars: | ||
archivepathsuffix: "" | ||
urlsuffix: .tar.gz | ||
required_vars: | ||
- version | ||
overrides: | ||
- matcher: | ||
os: | ||
- windows | ||
dependency: | ||
vars: | ||
archivepathsuffix: .exe | ||
urlsuffix: .zip | ||
systems: | ||
- darwin/386 | ||
- darwin/amd64 | ||
- linux/386 | ||
- linux/amd64 | ||
- linux/arm64 | ||
- windows/386 | ||
- windows/amd64 | ||
- freebsd/386 | ||
- freebsd/amd64 | ||
- linux/mips64 | ||
- linux/mips64le | ||
- linux/s390x | ||
- linux/ppc64le | ||
origin#shellcheck: | ||
url: https://github.com/koalaman/shellcheck/releases/download/v{{.version}}/shellcheck-v{{.version}}.{{.os}}.{{.arch}}.tar.xz | ||
archive_path: shellcheck-v{{.version}}/shellcheck | ||
bin: shellcheck | ||
required_vars: | ||
- version | ||
overrides: | ||
- matcher: | ||
os: | ||
- windows | ||
dependency: | ||
url: https://github.com/koalaman/shellcheck/releases/download/v{{.version}}/shellcheck-v{{.version}}.zip | ||
archive_path: shellcheck-v{{.version}}.exe | ||
substitutions: | ||
arch: | ||
amd64: x86_64 | ||
systems: | ||
- darwin/amd64 | ||
- linux/amd64 | ||
- windows/amd64 | ||
template_sources: | ||
origin: https://raw.githubusercontent.com/WillAbides/bindown-templates/master/bindown.yml | ||
url_checksums: | ||
https://github.com/golangci/golangci-lint/releases/download/v1.28.2/golangci-lint-1.28.2-darwin-amd64.tar.gz: 6e6952a4d72906f6265c379743f274b7609a289cc9cbb19bf6ff94e6f8f00daf | ||
https://github.com/golangci/golangci-lint/releases/download/v1.28.2/golangci-lint-1.28.2-linux-amd64.tar.gz: c893b07dd7d2c8e13b6380dd52781bb6732f7f541d90da2dc941be5f7e8be6fb | ||
https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.darwin.x86_64.tar.xz: b080c3b659f7286e27004aa33759664d91e15ef2498ac709a452445d47e3ac23 | ||
https://github.com/koalaman/shellcheck/releases/download/v0.7.1/shellcheck-v0.7.1.linux.x86_64.tar.xz: 64f17152d96d7ec261ad3086ed42d18232fcb65148b44571b564d688269d36c8 | ||
https://github.com/myitcv/gobin/releases/download/v0.0.14/darwin-amd64: 08db3d50eea308b475d591d43efc160c7c44f4666da4f2fd103864a9d038b230 | ||
https://github.com/myitcv/gobin/releases/download/v0.0.14/linux-amd64: 5bc800e8be7eaefcb86780786c38b75243082685a17ceea3c2235e06b8259151 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module github.com/willabides/goproject-tmpl | ||
|
||
go 1.14 | ||
|
||
require github.com/stretchr/testify v1.5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4= | ||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= | ||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package goprojecttmpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package goprojecttmpl | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestNothing(t *testing.T) { | ||
require.True(t, true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
CDPATH="" cd -- "$(dirname -- "$(dirname -- "$0")")" | ||
|
||
nwo="$GITHUB_REPOSITORY" | ||
if [ -z "$nwo" ]; then | ||
nwo=$(git remote get-url origin) | ||
nwo=${nwo#"git@github.com:"} | ||
nwo=${nwo#"https://github.com/"} | ||
nwo=${nwo%".git"} | ||
fi | ||
|
||
sedi() { | ||
if [ "Darwin" = "$(uname)" ]; then | ||
sed -i '' "$1" "$2" | ||
else | ||
sed -i "$1" "$2" | ||
fi | ||
} | ||
|
||
reponame=$(echo "$nwo" | cut -d "/" -f2) | ||
downcased_reponame="$(echo "$reponame" | tr '[:upper:]' '[:lower:]')" | ||
|
||
sedi "s|WillAbides/goproject-tmpl|$nwo|g" README.md | ||
sedi "s|goproject-tmpl|$reponame|g" README.md | ||
|
||
template_modulename="github.com/willabides/goproject-tmpl" | ||
modulename="$(echo "github.com/$nwo" | tr '[:upper:]' '[:lower:]')" | ||
sedi "s|$template_modulename|$modulename|g" go.mod | ||
|
||
template_pkgname="goprojecttmpl" | ||
pkgname="$(echo "$reponame" | tr '[:upper:]' '[:lower:]' | sed 's/-//g')" | ||
sedi "s|$template_pkgname|$pkgname|g" goproject-tmpl.go | ||
sedi "s|$template_pkgname|$pkgname|g" goproject-tmpl_test.go | ||
|
||
mv goproject-tmpl.go "$downcased_reponame.go" | ||
mv goproject-tmpl_test.go "${downcased_reponame}_test.go" | ||
|
||
script/update-repo-settings | ||
rm script/update-repo-settings | ||
|
||
rm script/apply-template |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
CDPATH="" cd -- "$(dirname -- "$(dirname -- "$0")")" | ||
|
||
mkdir -p bin | ||
|
||
[ -f bin/bindown ] || sh -c "$(curl -sfL https://github.com/WillAbides/bindown/releases/download/v3.3.3/bootstrap-bindown.sh)" | ||
|
||
exec bin/bindown "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
CDPATH="" cd -- "$(dirname -- "$(dirname -- "$0")")" | ||
|
||
make -s bin/gofumpt bin/handcrafted >/dev/null | ||
|
||
git ls-files -o -c --exclude-standard -- *.go **/*.go | | ||
bin/handcrafted | | ||
xargs bin/gofumpt -w -extra |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
CDPATH="" cd -- "$(dirname -- "$(dirname -- "$0")")" | ||
|
||
if [ "$1" = "--check" ]; then | ||
[ -z "$(git status --porcelain)" ] || { | ||
git status | ||
1>&2 echo "Running 'script/generate --check' requires a clean git working tree. Please commit or stash changes and try again." | ||
exit 1 | ||
} | ||
script/generate | ||
[ -z "$(git status --porcelain)" ] || { | ||
git status | ||
1>&2 echo "script/generate resulted in changes. Please commit changes (or 'git reset --hard HEAD' if you aren't ready to commit changes)." | ||
git diff | ||
exit 1 | ||
} | ||
exit 0 | ||
fi | ||
|
||
go generate ./... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
CDPATH="" cd -- "$(dirname -- "$(dirname -- "$0")")" | ||
|
||
make -s bin/golangci-lint bin/shellcheck | ||
bin/golangci-lint run ./... | ||
bin/shellcheck script/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
CDPATH="" cd -- "$(dirname -- "$(dirname -- "$0")")" | ||
|
||
go test -race -covermode=atomic ./... |
Oops, something went wrong.