生命不止,继续 go go go !!!
今天跟大家分享一些有用的,简单的golang代码片段。
改变string的值
首先我们要知道,在golang中,string是不可变的:
str := "hello"
str[0] = 'c'
编译错误:cannot assign to str[0]
正确的做法:
package main
import (
"fmt"
)
func main() {
str := "hello"
c := []