How to convert a bool to a string in Go?

前端 未结 4 893
萌比男神i
萌比男神i 2020-12-15 02:07

I am trying to convert a bool called isExist to a string (true or false) by using string(isExist)

4条回答
  •  别那么骄傲
    2020-12-15 02:49

    use the strconv package

    docs

    strconv.FormatBool(v)

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

提交回复
热议问题