情况:
我有一个值片段,需要从中随机选择一个值。然后我想用一个固定的字符串连接它。到目前为止,这是我的代码:
func main() {
//create the reasons slice and append reasons to it
reasons := make([]string, 0)
reasons = append(reasons,
"Locked out",
"Pipes broke",
"Food poisoning",
"Not feeling well")
message := fmt.Sprint("Gonna work from home...", pick a random reason )
}
问题:
是否有一个内置的功能,可以帮助我做“ 随便找个理由”的一部分?