7
[Golang] Convert Integer to String via fmt.Sprintf
source link: http://siongui.github.io/2018/05/28/go-convert-integer-to-string-via-fmt.Sprintf/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
[Golang] Convert Integer to String via fmt.Sprintf
May 28, 2018
If you use strconv package, you can convert integer to string using following methods:
There is another way to do this, that is, use fmt.Sprintf
For example, assume variable i is either int or int64 type, you can convert it to string type as follows:
s := fmt.Sprintf("%d", i)
This is a small trick I found recently. You can try it yourself online:
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK