首先,需要引入字符串的包:

import "strings"

然后,给你个示例:

test = strings.Replace(test, "a", "abc", -1)

-1表示全部替换,正数为替换次数。[……]

Read more