package main
import (
"fmt"
)
type userInfo struct {
userId string
userName string
}
func main() {
var userInfos []*userInfo
userInfos = append(userInfos, &userInfo{userId: "123qew", userName: "test1"})
userInfos = append(userInfos, &userInfo{userId: "1234qew", userName: "test2"})
for _, singleBid := range userInfos {
singleBid.userId = "test3"
}
fmt.Printf("%+v\n", userInfos[0])
fmt.Printf("%+v\n", userInfos[1])
}
go 通过指针修改struct结构体的值
最新推荐文章于 2023-03-09 17:53:20 发布