我需要将uint32转换为字符串并将前导零添加到固定长度。我怎么能这样做?
这是我的代码:
var unixTs uint32 = 1446455472
var randomInt uint32 = 58964981
var expiredTs uint32 = 2
unixTsStr := fmt.Sprint("%010d", unixTs)
randomIntStr := fmt.Sprint("%08d", randomInt)
expiredTsStr := fmt.Sprint("%010d", expiredTs)
输出打印:
%010d1446455472
%08d58964981
%010d2
我想要的是:
1446455472
58964981
0000000002
谢谢!