你可以使用 strings.Replace 函数来将字符串的前几位替换为 ****

下面是一个示例代码:

package main

import (
	"fmt"
	"strings"
)

func main() {
	str := "Hello, World!"
	replaced := "****" + str[4:]

	fmt.Println(replaced)
}

输出结果为:****o, World!


原文地址: https://www.cveoy.top/t/topic/pkVL 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录