David in Canada

 

Tech, life, and everything in between.

Day 4: functions

Updated at # Tech # Go

Today's knowelege is functions: Key Concepts Basic form func add(a int, b int) int { return a + b } Usage result := add(1, 2) Cleaner syntax (same type) func add(a, b int) int { return a + b } Multiple Return Values func divide(a, b int) (int, int) { return a / b, a % b } Usage q, r := divide(10, 3) Ignoring Values q, _ := divide(10, 3) Named Return Values func rectangle(widt

Day 3: control flow with if, switch, and for loop

Updated at # Tech # Go

Today's knowelege is quite simple: Key Concepts if Basic form for condition { // body } else { // body } Parentheses are unnecessary and not idiomatic for n > 0 { fmt.Println("Positive") } switch Basic form day := 3 switch day { case 1: fmt.Println("Monday") case 2: fmt.Println("Tuesday") default: fmt.Println("Unknown") } No break needed Multiple conditions score :=

Day 2 of Learning Go: Variables, Types, and CLI Input

Updated at # Tech # Go

Today's knowelege is quite simple: Key Concepts variable Use var to declare a variable use var a int = 30 to declear a as a integer type, or just use := like: a := 100 to let Go infer the type automatically Data Type basic data types: int float64 string bool Cli Input use fmt.Scan() to get user input the parameter should be a pointer, so use & in front of the varibale P

Start learning Go

Updated at # Tech # Go

I'm going to spend 14 days learning the basics of Go. Here's the work for day one. Practice Install the latest Go (1.26.1) from the official website Go Programming Language Install the latest Visual Studio Code (1.114.0) from the official website Visual Studio Code - The open source AI code editor Update PowerShell to version 7.6.0 from github PowerShell/PowerShell: PowerShell for every syst

Life in Canada: Changing Tires

Updated at # Life

Before I came to Canada, I've never had a car. And since I got my driver's license, it only took few times I drive that I found out I have eye problem which causes poor eye-sights, and my red-green color-blind also an issue when I'm driving. So after the first few drive experiences, I never drove a car then. Before coming to Canada, I had never owned a car. Even after getting my driver’s license,