![構造体・予約語『type』・new関数](https://mitikusa-engineer.com/wp-content/uploads/2022/07/Go-1024x538.png)
Go言語の構造体と予約語『type』についてまとめました。
動作環境
ホストOS | Windows 10 21H1(19043.2006) 64bit |
WSL | 2 |
Visual Studio Code | 1.70.2 |
Docker Desktop | 4.12.0(85629) |
Go | 1.18.6 |
構文
// typeの構文
type 型の別名 元の型名
// 構造体の構文
type 構造体名 struct {
アクセスするためのフィールド名 型名
・
・
・
}
サンプル
.
├── go.mod
└── main.go