Skip to content

Commit 7630a0d

Browse files
Use mise
1 parent 049fe44 commit 7630a0d

6 files changed

Lines changed: 77 additions & 122 deletions

File tree

File renamed without changes.

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
# Typos
3535
!.typos.toml
3636

37-
# Task
38-
!Taskfile.yml
37+
# mise
38+
!mise.toml
3939

4040
# Copier
4141
!.copier-answers.yml

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use everywhere across all my Go projects (which are mostly command line applicat
2222

2323
## Installation
2424

25-
```shell
25+
```bash
2626
go get go.followtheprocess.codes/log@latest
2727
```
2828

@@ -46,6 +46,7 @@ func main() {
4646
logger.Info(
4747
"Some information here",
4848
// Yep! You use slog.Attrs for key value pairs, why reinvent the wheel?
49+
// ... says the guy who wrote a new Logger
4950
slog.Bool("really", true),
5051
)
5152
logger.Warn("Uh oh!")

Taskfile.yml

Lines changed: 0 additions & 117 deletions
This file was deleted.

log.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ const (
4040
type Logger struct {
4141
w io.Writer // Where to write logs to
4242
timeFunc func() time.Time // A function to get the current time, defaults to [time.Now] (with UTC)
43-
mu *sync.Mutex // Protects w
43+
mu *sync.Mutex // Protects w, pointer so that child loggers share the same mutex
4444
timeFormat string // The time format layout string, defaults to [time.RFC3339]
4545
prefix string // Optional prefix to prepend to all log messages
4646
attrs []slog.Attr // Persistent key value pairs
@@ -130,7 +130,8 @@ func (l *Logger) log(level Level, msg string, attrs ...slog.Attr) {
130130
buf.WriteString(level.String())
131131

132132
if l.prefix != "" {
133-
buf.WriteString(" " + prefixStyle.Text(l.prefix))
133+
buf.WriteString(" ")
134+
buf.WriteString(prefixStyle.Text(l.prefix))
134135
}
135136

136137
buf.WriteByte(':')

mise.toml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# https://mise.jdx.dev
2+
[tools]
3+
golangci-lint = "latest"
4+
typos = "latest"
5+
vhs = "latest"
6+
"go:golang.org/x/pkgsite/cmd/pkgsite" = "latest"
7+
8+
[vars]
9+
cov_data = "coverage.out"
10+
11+
[tasks.tidy]
12+
description = "Tidy dependencies in go.mod and go.sum"
13+
sources = ["**/*.go", "go.mod", "go.sum"]
14+
run = "go mod tidy"
15+
16+
[tasks.fmt]
17+
description = "Run go fmt on all source files"
18+
sources = ["**/*.go", ".golangci.yml"]
19+
run = "golangci-lint fmt ./..."
20+
21+
[tasks.demo]
22+
description = "Render the demo gifs"
23+
sources = ["docs/src/*.tape", "**/*.go"]
24+
run = 'for file in ./docs/src/*.tape; do vhs "$file"; done'
25+
26+
[tasks.test]
27+
description = "Run the test suite"
28+
sources = ["**/*.go", "go.mod", "go.sum", "**/testdata/**/*"]
29+
# -race needs CGO
30+
env = { CGO_ENABLED = "1" }
31+
run = "go test -race ./..."
32+
33+
[tasks.bench]
34+
description = "Run all project benchmarks"
35+
sources = ["**/*.go"]
36+
run = "go test ./... -run None -benchmem -bench ."
37+
38+
[tasks.lint]
39+
description = "Run linting"
40+
depends = ["fmt"]
41+
sources = ["**/*.go", ".golangci.yml"]
42+
run = ["golangci-lint run ./...", "typos"]
43+
44+
[tasks.doc]
45+
description = "Render the pkg docs locally"
46+
run = "pkgsite -open"
47+
48+
[tasks.cov]
49+
description = "Calculate test coverage and render the html"
50+
outputs = ["{{vars.cov_data}}"]
51+
run = [
52+
"go test -race -cover -covermode atomic -coverprofile {{vars.cov_data}} ./...",
53+
"go tool cover -html {{vars.cov_data}}",
54+
]
55+
56+
[tasks.check]
57+
description = "Run tests and linting in one"
58+
run = ["mise run test", "mise run lint"]
59+
60+
[tasks.sloc]
61+
description = "Print lines of code"
62+
run = "fd . -e go | xargs wc -l | sort -nr | head"
63+
64+
[tasks.clean]
65+
description = "Remove build artifacts and other clutter"
66+
run = ["go clean ./...", "rm -rf {{vars.cov_data}}"]
67+
68+
[tasks.update]
69+
description = "Updates dependencies in go.mod and go.sum"
70+
run = ["go get -u ./...", "go mod tidy"]

0 commit comments

Comments
 (0)