building storage - Structs - fields, dot operator
Head First Go、 Jay McGavren(著)、O’Reilly Media)の Chapter 8(building storage - Structs)、p.235(Exercise)の解答を求めてみる。
コード
main.go
package main
import "fmt"
func main() {
var pet struct {
name string
age int
}
pet.name = "Max"
pet.age = 5
fmt.Println("Name:", pet.name)
fmt.Println("Age:", pet.age)
}
入出力結果(Terminal, Zsh)
% go run ./main.go
Name: Max
Age: 5
%