go-zero/example/stringx/replace/replace.go

17 lines
299 B
Go
Raw Normal View History

2020-08-19 17:58:57 +08:00
package main
import (
"fmt"
"github.com/tal-tech/go-zero/core/stringx"
)
func main() {
replacer := stringx.NewReplacer(map[string]string{
2020-08-19 22:34:54 +08:00
"日本": "法国",
"日本的首都": "东京",
"东京": "日本的首都",
2020-08-19 17:58:57 +08:00
})
2020-08-19 22:34:54 +08:00
fmt.Println(replacer.Replace("日本的首都是东京"))
2020-08-19 17:58:57 +08:00
}