We started with A tour of Go https://go.dev/tour/list
- Packages
- go Programs start running in package
main
.
- Imports
- We can import packages as parenthesized, "factored" import statement or write multiple import statements.
- Exported names
- In Go, a name is exported if it begins with a capital letter, so Go interprets
math.Pi
but notmath.pi
- Functions
- Learn to write functions in Go, with zero, one or multiple parameters. Also, notice
type
comes after the variable name.
- Functions continued
- Learn how
x int, y int
can also be written asx, y int
- Multiple results
- A function can return any number of results. Practice this using
swap
function which returns two or more strings
- Named return values
- A
return
statement without arguments returns the named return values. This is known as a "naked" return. Use Naked return statements only in short functions.
- For this session we ended it here - https://go.dev/tour/basics/7