Example of Go variadic function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 func main() { nums := []int{1, 2, 3} // uses the existing slice s1 := sum(nums.Here is an example of slice passed as value to a function:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 func main() { dirs := []string{"up", "down", "left", "right"} up(dirs) // dirs => []string{"UP", "DOWN", "LEFT", "RIGHT"} } func up(list []string) { // slice pointer points to a reference // even if they passed in a function.Declare a struct:
1 2 3 4 5 6 7 8 9 type person struct { name, lastname string age int } var alice struct { name, lastname string age int } Struct instance:
1 2 3 4 5 6 7 8 9 picasso := person{ name: "Pablo", lastname: "Picasso", age: 91, } alice.Read standard input by line:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 import ( "bufio" "os" "fmt" ) func main() { // New scanner to read from stdin. // By default it reads line.My notes of 1% Better Every Day - James Clear at ConvertKit Craft + Commerce 2017 talk.
The aggregation of marginal gains. To explain this, speaker talks about bicycle group example that work on small improvement to achieve an goal.
Improve 1% each day that compound to end up 37% times better at end of year.