Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sters committed Jun 17, 2021
0 parents commit a375041
Show file tree
Hide file tree
Showing 14 changed files with 1,303 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .github/ISSUE_TEMPLATE/create-new-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
name: IssueTemplate
about: 'Create a new issue'
title: ''
labels: ''
assignees: ''

---

## WHY

## WHAT
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "gomod" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
25 changes: 25 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Go
on:
push:
branches:
- "*"
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- run: make bootstrap-tools
- run: make lint
- run: make cover

- uses: codecov/codecov-action@v1
29 changes: 29 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Release
on:
push:
branches:
- "!*"
tags:
- "v*.*.*"
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.16
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# 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/
bin/
26 changes: 26 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
run:
skip-dirs:
- bin

linters-settings:
golint:
min-confidence: 0
govet:
check-shadowing: true

linters:
enable:
- gocritic
- gofmt
- goimports
- golint
- gosec
- misspell
- scopelint

issues:
exclude-rules:
# Exclude shadow checking on the variable named err
- text: "shadow: declaration of \"err\""
linters:
- govet
11 changes: 11 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- darwin
- windows
goarch:
- 386
- amd64
main: ./cmd/command/main.go
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 sters

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.
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

export GOBIN := $(PWD)/bin
export PATH := $(GOBIN):$(PATH)

TOOLS=$(shell cat tools/tools.go | egrep '^\s_ ' | awk '{ print $$2 }')

.PHONY: bootstrap-tools
bootstrap-tools:
@echo "Installing: " $(TOOLS)
@go install $(TOOLS)

.PHONY: run
run:
go run cmd/command/main.go

.PHONY: lint
lint:
golangci-lint run -v ./...
go-consistent -v ./...

.PHONY: lint-fix
lint-fix:
golangci-lint run --fix -v ./...

.PHONY: test
test:
go test -v -race ./...

.PHONY: cover
cover:
go test -v -race -coverpkg=./... -coverprofile=coverage.txt ./...

.PHONY: tidy
tidy:
go mod tidy
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# go-project-boilerplate

[![go](https://github.com/sters/go-project-boilerplate/workflows/Go/badge.svg)](https://github.com/sters/go-project-boilerplate/actions?query=workflow%3AGo)
[![codecov](https://codecov.io/gh/sters/go-project-boilerplate/branch/main/graph/badge.svg)](https://codecov.io/gh/sters/go-project-boilerplate)
[![go-report](https://goreportcard.com/badge/github.com/sters/go-project-boilerplate)](https://goreportcard.com/report/github.com/sters/go-project-boilerplate)

My go project boilerplate.

## Includes

- Makefile
- run
- test
- cover
- Tools install from `./tools/tools.go`
- Github Actions
- Go
- Lint by golangcilint
- Run test and upload test coverage to codecov
- Release
- Make release when vX.X.X tag is added by goreleaser.
- README
- Badge: Github Actions/Go
- Badge: Codecov
- Badge: Go Report

## TODO when use this

- [ ] Change `cmd/xxxxx` directory name
- [ ] Change run task in `Makefile`
- [ ] Change package name in `go.mod`
- [ ] Change main in `.goreleaser.yml`
- [ ] Update `README.md`
7 changes: 7 additions & 0 deletions cmd/command/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package main

import "fmt"

func main() {
fmt.Println("Hello World!")
}
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/sters/go-project-boilerplate

go 1.16

require (
github.com/golangci/golangci-lint v1.40.1
github.com/quasilyte/go-consistent v0.0.0-20190521200055-c6f3937de18c
)
Loading

0 comments on commit a375041

Please sign in to comment.