feat: add a template repo for a generic go project
- add an empty .gitignore file - add .golangci.yaml - add a simple magefile.go file - add a very simple main.go file
This commit is contained in:
commit
72fc243dd9
4 changed files with 84 additions and 0 deletions
0
.gitignore
vendored
Normal file
0
.gitignore
vendored
Normal file
22
.golangci.yaml
Normal file
22
.golangci.yaml
Normal file
|
@ -0,0 +1,22 @@
|
|||
---
|
||||
run:
|
||||
concurrency: 2
|
||||
timeout: 1m
|
||||
issues-exit-code: 1
|
||||
tests: true
|
||||
|
||||
output:
|
||||
format: colored-line-number
|
||||
print-issues-lines: true
|
||||
print-linter-name: true
|
||||
uniq-by-line: true
|
||||
sort-results: true
|
||||
|
||||
linters-settings:
|
||||
lll:
|
||||
line-length: 140
|
||||
|
||||
linters:
|
||||
enable-all: true
|
||||
# disable:
|
||||
fast: false
|
57
magefile.go
Normal file
57
magefile.go
Normal file
|
@ -0,0 +1,57 @@
|
|||
//go:build mage
|
||||
// +build mage
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/magefile/mage/sh"
|
||||
)
|
||||
|
||||
var Default = Build
|
||||
|
||||
var binary = "app"
|
||||
|
||||
// Test run the go tests.
|
||||
// To enable verbose mode set GO_TEST_VERBOSE=1.
|
||||
// To enable coverage mode set GO_TEST_COVER=1.
|
||||
func Test() error {
|
||||
goTest := sh.RunCmd("go", "test")
|
||||
|
||||
args := []string{"./..."}
|
||||
|
||||
if os.Getenv("GO_TEST_VERBOSE") == "1" {
|
||||
args = append(args, "-v")
|
||||
}
|
||||
|
||||
if os.Getenv("GO__TEST_COVER") == "1" {
|
||||
args = append(args, "-cover")
|
||||
}
|
||||
|
||||
return goTest(args...)
|
||||
}
|
||||
|
||||
// Lint runs golangci-lint against the code.
|
||||
func Lint() error {
|
||||
return sh.RunV("golangci-lint", "run", "--color", "always")
|
||||
}
|
||||
|
||||
// Build build the executable.
|
||||
func Build() error {
|
||||
main := "main.go"
|
||||
return sh.Run("go", "build", "-o", binary, main)
|
||||
}
|
||||
|
||||
// Clean clean the workspace.
|
||||
func Clean() error {
|
||||
if err := sh.Rm(binary); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := sh.Run("go", "clean", "./..."); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
5
main.go
Normal file
5
main.go
Normal file
|
@ -0,0 +1,5 @@
|
|||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
Loading…
Reference in a new issue