Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ linters:
- gocyclo # cyclop does this instead
- godox # "todo" and "fixme" comments are allowed
- goheader # No need
- goprintffuncname # I do a lot of this in here
- gosmopolitan # No need
- grouper # Imports take care of themselves, rest is common sense
- ireturn # This is just not necessary or practical in a real codebase
Expand All @@ -44,7 +45,6 @@ linters:
- varnamelen # Lots of false positives of things that are fine
- wrapcheck # Not every error must be wrapped
- wsl # Very aggressive, some of this I like but tend to do anyway
- wsl_v5 # Very aggressive, some of this I like but tend to do anyway

exclusions:
presets:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module go.followtheprocess.codes/msg

go 1.25

require go.followtheprocess.codes/hue v0.7.0
require go.followtheprocess.codes/hue v1.0.0

require (
golang.org/x/sys v0.36.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ go.followtheprocess.codes/hue v0.6.0 h1:JDLnRrkauCCIyYRqKNBDM+X6X5o75j2CG3iddnzI
go.followtheprocess.codes/hue v0.6.0/go.mod h1:tNCWKaywHqkFo20hYOVwG7CaoRajJeE2AueP5HStY7U=
go.followtheprocess.codes/hue v0.7.0 h1:6HaZTGc4NYVnqqjYZTTBcVYRKb8MyfPe5yBHJiBfekg=
go.followtheprocess.codes/hue v0.7.0/go.mod h1:gSn5xK6KJapih+eFgQk3woo1qg3/rx9XSrAanUIuDr8=
go.followtheprocess.codes/hue v1.0.0 h1:0fYXAGR1o+w7Vja+Q+iVtqeEP3/CE6ET/pniyl8e9yo=
go.followtheprocess.codes/hue v1.0.0/go.mod h1:gSn5xK6KJapih+eFgQk3woo1qg3/rx9XSrAanUIuDr8=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
golang.org/x/sys v0.36.0 h1:KVRy2GtZBrk1cBYA7MKu5bEZFxQk4NIDV6RLVcC8o0k=
Expand Down
10 changes: 10 additions & 0 deletions msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func TestErrorCaptured(t *testing.T) {
func TestErr(t *testing.T) {
t.Run("nil", func(t *testing.T) {
buf := new(bytes.Buffer)

var err error
msg.Ferr(buf, err)

Expand All @@ -102,6 +103,7 @@ func TestErr(t *testing.T) {
two := fmt.Errorf("failed to process file: %w", one)
three := fmt.Errorf("could not deposit money: %w", two)
msg.Ferr(buf, three)

wantTemplate := `%[1]sError%[2]s: could not deposit money
╰─ %[3]scause%[2]s: failed to process file
╰─ %[3]scause%[2]s: could not frobnicate the baz
Expand Down Expand Up @@ -238,7 +240,9 @@ func TestVisual(t *testing.T) {

func captureStdout(t *testing.T, printer func()) string {
t.Helper()

old := os.Stdout // Backup of the real one

defer func() {
os.Stdout = old // Set it back even if we error later
}()
Expand All @@ -256,6 +260,7 @@ func captureStdout(t *testing.T, printer func()) string {
go func() {
buf := new(bytes.Buffer)
io.Copy(buf, r) //nolint: errcheck // It's fine

capture <- buf.String()
}()

Expand All @@ -264,14 +269,17 @@ func captureStdout(t *testing.T, printer func()) string {

// Close the writer
w.Close()

captured := <-capture

return captured
}

func captureStderr(t *testing.T, printer func()) string {
t.Helper()

old := os.Stderr // Backup of the real one

defer func() {
os.Stderr = old // Set it back even if we error later
}()
Expand All @@ -289,6 +297,7 @@ func captureStderr(t *testing.T, printer func()) string {
go func() {
buf := new(bytes.Buffer)
io.Copy(buf, r) //nolint: errcheck // It's fine

capture <- buf.String()
}()

Expand All @@ -297,6 +306,7 @@ func captureStderr(t *testing.T, printer func()) string {

// Close the writer
w.Close()

captured := <-capture

return captured
Expand Down
Loading