Skip to content

Commit 67bb3be

Browse files
committed
first commit
0 parents  commit 67bb3be

File tree

8 files changed

+329
-0
lines changed

8 files changed

+329
-0
lines changed

.editorconfig

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
trim_trailing_whitespace = true
7+
insert_final_newline = true
8+
indent_size = 4
9+
indent_style = space
10+
11+
[*.go]
12+
indent_style = tab
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+
17+
[*.{html,js,json,jsx,proto,scss,sh,sql,toml,ts,tsx,vue,xml,yaml,yml}]
18+
indent_size = 2
19+
20+
[Makefile]
21+
indent_style = tab

.github/workflows/release.yml

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: "Create Release"
2+
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
8+
env:
9+
SLACK_COLOR_FAILED: "#a92d2e"
10+
SLACK_COLOR: "#32bd77"
11+
SLACK_ICON: "https://github.com/github.png"
12+
SLACK_USERNAME: "GitHub Actions"
13+
14+
jobs:
15+
release:
16+
name: "Build Container"
17+
runs-on: "ubuntu-latest"
18+
steps:
19+
- uses: "actions/checkout@v2"
20+
21+
- name: "Get app version"
22+
run: |
23+
echo "APP_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
24+
25+
- name: "Create release"
26+
id: "create-release"
27+
uses: "actions/[email protected]"
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
with:
31+
draft: ${{ contains(env.APP_VERSION, '-dev') }}
32+
prerelease: ${{ contains(env.APP_VERSION, '-dev') }}
33+
release_name: Release ${{ env.APP_VERSION }}
34+
tag_name: ${{ env.APP_VERSION }}
35+
36+
- name: "Slack Notification on success"
37+
if: "success()"
38+
uses: "8398a7/action-slack@v3"
39+
env:
40+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
41+
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK }}"
42+
with:
43+
status: "custom"
44+
custom_payload: |
45+
{
46+
username: '${{ env.SLACK_USERNAME }}',
47+
channel: '${{ secrets.SLACK_CHANNEL }}',
48+
"icon_url": '${{ env.SLACK_ICON }}',
49+
text: 'Workflow [${{ github.workflow }}] is successful.',
50+
attachments: [{
51+
"author_name": "${{ github.actor }}",
52+
"author_link": "http://github.com/${{ github.actor }}",
53+
"author_icon": "http://github.com/${{ github.actor }}.png?size=32",
54+
color: '${{ env.SLACK_COLOR }}',
55+
fields: [{
56+
title: 'Ref',
57+
value: '${{ github.ref }}',
58+
short: true
59+
}, {
60+
title: 'Event',
61+
value: '${{ github.event_name }}',
62+
short: true
63+
}, {
64+
title: 'Actions URL',
65+
value: 'https://github.com/${{ github.repository }}/actions',
66+
short: false
67+
}, {
68+
title: 'Release URL',
69+
value: 'https://github.com/${{ github.repository }}/releases/tag/${{ github.ref }}',
70+
short: false
71+
}]
72+
}]
73+
}
74+
75+
- name: "Slack Notification on failure"
76+
if: "failure()"
77+
uses: "8398a7/action-slack@v3"
78+
env:
79+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
80+
SLACK_WEBHOOK_URL: "${{ secrets.SLACK_WEBHOOK }}"
81+
with:
82+
status: "custom"
83+
custom_payload: |
84+
{
85+
username: '${{ env.SLACK_USERNAME }}',
86+
channel: '${{ secrets.SLACK_CHANNEL }}',
87+
"icon_url": '${{ env.SLACK_ICON }}',
88+
text: 'Workflow [${{ github.workflow }}] is failure.',
89+
attachments: [{
90+
"author_name": "${{ github.actor }}",
91+
"author_link": "http://github.com/${{ github.actor }}",
92+
"author_icon": "http://github.com/${{ github.actor }}.png?size=32",
93+
color: '${{ env.SLACK_COLOR_FAILED }}',
94+
fields: [{
95+
title: 'Ref',
96+
value: '${{ github.ref }}',
97+
short: true
98+
}, {
99+
title: 'Event',
100+
value: '${{ github.event_name }}',
101+
short: true
102+
}, {
103+
title: 'Actions URL',
104+
value: 'https://github.com/${{ github.repository }}/actions',
105+
short: false
106+
}]
107+
}]
108+
}

