til/Development/Go/strings.md

10 lines
266 B
Markdown
Raw Normal View History

2020-07-10 10:57:16 +00:00
# [strings](https://golang.org/pkg/strings/)
2020-08-29 06:28:01 +00:00
Replace list of strings by using `Replacer`:
2020-07-10 10:57:16 +00:00
```go
template := "My city is {city} and my country is {country}"
r := strings.NewReplacer("{city}", "Sai Gon", "{country}", "Viet Nam")
fmt.Println(r.Replace(template))
```