-
Notifications
You must be signed in to change notification settings - Fork 1
/
magefile.go
58 lines (44 loc) · 1.06 KB
/
magefile.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//go:build mage
// +build mage
package main
import (
"github.com/magefile/mage/sh"
"github.com/princjef/mageutil/bintool"
)
const binDir = "tools"
var (
linter = bintool.Must(bintool.New(
"golangci-lint{{.BinExt}}",
"1.49.0",
"https://github.com/golangci/golangci-lint/releases/download/v{{.Version}}/golangci-lint-{{.Version}}-{{.GOOS}}-{{.GOARCH}}{{.ArchiveExt}}",
bintool.WithFolder(binDir),
))
godoc = bintool.Must(bintool.NewGo("godoc", "latest", bintool.WithFolder("tools")))
)
func Lint() error {
if err := linter.Ensure(); err != nil {
return err
}
return linter.Command(`run`).Run()
}
func LintFix() error {
if err := linter.Ensure(); err != nil {
return err
}
return linter.Command(`run --fix`).Run()
}
func Test() error {
return sh.RunV("go", "test", "-race", "-v", "-count", "1", "./...")
}
func Vendor() error {
return sh.RunV("go", "mod", "vendor")
}
func Todo() error {
return sh.RunV("rg", "-i", "todo")
}
func Godoc() error {
if err := godoc.Ensure(); err != nil {
return err
}
return godoc.Command("-http=:6060").Run()
}