본 게시글은 Golang Tutorial for Beginners | Full Go Course을 학습하며 작성한 개인 노트입니다.
Go is a statically typed language
var userName string
var userTickets int
uint & int
remainingTickets -= uint(userTickets)
uint > string
strconv.FormatUint(uint64(uint-value), base)
Commonly used data types to store a list of values
var variable_name = [size]variable_type
-var bookings = [50]string{}
-var bookings [50]string
var bookings = [50]string{"Jack", "Peter"}
bookings[0] = "Nana"
bookings[10] = "Xavier"
len(arr)
fmt.Print(arr)
>> [50]string
var bookings = []string{}
bookings := []string{}
bookings = append(bookings, firstName+" "+lastName)
var userName string
fmt.Scan(&userName)
You have to use a pointer to scan user input properly. Without a pointer, Go will run the program without the user input.
Pass the reference (not the value) into the scan function so that the scan function can assign the user's value to the variable based on the memory address the pointer has.
Pointer: the address of a variable
References:
https://www.geeksforgeeks.org/data-types-in-go/