Go: fix string formatting in error messages
Alpine 3.19 Success Details

This commit is contained in:
Přemysl Eric Janouch 2022-03-16 12:38:51 +01:00
parent 71056896ac
commit b785eacf20
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 8 additions and 8 deletions

View File

@ -280,7 +280,7 @@ func fnMinus(ell *Ell, args []V) (result []V, ok bool) {
var res float64
if n, _ := fmt.Sscan(args[0].String, &res); n < 1 {
return ell.Errorf("invalid number: %f", args[0].String)
return ell.Errorf("invalid number: %s", args[0].String)
}
if len(args) == 1 {
res = -res
@ -292,7 +292,7 @@ func fnMinus(ell *Ell, args []V) (result []V, ok bool) {
}
var value float64
if n, _ := fmt.Sscan(arg.String, &value); n < 1 {
return ell.Errorf("invalid number: %f", arg.String)
return ell.Errorf("invalid number: %s", arg.String)
}
res -= value
}
@ -321,7 +321,7 @@ func fnDivide(ell *Ell, args []V) (result []V, ok bool) {
var res float64
if n, _ := fmt.Sscan(args[0].String, &res); n < 1 {
return ell.Errorf("invalid number: %f", args[0].String)
return ell.Errorf("invalid number: %s", args[0].String)
}
for _, arg := range args[1:] {
if arg.Type != VTypeString {
@ -329,7 +329,7 @@ func fnDivide(ell *Ell, args []V) (result []V, ok bool) {
}
var value float64
if n, _ := fmt.Sscan(arg.String, &value); n < 1 {
return ell.Errorf("invalid number: %f", arg.String)
return ell.Errorf("invalid number: %s", arg.String)
}
res /= value
}
@ -411,7 +411,7 @@ func fnEquals(ell *Ell, args []V) (result []V, ok bool) {
}
var first, second float64
if n, _ := fmt.Sscan(args[0].String, &first); n < 1 {
return ell.Errorf("invalid number: %f", args[0].String)
return ell.Errorf("invalid number: %s", args[0].String)
}
res := true
for _, arg := range args[1:] {
@ -419,7 +419,7 @@ func fnEquals(ell *Ell, args []V) (result []V, ok bool) {
return ell.Errorf("arguments must be strings")
}
if n, _ := fmt.Sscan(arg.String, &second); n < 1 {
return ell.Errorf("invalid number: %f", arg.String)
return ell.Errorf("invalid number: %s", arg.String)
}
if res = first == second; !res {
break
@ -435,7 +435,7 @@ func fnLess(ell *Ell, args []V) (result []V, ok bool) {
}
var first, second float64
if n, _ := fmt.Sscan(args[0].String, &first); n < 1 {
return ell.Errorf("invalid number: %f", args[0].String)
return ell.Errorf("invalid number: %s", args[0].String)
}
res := true
for _, arg := range args[1:] {
@ -443,7 +443,7 @@ func fnLess(ell *Ell, args []V) (result []V, ok bool) {
return ell.Errorf("arguments must be strings")
}
if n, _ := fmt.Sscan(arg.String, &second); n < 1 {
return ell.Errorf("invalid number: %f", arg.String)
return ell.Errorf("invalid number: %s", arg.String)
}
if res = first < second; !res {
break