Go struct can add method in
Go struct is not class. But it becomes like class. Go struct can add method
This is an example
package main import ( "fmt" ) type ABC struct { name string number int } func (a ABC) hello(message string) string { return a.name + " " + message } func main() { abc := ABC{ "Gonta", 1, } fmt.Println(abc.hello("Super!!!")) }
コメント