dbg: linter feedback updates.
This commit is contained in:
@@ -447,6 +447,8 @@ linters:
|
||||
linters: [ staticcheck, gosec ]
|
||||
- path: 'backoff/backoff_test.go'
|
||||
linters: [ testpackage ]
|
||||
- path: 'dbg/dbg_test.go'
|
||||
linters: [ testpackage ]
|
||||
- source: 'TODO'
|
||||
linters: [ godot ]
|
||||
- text: 'should have a package comment'
|
||||
|
||||
14
dbg/dbg.go
14
dbg/dbg.go
@@ -47,7 +47,7 @@ func ToFile(path string) (*DebugPrinter, error) {
|
||||
}, 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 {
|
||||
return &DebugPrinter{
|
||||
out: w,
|
||||
@@ -55,22 +55,22 @@ func To(w io.WriteCloser) *DebugPrinter {
|
||||
}
|
||||
|
||||
// Print calls fmt.Print if Enabled is true.
|
||||
func (dbg *DebugPrinter) Print(v ...interface{}) {
|
||||
func (dbg *DebugPrinter) Print(v any) {
|
||||
if dbg.Enabled {
|
||||
fmt.Fprint(dbg.out, v...)
|
||||
fmt.Fprint(dbg.out, v)
|
||||
}
|
||||
}
|
||||
|
||||
// Println calls fmt.Println if Enabled is true.
|
||||
func (dbg *DebugPrinter) Println(v ...interface{}) {
|
||||
func (dbg *DebugPrinter) Println(v any) {
|
||||
if dbg.Enabled {
|
||||
fmt.Fprintln(dbg.out, v...)
|
||||
fmt.Fprintln(dbg.out, v)
|
||||
}
|
||||
}
|
||||
|
||||
// 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 {
|
||||
fmt.Fprintf(dbg.out, format, v...)
|
||||
fmt.Fprintf(dbg.out, format, v)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package dbg
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
@@ -50,7 +49,7 @@ func TestTo(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestToFile(t *testing.T) {
|
||||
testFile, err := ioutil.TempFile("", "dbg")
|
||||
testFile, err := os.CreateTemp(t.TempDir(), "dbg")
|
||||
assert.NoErrorT(t, err)
|
||||
err = testFile.Close()
|
||||
assert.NoErrorT(t, err)
|
||||
@@ -103,7 +102,7 @@ func TestWriting(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestToFileError(t *testing.T) {
|
||||
testFile, err := ioutil.TempFile("", "dbg")
|
||||
testFile, err := os.CreateTemp(t.TempDir(), "dbg")
|
||||
assert.NoErrorT(t, err)
|
||||
err = testFile.Chmod(0400)
|
||||
assert.NoErrorT(t, err)
|
||||
|
||||
Reference in New Issue
Block a user