This is due to a known bug with the implementation of main and how it interferes with varargs.
It would be fixed soon, when main is not treated as specially as it is now.
If you put the example in another function, then call it in main, it should work:

The tests work since they are executed inside test_ functions not inside main.
You're right. It works outside of main.
@shnorbluk Anyway, prefer the use of string interpolation: "Hello $a"
v_sprintf it there only in orderd to simplfy C portings :)
Yes, to get compile time string concatenation. But my need was to generate numbers padded with zeros, and printf seemed the simplest way.
you can use string concatenation like this:
fn main(){
a := 1234
allign_l := "[${a:-10}]"
allign_r := "[${a:10}]"
println("$allign_l $allign_r")
}
:)
I didn't see it ;) but it is documented here : https://github.com/vlang/v/blob/master/doc/docs.md#strings .
My code is:
a := 1234
println("${a:06d}")
Most helpful comment
I didn't see it ;) but it is documented here : https://github.com/vlang/v/blob/master/doc/docs.md#strings .
My code is: