This Commented CUE
demonstrates how to use the built-in function
strconv.Atoi
to convert a string representation of an int to the number itself, using base
10.
file.cue
package example
import "strconv"
"0": strconv.Atoi("0")
"1": strconv.Atoi("1")
"10": strconv.Atoi("10")
"42": strconv.Atoi("42")
"-42": strconv.Atoi("-42")
"050": strconv.Atoi("050")
"-050": strconv.Atoi("-050")
"00012345": strconv.Atoi("00012345")
TERMINAL
$ cue export
{
"0": 0,
"1": 1,
"10": 10,
"42": 42,
"-42": -42,
"050": 50,
"-050": -50,
"00012345": 12345
}
Related content
strconv.Atoi
is a base-10 convenience wrapper around the built-in functionstrconv.ParseInt
, which can perform conversions with custom bases and bit widths- The
strconv
built-in package