From c41009f1d01c9023f951043a001617aa405f8b16 Mon Sep 17 00:00:00 2001 From: Nhat Date: Tue, 20 Jul 2021 21:39:00 +0200 Subject: [PATCH] Initial commit --- .github/workflows/golangci-lint.yaml | 38 ++++++++++++++++++ .github/workflows/test.yaml | 60 ++++++++++++++++++++++++++++ .gitignore | 17 ++++++++ .golangci.yaml | 47 ++++++++++++++++++++++ LICENSE | 21 ++++++++++ Makefile | 25 ++++++++++++ README.md | 42 +++++++++++++++++++ codecov.yml | 2 + doc.go | 2 + go.mod | 3 ++ 10 files changed, 257 insertions(+) create mode 100644 .github/workflows/golangci-lint.yaml create mode 100644 .github/workflows/test.yaml create mode 100644 .gitignore create mode 100644 .golangci.yaml create mode 100644 LICENSE create mode 100644 Makefile create mode 100644 README.md create mode 100644 codecov.yml create mode 100644 doc.go create mode 100644 go.mod diff --git a/.github/workflows/golangci-lint.yaml b/.github/workflows/golangci-lint.yaml new file mode 100644 index 0000000..a24eeb7 --- /dev/null +++ b/.github/workflows/golangci-lint.yaml @@ -0,0 +1,38 @@ +name: lint +on: + push: + tags: + - v* + branches: + - master + - main + pull_request: +jobs: + golangci: + name: golangci-lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2.5.1 + with: + # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + version: v1.39.0 + + # Optional: working directory, useful for monorepos + # working-directory: somedir + + # Optional: golangci-lint command line arguments. + # args: --issues-exit-code=0 + + # Optional: show only new issues if it's a pull request. The default value is `false`. + # only-new-issues: true + + # Optional: if set to true then the action will use pre-installed Go. + # skip-go-installation: true + + # Optional: if set to true then the action don't cache or restore ~/go/pkg. + # skip-pkg-cache: true + + # Optional: if set to true then the action don't cache or restore ~/.cache/go-build. + # skip-build-cache: true diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 0000000..996a245 --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,60 @@ +name: test + +on: + push: + branches: + - master + pull_request: + +env: + GO111MODULE: "on" + GO_LATEST_VERSION: "1.16.x" + +jobs: + test: + strategy: + fail-fast: false + matrix: + os: [ ubuntu-latest, macos-latest ] + go-version: [ 1.15.x, 1.16.x ] + runs-on: ${{ matrix.os }} + steps: + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Go cache + uses: actions/cache@v2 + with: + # In order: + # * Module download cache + # * Build cache (Linux) + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: ${{ runner.os }}-go-${{ matrix.go-version }}-cache-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go-${{ matrix.go-version }}-cache + + - name: Test + id: test + run: | + make test + + - name: Upload code coverage (unit) + if: matrix.go-version == env.GO_LATEST_VERSION + uses: codecov/codecov-action@v1 + with: + file: ./unit.coverprofile + flags: unittests-${{ runner.os }} + +# - name: Upload code coverage (features) +# if: matrix.go-version == env.GO_LATEST_VERSION +# uses: codecov/codecov-action@v1 +# with: +# file: ./features.coverprofile +# flags: featurestests-${{ runner.os }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..04bd755 --- /dev/null +++ b/.gitignore @@ -0,0 +1,17 @@ +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +/vendor + +*.coverprofile diff --git a/.golangci.yaml b/.golangci.yaml new file mode 100644 index 0000000..e490ad1 --- /dev/null +++ b/.golangci.yaml @@ -0,0 +1,47 @@ +# See https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml +run: + tests: true + +linters-settings: + errcheck: + check-type-assertions: true + check-blank: true + gocyclo: + min-complexity: 20 + dupl: + threshold: 100 + misspell: + locale: US + unused: + check-exported: false + unparam: + check-exported: true + +linters: + enable-all: true + disable: + - lll + - maligned + - gochecknoglobals + - gomnd + - wrapcheck + - paralleltest + - forbidigo + - exhaustivestruct + - interfacer + - forcetypeassert + - ifshort + - testpackage + - gci + +issues: + exclude-use-default: false + exclude-rules: + - linters: + - gomnd + - goconst + - goerr113 + - noctx + - funlen + - dupl + path: "_test.go" diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..9b95921 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2021 Nhat + +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. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..7c36fca --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +VENDOR_DIR = vendor + +GO ?= go +GOLANGCI_LINT ?= golangci-lint + +.PHONY: $(VENDOR_DIR) lint test test-unit + +$(VENDOR_DIR): + @mkdir -p $(VENDOR_DIR) + @$(GO) mod vendor + @$(GO) mod tidy + +lint: + @$(GOLANGCI_LINT) run + +test: test-unit + +## Run unit tests +test-unit: + @echo ">> unit test" + @$(GO) test -gcflags=-l -coverprofile=unit.coverprofile -covermode=atomic -race ./... + +#test-integration: +# @echo ">> integration test" +# @$(GO) test ./features/... -gcflags=-l -coverprofile=features.coverprofile -coverpkg ./... -godog -race diff --git a/README.md b/README.md new file mode 100644 index 0000000..e363b3c --- /dev/null +++ b/README.md @@ -0,0 +1,42 @@ +# @nhatthm/{name} + + + +TBD + +## Prerequisites + +- `Go >= 1.15` + +## Install + +```bash +go get github.com/nhatthm/{name} +``` + +## Usage + +TBD + +## Examples + +TBA + +## Donation + +If this project help you reduce time to develop, you can give me a cup of coffee :) + +### Paypal donation + +[![paypal](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif)](https://www.paypal.com/donate/?hosted_button_id=PJZSGJN57TDJY) + +       or scan this + + diff --git a/codecov.yml b/codecov.yml new file mode 100644 index 0000000..70917de --- /dev/null +++ b/codecov.yml @@ -0,0 +1,2 @@ +ignore: + - "features/**/*" diff --git a/doc.go b/doc.go new file mode 100644 index 0000000..8c6c334 --- /dev/null +++ b/doc.go @@ -0,0 +1,2 @@ +// Package main +package main diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..0410ecf --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/nhatthm/template-go-project + +go 1.16