Go 1.14.1
This contains personal notes for Go along with course code.
- courses contains Coursera and schoolwork code.
- experiments contains some code I used to experiment with and learn about Go concepts involving REST API's a long time ago.
- examples contains some recent examples demonstrating how to do basic things including the topics below.
Note: executing the supplied Go code requires navigating to
PROJECT_DIR/src
or setting theGO_PATH
appropriately.
Use decimals when multiplying floats. Go to.
Go does not have inheritance - polymorphism is achieved through flexible structs where an attribute plays the role of a type. Go to.
Encapsulation is achieved using structs, keeping method and type names lowercase (to prevent exporting), and using receivers. Go to.
Use make()
for Arrays and Maps:
Use:
bscan := bufio.NewScanner(os.Stdin)
// Continually reads input - try multiple times
for bscan.Scan() { }
Or for singular inputs:
fileName := ""
fmt.Println("Enter filename!")
fmt.Scan(&fileName)