Skip to content

Commit c3cd15f

Browse files
committed
initial commit
0 parents  commit c3cd15f

16 files changed

+709
-0
lines changed

Diff for: .github/FUNDING.yml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
github: [samber]

Diff for: .github/workflows/lint.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
tags:
6+
branches:
7+
pull_request:
8+
9+
jobs:
10+
golangci:
11+
name: lint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/setup-go@v2
15+
with:
16+
go-version: 1.20.1
17+
stable: false
18+
- uses: actions/checkout@v2
19+
- name: golangci-lint
20+
uses: golangci/golangci-lint-action@v2
21+
with:
22+
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
23+
version: latest
24+
25+
# Optional: working directory, useful for monorepos
26+
working-directory: ./
27+
28+
# Optional: golangci-lint command line arguments.
29+
args: --timeout 60s --max-same-issues 50
30+
31+
# Optional: show only new issues if it's a pull request. The default value is `false`.
32+
# only-new-issues: true
33+
34+
# Optional: if set to true then the action will use pre-installed Go.
35+
# skip-go-installation: true
36+
37+
# Optional: if set to true then the action don't cache or restore ~/go/pkg.
38+
# skip-pkg-cache: true
39+
40+
# Optional: if set to true then the action don't cache or restore ~/.cache/go-build.
41+
# skip-build-cache: true
42+
43+
# optionally use a specific version of Go rather than the latest one
44+
go_version: '1.20.1'

Diff for: .github/workflows/release.yml

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
semver:
7+
type: string
8+
description: 'Semver (eg: v1.2.3)'
9+
required: true
10+
11+
jobs:
12+
release:
13+
if: github.triggering_actor == 'samber'
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v2
17+
18+
- name: Set up Go
19+
uses: actions/setup-go@v2
20+
with:
21+
go-version: 1.20.1
22+
stable: false
23+
24+
- name: Test
25+
run: make test
26+
27+
# remove tests in order to clean dependencies
28+
- name: Remove xxx_test.go files
29+
run: rm -rf *_test.go ./examples ./images
30+
31+
# cleanup test dependencies
32+
- name: Cleanup dependencies
33+
run: go mod tidy
34+
35+
- name: List files
36+
run: tree -Cfi
37+
- name: Write new go.mod into logs
38+
run: cat go.mod
39+
- name: Write new go.sum into logs
40+
run: cat go.sum
41+
42+
- name: Create tag
43+
run: |
44+
git config --global user.name '${{ github.triggering_actor }}'
45+
git config --global user.email "${{ github.triggering_actor}}@users.noreply.github.com"
46+
47+
git add .
48+
git commit --allow-empty -m 'bump ${{ inputs.semver }}'
49+
git tag ${{ inputs.semver }}
50+
git push origin ${{ inputs.semver }}
51+
52+
- name: Release
53+
uses: softprops/action-gh-release@v1
54+
with:
55+
name: ${{ inputs.semver }}
56+
tag_name: ${{ inputs.semver }}

Diff for: .github/workflows/test.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
tags:
6+
branches:
7+
pull_request:
8+
9+
jobs:
10+
11+
test:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
16+
- name: Set up Go
17+
uses: actions/setup-go@v2
18+
with:
19+
go-version: 1.20.1
20+
stable: false
21+
22+
- name: Build
23+
run: make build
24+
25+
- name: Test
26+
run: make test
27+
28+
- name: Test
29+
run: make coverage
30+
31+
- name: Codecov
32+
uses: codecov/codecov-action@v2
33+
with:
34+
token: ${{ secrets.CODECOV_TOKEN }}
35+
file: ./cover.out
36+
flags: unittests
37+
verbose: true

Diff for: .gitignore

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
# Created by https://www.toptal.com/developers/gitignore/api/go
3+
# Edit at https://www.toptal.com/developers/gitignore?templates=go
4+
5+
### Go ###
6+
# If you prefer the allow list template instead of the deny list, see community template:
7+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
8+
#
9+
# Binaries for programs and plugins
10+
*.exe
11+
*.exe~
12+
*.dll
13+
*.so
14+
*.dylib
15+
16+
# Test binary, built with `go test -c`
17+
*.test
18+
19+
# Output of the go coverage tool, specifically when used with LiteIDE
20+
*.out
21+
22+
# Dependency directories (remove the comment below to include it)
23+
# vendor/
24+
25+
# Go workspace file
26+
go.work
27+
28+
### Go Patch ###
29+
/vendor/
30+
/Godeps/
31+
32+
# End of https://www.toptal.com/developers/gitignore/api/go
33+
34+
cover.out
35+
cover.html
36+
.vscode
37+
38+
.idea/

Diff for: LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Samuel Berthe
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.

Diff for: Makefile

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
BIN=go
3+
4+
build:
5+
${BIN} build -v ./...
6+
7+
test:
8+
go test -race -v ./...
9+
watch-test:
10+
reflex -t 50ms -s -- sh -c 'gotest -race -v ./...'
11+
12+
bench:
13+
go test -benchmem -count 3 -bench ./...
14+
watch-bench:
15+
reflex -t 50ms -s -- sh -c 'go test -benchmem -count 3 -bench ./...'
16+
17+
coverage:
18+
${BIN} test -v -coverprofile=cover.out -covermode=atomic .
19+
${BIN} tool cover -html=cover.out -o cover.html
20+
21+
tools:
22+
${BIN} install github.com/cespare/reflex@latest
23+
${BIN} install github.com/rakyll/gotest@latest
24+
${BIN} install github.com/psampaz/go-mod-outdated@latest
25+
${BIN} install github.com/jondot/goweight@latest
26+
${BIN} install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
27+
${BIN} get -t -u golang.org/x/tools/cmd/cover
28+
${BIN} install github.com/sonatype-nexus-community/nancy@latest
29+
go mod tidy
30+
31+
lint:
32+
golangci-lint run --timeout 60s --max-same-issues 50 ./...
33+
lint-fix:
34+
golangci-lint run --timeout 60s --max-same-issues 50 --fix ./...
35+
36+
audit: tools
37+
${BIN} list -json -m all | nancy sleuth
38+
39+
outdated: tools
40+
${BIN} list -u -m -json all | go-mod-outdated -update -direct
41+
42+
weight: tools
43+
goweight

0 commit comments

Comments
 (0)