Map, Struct

지니🧸·2023년 8월 29일
0

Go

목록 보기
7/8

본 게시글은 Golang Tutorial for Beginners | Full Go Course을 학습하며 작성한 개인 노트입니다.

Map

Initialize

var mapName = make(map[keyType]dataType)

Add values

userData["firstName"] = firstName

A list of maps

var bookings = make([]map[string]string, 0)

declared as 0 because it will increase automatically anways

Structs

Structs can mix up data types

Initialize

type UserData struct {
	firstName string
	lastName string
	email string
	numberOfTickets uint
}

Use it

var bookings = make([]UserData, 0)

bookings[0].firstName

profile
우당탕탕

0개의 댓글