
上QQ阅读APP看书,第一时间看更新
How it works...
This recipe makes use of the strconv and strings packages to convert currency between dollars in string format and pennies in int64. It does this without even converting to a float64 other than as validation.
The strconv.ParseInt and strconv.FormatInt functions are very useful for converting to and from int64 and strings. We also made use of the fact that Go strings can easily be appended and sliced as needed.