获取第一个符文,符文的标题大小写并重新组装字符串:sentence := "the biggest ocean is the Pacific ocean"r, i := utf8.DecodeRuneInString(sentence)sentence = string(unicode.ToTitle(r)) + sentence[i:]fmt.Println(sentence)
达到预期结果的最简单方法是使用strings.ToUpper()函数。参考var input string = "the biggest ocean is the Pacific ocean" res := strings.ToUpper(input[:1]) + input[1:] fmt.Println(res)或者你可以去goplayground试试