且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Go 中将布尔值转换为字符串?

更新时间:2022-05-22 05:46:35

使用strconv包

文档

strconv.FormatBool(v)

func FormatBool(b bool) 字符串 FormatBool 返回真"或假"
根据b的值

func FormatBool(b bool) string FormatBool returns "true" or "false"
according to the value of b