修改结构体值时,重复的参数错误,s就是重复的祸根

package main

import "fmt"

type SS struct {
S string
I int
}

func (s *SS) Test(i int) {
s.I=i

}
func (s *SS) TestString(s string) {
s.S=s

}

func main() {
s:=&SS{S: "test"}
s.Test(100)
s.TestString("cheyunhua")
fmt.Println(s.S)

}


# command-line-arguments
.\test16.go:14:25: duplicate argument s
.\test16.go:15:3: s.S undefined (type string has no field or method S)

posted @ 2021-12-27 15:05  技术颜良  阅读(68)  评论(0)    收藏  举报