dbg: linter feedback updates.

This commit is contained in:
2025-11-15 15:53:57 -08:00
parent e4db163efe
commit ddf26e00af
3 changed files with 11 additions and 10 deletions

View File

@@ -447,6 +447,8 @@ linters:
linters: [ staticcheck, gosec ] linters: [ staticcheck, gosec ]
- path: 'backoff/backoff_test.go' - path: 'backoff/backoff_test.go'
linters: [ testpackage ] linters: [ testpackage ]
- path: 'dbg/dbg_test.go'
linters: [ testpackage ]
- source: 'TODO' - source: 'TODO'
linters: [ godot ] linters: [ godot ]
- text: 'should have a package comment' - text: 'should have a package comment'

View File

@@ -47,7 +47,7 @@ func ToFile(path string) (*DebugPrinter, error) {
}, nil }, nil
} }
// To sets up a new DebugPrint to an io.WriteCloser. // To will set up a new DebugPrint to an io.WriteCloser.
func To(w io.WriteCloser) *DebugPrinter { func To(w io.WriteCloser) *DebugPrinter {
return &DebugPrinter{ return &DebugPrinter{
out: w, out: w,
@@ -55,22 +55,22 @@ func To(w io.WriteCloser) *DebugPrinter {
} }
// Print calls fmt.Print if Enabled is true. // Print calls fmt.Print if Enabled is true.
func (dbg *DebugPrinter) Print(v ...interface{}) { func (dbg *DebugPrinter) Print(v any) {
if dbg.Enabled { if dbg.Enabled {
fmt.Fprint(dbg.out, v...) fmt.Fprint(dbg.out, v)
} }
} }
// Println calls fmt.Println if Enabled is true. // Println calls fmt.Println if Enabled is true.
func (dbg *DebugPrinter) Println(v ...interface{}) { func (dbg *DebugPrinter) Println(v any) {
if dbg.Enabled { if dbg.Enabled {
fmt.Fprintln(dbg.out, v...) fmt.Fprintln(dbg.out, v)
} }
} }
// Printf calls fmt.Printf if Enabled is true. // Printf calls fmt.Printf if Enabled is true.
func (dbg *DebugPrinter) Printf(format string, v ...interface{}) { func (dbg *DebugPrinter) Printf(format string, v any) {
if dbg.Enabled { if dbg.Enabled {
fmt.Fprintf(dbg.out, format, v...) fmt.Fprintf(dbg.out, format, v)
} }
} }

View File

@@ -2,7 +2,6 @@ package dbg
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"testing" "testing"
@@ -50,7 +49,7 @@ func TestTo(t *testing.T) {
} }
func TestToFile(t *testing.T) { func TestToFile(t *testing.T) {
testFile, err := ioutil.TempFile("", "dbg") testFile, err := os.CreateTemp(t.TempDir(), "dbg")
assert.NoErrorT(t, err) assert.NoErrorT(t, err)
err = testFile.Close() err = testFile.Close()
assert.NoErrorT(t, err) assert.NoErrorT(t, err)
@@ -103,7 +102,7 @@ func TestWriting(t *testing.T) {
} }
func TestToFileError(t *testing.T) { func TestToFileError(t *testing.T) {
testFile, err := ioutil.TempFile("", "dbg") testFile, err := os.CreateTemp(t.TempDir(), "dbg")
assert.NoErrorT(t, err) assert.NoErrorT(t, err)
err = testFile.Chmod(0400) err = testFile.Chmod(0400)
assert.NoErrorT(t, err) assert.NoErrorT(t, err)