Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String GoLang中的模板字符串?_String_Templates_Go - Fatal编程技术网

String GoLang中的模板字符串?

String GoLang中的模板字符串?,string,templates,go,String,Templates,Go,我已经研究了一段时间,但什么也没找到 比如说 var name = "tom" sentence := "My Name is #{name}" 在JS中,它使用${var},在ruby中使用#{var} 那么GoLang中有模板字符串吗 感谢您的帮助解决方案是 sentence := fmt.Sprintf("My Name is %s", name)

我已经研究了一段时间,但什么也没找到

比如说

var name = "tom"
sentence := "My Name is #{name}"
在JS中,它使用${var},在ruby中使用#{var}

那么GoLang中有模板字符串吗

感谢您的帮助

解决方案是

sentence := fmt.Sprintf("My Name is %s", name)