Skip to content

Commit abb47dd

Browse files
authored
Initial commit
0 parents  commit abb47dd

File tree

7 files changed

+143
-0
lines changed

7 files changed

+143
-0
lines changed

.github/workflows/ci.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
name: Test
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
# Fail fast is disabled because there are Go version specific features and tests
15+
# that should be able to fail independently.
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest, macos-latest, windows-latest]
19+
go: ['1.18', '1.19', '1.20', '1.21', '1.22', '1.23']
20+
21+
steps:
22+
- name: Set up Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version: ${{ matrix.go }}
26+
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
- name: Test
31+
run: go test -race -coverprofile=coverage.txt -covermode=atomic
32+
if: runner.os != 'Windows'
33+
34+
- name: Test Windows
35+
run: go test -race
36+
if: runner.os == 'Windows'
37+
38+
- name: Upload coverage to Codecov
39+
uses: codecov/codecov-action@v4
40+
with:
41+
token: ${{ secrets.CODECOV_TOKEN }}
42+
43+
lint:
44+
name: Lint
45+
runs-on: ubuntu-latest
46+
env:
47+
GOFLAGS: -mod=readonly
48+
49+
steps:
50+
- name: Set up Go
51+
uses: actions/setup-go@v3
52+
with:
53+
go-version: 1.18
54+
55+
- name: Checkout code
56+
uses: actions/checkout@v4
57+
58+
- name: Lint
59+
uses: golangci/golangci-lint-action@v6
60+
with:
61+
version: v1.60

.gitignore

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# If you prefer the allow list template instead of the deny list, see community template:
2+
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
3+
#
4+
# Binaries for programs and plugins
5+
*.exe
6+
*.exe~
7+
*.dll
8+
*.so
9+
*.dylib
10+
11+
# Test binary, built with `go test -c`
12+
*.test
13+
14+
# Output of the go coverage tool, specifically when used with LiteIDE
15+
*.out
16+
17+
# Dependency directories (remove the comment below to include it)
18+
# vendor/
19+
20+
# Go workspace file
21+
go.work
22+
go.work.sum
23+
24+
# env file
25+
.env
26+
27+
.vscode
28+
.idea
29+
.DS_Store

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Hyper Jiang
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.

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Go project template
2+
3+
[![GoDoc](https://pkg.go.dev/badge/github.com/hyperjiang/go-tpl)](https://pkg.go.dev/github.com/hyperjiang/go-tpl)
4+
[![CI](https://github.com/hyperjiang/go-tpl/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/hyperjiang/go-tpl/actions/workflows/ci.yml)
5+
[![](https://goreportcard.com/badge/github.com/hyperjiang/go-tpl)](https://goreportcard.com/report/github.com/hyperjiang/go-tpl)
6+
[![codecov](https://codecov.io/gh/hyperjiang/go-tpl/branch/main/graph/badge.svg)](https://codecov.io/gh/hyperjiang/go-tpl)
7+
[![Release](https://img.shields.io/github/release/hyperjiang/go-tpl.svg)](https://github.com/hyperjiang/go-tpl/releases)
8+
9+
Simple golang project template.
10+
11+
## Prerequisite
12+
13+
go version >= 1.18

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/hyperjiang/gotpl
2+
3+
go 1.18

hello.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package gotpl
2+
3+
func Say() string {
4+
return "Hello, World!"
5+
}

hello_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package gotpl
2+
3+
import "testing"
4+
5+
func TestSay(t *testing.T) {
6+
expected := "Hello, World!"
7+
result := Say()
8+
if result != expected {
9+
t.Errorf("Say() = %v; want %v", result, expected)
10+
}
11+
}

0 commit comments

Comments
 (0)