chore: make go vet happy.

This commit is contained in:
Alexandre Pujol 2024-08-20 19:07:56 +01:00
parent 93313422bd
commit 4f4e373877
Failed to generate hash of commit
6 changed files with 23 additions and 23 deletions

View file

@ -199,7 +199,7 @@ func main() {
case format: case format:
files, err = pathsFromArgs() files, err = pathsFromArgs()
if err != nil { if err != nil {
logging.Fatal(err.Error()) logging.Fatal("%s", err.Error())
} }
err = aaFormat(files) err = aaFormat(files)
case tree: case tree:
@ -207,6 +207,6 @@ func main() {
} }
if err != nil { if err != nil {
logging.Fatal(err.Error()) logging.Fatal("%s", err.Error())
} }
} }

View file

@ -91,6 +91,6 @@ func main() {
os.Exit(0) os.Exit(0)
} }
if err := aaPrebuild(); err != nil { if err := aaPrebuild(); err != nil {
logging.Fatal(err.Error()) logging.Fatal("%s", err.Error())
} }
} }

View file

@ -37,7 +37,7 @@ func Print(msg string, a ...interface{}) int {
// Println prints a formatted message. Arguments are handled in the manner of fmt.Println. // Println prints a formatted message. Arguments are handled in the manner of fmt.Println.
func Println(msg string) int { func Println(msg string) int {
n, _ := fmt.Fprintf(os.Stdout, msg+"\n") n, _ := fmt.Fprintf(os.Stdout, "%s\n", msg)
return n return n
} }
@ -48,7 +48,7 @@ func Bulletf(msg string, a ...interface{}) string {
// Bullet prints a formatted bullet point string // Bullet prints a formatted bullet point string
func Bullet(msg string, a ...interface{}) int { func Bullet(msg string, a ...interface{}) int {
return Print(Bulletf(msg, a...)) return Print("%s", Bulletf(msg, a...))
} }
// Stepf returns a formatted step string // Stepf returns a formatted step string
@ -58,7 +58,7 @@ func Stepf(msg string, a ...interface{}) string {
// Step prints a step title // Step prints a step title
func Step(msg string, a ...interface{}) int { func Step(msg string, a ...interface{}) int {
return Print(Stepf(msg, a...)) return Print("%s", Stepf(msg, a...))
} }
// Successf returns a formatted success string // Successf returns a formatted success string
@ -68,7 +68,7 @@ func Successf(msg string, a ...interface{}) string {
// Success prints a formatted success message to stdout // Success prints a formatted success message to stdout
func Success(msg string, a ...interface{}) int { func Success(msg string, a ...interface{}) int {
return Print(Successf(msg, a...)) return Print("%s", Successf(msg, a...))
} }
// Warningf returns a formatted warning string // Warningf returns a formatted warning string
@ -78,12 +78,12 @@ func Warningf(msg string, a ...interface{}) string {
// Warning prints a formatted warning message to stdout // Warning prints a formatted warning message to stdout
func Warning(msg string, a ...interface{}) int { func Warning(msg string, a ...interface{}) int {
return Print(Warningf(msg, a...)) return Print("%s", Warningf(msg, a...))
} }
// Fatalf returns a formatted error message // Fatalf returns a formatted error message
func Error(msg string, a ...interface{}) int { func Error(msg string, a ...interface{}) int {
return Print(fmt.Sprintf("%s%s%s\n", Indent, errorText, fmt.Sprintf(msg, a...))) return Print("%s", fmt.Sprintf("%s%s%s\n", Indent, errorText, fmt.Sprintf(msg, a...)))
} }
// Fatalf returns a formatted error message // Fatalf returns a formatted error message

View file

@ -10,7 +10,7 @@ func TestPrint(t *testing.T) {
msg := "Print message" msg := "Print message"
wantN := 13 wantN := 13
gotN := Print(msg) gotN := Print("%s", msg)
if gotN != wantN { if gotN != wantN {
t.Errorf("Print() = %v, want %v", gotN, wantN) t.Errorf("Print() = %v, want %v", gotN, wantN)
} }
@ -28,7 +28,7 @@ func TestPrintln(t *testing.T) {
func TestBulletf(t *testing.T) { func TestBulletf(t *testing.T) {
msg := "Bullet message" msg := "Bullet message"
want := "\033[1m ⋅ \033[0mBullet message\n" want := "\033[1m ⋅ \033[0mBullet message\n"
if got := Bulletf(msg); got != want { if got := Bulletf("%s", msg); got != want {
t.Errorf("Bulletf() = %v, want %v", got, want) t.Errorf("Bulletf() = %v, want %v", got, want)
} }
} }
@ -36,7 +36,7 @@ func TestBulletf(t *testing.T) {
func TestBullet(t *testing.T) { func TestBullet(t *testing.T) {
msg := "Bullet message" msg := "Bullet message"
wantN := 28 wantN := 28
gotN := Bullet(msg) gotN := Bullet("%s", msg)
if gotN != wantN { if gotN != wantN {
t.Errorf("Bullet() = %v, want %v", gotN, wantN) t.Errorf("Bullet() = %v, want %v", gotN, wantN)
} }
@ -45,7 +45,7 @@ func TestBullet(t *testing.T) {
func TestStepf(t *testing.T) { func TestStepf(t *testing.T) {
msg := "Step message" msg := "Step message"
want := "\033[1;32mStep message\033[0m\n" want := "\033[1;32mStep message\033[0m\n"
if got := Stepf(msg); got != want { if got := Stepf("%s", msg); got != want {
t.Errorf("Stepf() = %v, want %v", got, want) t.Errorf("Stepf() = %v, want %v", got, want)
} }
} }
@ -53,7 +53,7 @@ func TestStepf(t *testing.T) {
func TestStep(t *testing.T) { func TestStep(t *testing.T) {
msg := "Step message" msg := "Step message"
wantN := 24 wantN := 24
gotN := Step(msg) gotN := Step("%s", msg)
if gotN != wantN { if gotN != wantN {
t.Errorf("Step() = %v, want %v", gotN, wantN) t.Errorf("Step() = %v, want %v", gotN, wantN)
} }
@ -62,7 +62,7 @@ func TestStep(t *testing.T) {
func TestSuccessf(t *testing.T) { func TestSuccessf(t *testing.T) {
msg := "Success message" msg := "Success message"
want := "\033[1;32m ✓ \033[0mSuccess message\n" want := "\033[1;32m ✓ \033[0mSuccess message\n"
if got := Successf(msg); got != want { if got := Successf("%s", msg); got != want {
t.Errorf("Successf() = %v, want %v", got, want) t.Errorf("Successf() = %v, want %v", got, want)
} }
} }
@ -70,7 +70,7 @@ func TestSuccessf(t *testing.T) {
func TestSuccess(t *testing.T) { func TestSuccess(t *testing.T) {
msg := "Success message" msg := "Success message"
wantN := 32 wantN := 32
gotN := Success(msg) gotN := Success("%s", msg)
if gotN != wantN { if gotN != wantN {
t.Errorf("Success() = %v, want %v", gotN, wantN) t.Errorf("Success() = %v, want %v", gotN, wantN)
} }
@ -79,7 +79,7 @@ func TestSuccess(t *testing.T) {
func TestWarningf(t *testing.T) { func TestWarningf(t *testing.T) {
msg := "Warning message" msg := "Warning message"
want := "\033[1;33m ‼ \033[0mWarning message\n" want := "\033[1;33m ‼ \033[0mWarning message\n"
if got := Warningf(msg); got != want { if got := Warningf("%s", msg); got != want {
t.Errorf("Warningf() = %v, want %v", got, want) t.Errorf("Warningf() = %v, want %v", got, want)
} }
} }
@ -87,7 +87,7 @@ func TestWarningf(t *testing.T) {
func TestWarning(t *testing.T) { func TestWarning(t *testing.T) {
msg := "Warning message" msg := "Warning message"
wantN := 32 wantN := 32
gotN := Warning(msg) gotN := Warning("%s", msg)
if gotN != wantN { if gotN != wantN {
t.Errorf("Warning() = %v, want %v", gotN, wantN) t.Errorf("Warning() = %v, want %v", gotN, wantN)
} }
@ -96,7 +96,7 @@ func TestWarning(t *testing.T) {
func TestError(t *testing.T) { func TestError(t *testing.T) {
msg := "Error message" msg := "Error message"
wantN := 30 wantN := 30
gotN := Error(msg) gotN := Error("%s", msg)
if gotN != wantN { if gotN != wantN {
t.Errorf("Error() = %v, want %v", gotN, wantN) t.Errorf("Error() = %v, want %v", gotN, wantN)
} }
@ -105,7 +105,7 @@ func TestError(t *testing.T) {
func TestFatalf(t *testing.T) { func TestFatalf(t *testing.T) {
msg := "Error message" msg := "Error message"
want := "\033[1;31m ✗ Error: \033[0mError message\n" want := "\033[1;31m ✗ Error: \033[0mError message\n"
if got := Fatalf(msg); got != want { if got := Fatalf("%s", msg); got != want {
t.Errorf("Fatalf() = %v, want %v", got, want) t.Errorf("Fatalf() = %v, want %v", got, want)
} }
} }

View file

@ -197,6 +197,6 @@ func main() {
os.Exit(1) os.Exit(1)
} }
if err != nil { if err != nil {
logging.Fatal(err.Error()) logging.Fatal("%s", err.Error())
} }
} }

View file

@ -102,13 +102,13 @@ func (t *Test) Run(dryRun bool) (ran int, nb int, err error) {
if !strings.Contains(cmd, "{{") { if !strings.Contains(cmd, "{{") {
nb++ nb++
if dryRun { if dryRun {
logging.Bullet(cmd) logging.Bullet("%s", cmd)
} else { } else {
cmdErr := t.run(cmd, strings.Join(test.Stdin, "\n")) cmdErr := t.run(cmd, strings.Join(test.Stdin, "\n"))
if cmdErr != nil { if cmdErr != nil {
logging.Error("%v", cmdErr) logging.Error("%v", cmdErr)
} else { } else {
logging.Success(cmd) logging.Success("%s", cmd)
} }
} }
} }