You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 6 Next »

TaskCode ExampleReference
Creating a new go project
mkdir myproject
cd my project
go mod init myproject
link
Creating an instance of a struct
type Student struct {
	Name string
	Age  int
}

b := Student{ Name: "Bob", }
link
Creating an instance of a struct
var pa *Student   // pa == nil
pa = new(Student) // pa == &Student{"", 0}
pa.Name = "Alice" // pa == &Student{"Alice", 0}






















  • No labels