gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + Gno.land: a blockchain for timeless code and fair open-source
https://gno.land/
Other
839 stars 342 forks source link

feat(p/ufmt): Support more formatting verbs #2351

Open notJoon opened 1 week ago

notJoon commented 1 week ago

Description

Support for several new formatting verbs to the ufmt package:

%x: Outputs byte values as hexadecimal strings. Supports uint8, []uint8, and [32]uint8 types. %c: Outputs characters. Supports rune and int types. %q: Outputs quoted strings with proper escaping. Supports string type. %T: Outputs the type of the value. Supports various built-in types using type switching with interface{}.

Particularly in the case of byte slices, previously need to use a loop to convert each element to a string one by one, but now there is no need for that anymore.