.golangci.yml

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# see: https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml
2+
run:
3+
timeout: "1m"
4+
skip-dirs:
5+
- "build"
6+
- "docs"
7+
- "scripts"
8+
tests: false
9+
10+
linters-settings:
11+
dupl:
12+
threshold: 100
13+
gocognit:
14+
min-complexity: 20
15+
goconst:
16+
min-len: 3
17+
min-occurrences: 3
18+
gocyclo:
19+
min-complexity: 10
20+
lll:
21+
line-length: 80
22+
tab-width: 4
23+
maligned:
24+
suggest-new: true
25+
nakedret:
26+
max-func-lines: 100
27+
nestif:
28+
min-complexity: 4
29+
linters:
30+
enable:
31+
- "bodyclose"
32+
- "deadcode"
33+
- "depguard"
34+
- "dogsled"
35+
- "dupl"
36+
- "errcheck"
37+
- "gochecknoinits"
38+
- "gocognit"
39+
- "goconst"
40+
- "gocritic"
41+
- "gocyclo"
42+
- "godot"
43+
- "gofmt"
44+
- "goimports"
45+
- "golint"
46+
- "gomnd"
47+
- "goprintffuncname"
48+
- "gosimple"
49+
- "govet"
50+
- "ineffassign"
51+
- "interfacer"
52+
- "maligned"
53+
- "megacheck"
54+
- "misspell"
55+
- "nakedret"
56+
- "rowserrcheck"
57+
- "scopelint"
58+
- "staticcheck"
59+
- "structcheck"
60+
- "stylecheck"
61+
- "typecheck"
62+
- "unconvert"
63+
- "unparam"
64+
- "unused"
65+
- "varcheck"
66+
- "whitespace"
67+
- "wsl"
68+
disable:
69+
- "funlen"
70+
- "gochecknoglobals"
71+
- "gosec"
72+
- "godox"
73+
- "lll"
74+
- "testpackage"
75+
fast: false

.vscode/settings.json

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"[go]": {
3+
"editor.formatOnSave": true
4+
},
5+
"[markdown]": {
6+
"files.trimTrailingWhitespace": false
7+
},
8+
"[yaml]": {
9+
"editor.defaultFormatter": "redhat.vscode-yaml",
10+
"editor.formatOnSave": true
11+
},
12+
"editor.formatOnSave": false,
13+
"editor.insertSpaces": false,
14+
"go.autocompleteUnimportedPackages": true,
15+
"go.formatTool": "goimports",
16+
"go.inferGopath": false,
17+
"go.languageServerExperimentalFeatures": {
18+
"diagnostics": true,
19+
"documentLink": true
20+
},
21+
"go.lintOnSave": "workspace",
22+
"go.lintTool": "golangci-lint",
23+
"go.lintFlags": [
24+
"--config=${workspaceFolder}/.golangci.yml",
25+
"--fast"
26+
],
27+
"go.toolsEnvVars": {
28+
"GO111MODULE": "on"
29+
},
30+
"go.useLanguageServer": true
31+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright(C) mythrnr. All Rights Reserved.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Makefile

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
.PHONY: cover godoc lint mock pull test tidy
2+
3+
overridefile ?= override
4+
target ?= .
5+
lint_target ?= ./...
6+
7+
cover:
8+
docker-compose \
9+
-f docker-compose.yml \
10+
-f docker-compose.$(overridefile).yml \
11+
run --rm app sh scripts/cover.sh $(target)
12+
13+
godoc:
14+
docker-compose up docs
15+
16+
lint:
17+
docker-compose \
18+
-f docker-compose.yml \
19+
-f docker-compose.$(overridefile).yml \
20+
run --rm --no-deps app golangci-lint run \
21+
--config=./.golangci.yml \
22+
--print-issued-lines=false $(lint_target)
23+
24+
mock:
25+
docker-compose run --rm --no-deps app \
26+
sh scripts/genmock.sh $(target)
27+
28+
pull:
29+
docker-compose \
30+
-f docker-compose.yml \
31+
-f docker-compose.$(overridefile).yml pull
32+
33+
test:
34+
docker-compose \
35+
-f docker-compose.yml \
36+
-f docker-compose.$(overridefile).yml \
37+
run --rm app sh scripts/test.sh $(target)
38+
39+
tidy:
40+
docker-compose \
41+
-f docker-compose.yml \
42+
-f docker-compose.$(overridefile).yml \
43+
run --rm --no-deps app go mod tidy

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# template-lib-golang
2+
3+
- General packages for Golang Applications.
4+
5+
## Requirements
6+
7+
Go 1.13 or above.
8+
9+
## Getting Started
10+
11+
### Installation
12+
13+
```bash
14+
go get github.com/mythrnr/template-lib-golang
15+
```
16+
17+
## Status
18+
19+
[![Unit Test](https://github.com/mythrnr/template-lib-golang/workflows/Unit%20Test/badge.svg?branch=v1.x)](https://github.com/mythrnr/template-lib-golang/actions?query=workflow%3A%22Unit+Test%22)
20+
21+
[![Create Release](https://github.com/mythrnr/template-lib-golang/workflows/Create%20Release/badge.svg)](https://github.com/mythrnr/template-lib-golang/actions?query=workflow%3A%22Create+Release%22)
22+
23+
## Documents
24+
25+
- [Docs](./docs/README.md)

go.mod

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module github.com/mythrnr/template-lib-golang
2+
3+
go 1.15
4+
5+
require github.com/stretchr/testify v1.6.1

0 commit comments

Comments
 (0)