diff --git a/meetup_2018_11_20/go-quizzes/1.go b/meetup_2018_11_20/go-quizzes/1.go new file mode 100644 index 0000000..741686d --- /dev/null +++ b/meetup_2018_11_20/go-quizzes/1.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" +) + +// https://twitter.com/davecheney/status/1053490060492890118 +func main() { + one, two, three := 0.1, 0.2, 0.3 + fmt.Println(one+two > three) +} + +// True +// False +// 0.3 diff --git a/meetup_2018_11_20/go-quizzes/10.go b/meetup_2018_11_20/go-quizzes/10.go new file mode 100644 index 0000000..7ea491c --- /dev/null +++ b/meetup_2018_11_20/go-quizzes/10.go @@ -0,0 +1,19 @@ +package main + +import "fmt" + +func four(s []int) { + s = append(s, 4) +} + +// https://twitter.com/davecheney/status/1019359774264082432 +func main() { + s := []int{1, 2, 3} + four(s) + fmt.Println(s) +} + +// [ 1 2 3 4 ] +// [ 4 ] +// [ 1 2 3 ] +// doesn't compile diff --git a/meetup_2018_11_20/go-quizzes/2.go b/meetup_2018_11_20/go-quizzes/2.go new file mode 100644 index 0000000..8843edc --- /dev/null +++ b/meetup_2018_11_20/go-quizzes/2.go @@ -0,0 +1,14 @@ +package main + +import "fmt" + +// https://twitter.com/davecheney/status/1056487208989773824 +func main() { + ಠ_ಠ := '7' + fmt.Println(ಠ_ಠ) +} + +// ಠ_ಠ +// 55 +// 7 +// dude, that won't compile diff --git a/meetup_2018_11_20/go-quizzes/3.go b/meetup_2018_11_20/go-quizzes/3.go new file mode 100644 index 0000000..63f1f37 --- /dev/null +++ b/meetup_2018_11_20/go-quizzes/3.go @@ -0,0 +1,16 @@ +package main + +import ( + "fmt" +) + +// https://twitter.com/davecheney/status/1053419185680744448 +func main() { + var a []int + b := a[:] + fmt.Println(b == nil) +} + +// true +// false +// panic on line 9 diff --git a/meetup_2018_11_20/go-quizzes/4.go b/meetup_2018_11_20/go-quizzes/4.go new file mode 100644 index 0000000..6a9e0e2 --- /dev/null +++ b/meetup_2018_11_20/go-quizzes/4.go @@ -0,0 +1,16 @@ +package main + +import ( + "fmt" +) + +// https://twitter.com/davecheney/status/1042396099443453952 +func main() { + for i := 1; i < 10; i++ { + fmt.Println("Hello!") + } +} + +// Yes +// No +// Only on Windows diff --git a/meetup_2018_11_20/go-quizzes/5.go b/meetup_2018_11_20/go-quizzes/5.go new file mode 100644 index 0000000..39cdef9 --- /dev/null +++ b/meetup_2018_11_20/go-quizzes/5.go @@ -0,0 +1,17 @@ +package main + +import ( + "crypto/sha1" + "fmt" +) + +// https://twitter.com/davecheney/status/1041526653141147654 +func main() { + input := []byte("Hello, playground") + hash := sha1.Sum(input)[:5] + fmt.Println(hash) +} + +// 461ec8144f +// [70 30 200 20 79] +// nothing, doesn't compile diff --git a/meetup_2018_11_20/go-quizzes/6.go b/meetup_2018_11_20/go-quizzes/6.go new file mode 100644 index 0000000..88b4a7a --- /dev/null +++ b/meetup_2018_11_20/go-quizzes/6.go @@ -0,0 +1,15 @@ +package main + +import ( + "fmt" +) + +// https://twitter.com/davecheney/status/1039997464361623552 +func main() { + fmt.Println(string('7' << 1)) +} + +// 7 +// 14 +// n +// doesn't compile diff --git a/meetup_2018_11_20/go-quizzes/7.go b/meetup_2018_11_20/go-quizzes/7.go new file mode 100644 index 0000000..7b2f4ef --- /dev/null +++ b/meetup_2018_11_20/go-quizzes/7.go @@ -0,0 +1,23 @@ +package main + +import ( + "fmt" + "runtime" + "sync" +) + +// https://twitter.com/davecheney/status/1031699003803463680 +func main() { + var wg sync.Waitgroup + wg.Add(1) + go func() { + defer wg.Done() + runtime.Goexit() + }() + wg.Wait() + fmt.Println("Hello, playground") +} + +// Hello, playground +// It panics +// Nothing, it don'st compile diff --git a/meetup_2018_11_20/go-quizzes/8.go b/meetup_2018_11_20/go-quizzes/8.go new file mode 100644 index 0000000..1c35dc1 --- /dev/null +++ b/meetup_2018_11_20/go-quizzes/8.go @@ -0,0 +1,17 @@ +package main + +import "fmt" + +type Q struct{} + +func (Q) Hola() string { return "Bueno" } + +// https://twitter.com/davecheney/status/1031389514890006528 +func main() { + var q Q + fmt.Println(Q.Hola(q)) +} + +// Bueno +// Good +// Nada, it won't compile diff --git a/meetup_2018_11_20/go-quizzes/9.go b/meetup_2018_11_20/go-quizzes/9.go new file mode 100644 index 0000000..ef3ebd6 --- /dev/null +++ b/meetup_2018_11_20/go-quizzes/9.go @@ -0,0 +1,14 @@ +package main + +import ( + "fmt" +) + +// https://twitter.com/davecheney/status/1027826127841112064 +func main() { + fmt.Println(1) +} + +// "1" +// doesn't compile +// 1