🎃

【Golang】boolをstringに変換する

2023/02/23に公開

fmt.Sprintf()を使用する

package main

import "fmt"

func main() {
    s := fmt.Sprintf("%t", true)
}

https://pkg.go.dev/fmt

Boolean:
%t the word true or false

strconv.Format()を使用する

package main

import (
	"strconv"
)

func main() {
	s := strconv.FormatBool(true)
}

Discussion