Permalink
Browse files

Merge branch 'master' of github.com:lagomeetup/talks

  • Loading branch information...
2 parents a77db9b + 76069b9 commit b575f5011a95006de3c22edd096d34a44b8ebca9 @tebeka tebeka committed Mar 20, 2013
Showing with 1,359 additions and 3 deletions.
  1. +2 −1 2012/go-stdlib-part-1-io.slide
  2. BIN 2012/go-stdlib-part-1/bin/present
  3. +17 −0 2013/go-stdlib-part-2/I_like_to_spawn.go
  4. +14 −0 2013/go-stdlib-part-2/ch_of_ch.go
  5. +22 −0 2013/go-stdlib-part-2/channel_copy.go
  6. +16 −0 2013/go-stdlib-part-2/channel_one.go
  7. +21 −0 2013/go-stdlib-part-2/channel_range.go
  8. +15 −0 2013/go-stdlib-part-2/channel_read_on_close.go
  9. +18 −0 2013/go-stdlib-part-2/channel_read_on_close_other.go
  10. +22 −0 2013/go-stdlib-part-2/channel_reference.go
  11. +14 −0 2013/go-stdlib-part-2/channel_simple.go
  12. +14 −0 2013/go-stdlib-part-2/channel_simple_fix.go
  13. +22 −0 2013/go-stdlib-part-2/function_literal_gotcha.go
  14. +29 −0 2013/go-stdlib-part-2/function_literal_gotcha_fix.go
  15. +19 −0 2013/go-stdlib-part-2/function_literals.go
  16. +15 −0 2013/go-stdlib-part-2/go_1k_one_thread.go
  17. +11 −0 2013/go-stdlib-part-2/go_1k_one_thread_2.go
  18. +22 −0 2013/go-stdlib-part-2/go_1k_one_thread_runtime.go
  19. +24 −0 2013/go-stdlib-part-2/go_1k_one_thread_yield.go
  20. +14 −0 2013/go-stdlib-part-2/main_simple.go
  21. +15 −0 2013/go-stdlib-part-2/main_simple_fix.go
  22. +22 −0 2013/go-stdlib-part-2/max_procs.go
  23. +20 −0 2013/go-stdlib-part-2/max_procs_2.go
  24. +14 −0 2013/go-stdlib-part-2/python_1k_threads.py
  25. +25 −0 2013/go-stdlib-part-2/select_timeout.go
  26. +12 −0 2013/go-stdlib-part-2/ticker_example.go
  27. +12 −0 2013/go-stdlib-part-2/time_format.go
  28. +10 −0 2013/go-stdlib-part-2/time_sleep.go
  29. +19 −0 2013/go-stdlib-part-2/wait_group_panic.go
  30. +19 −0 2013/go-stdlib-part-2/wait_group_simple.go
  31. +19 −0 2013/go-stdlib-part-2/wait_group_simple_fix.go
  32. +308 −0 2013/go-stdlib-part2-io-concurrency.slide
  33. +147 −0 2013/go-stdlib-part3-reflection.slide
  34. +30 −0 2013/go-stdlib-part3/reflect_array.go
  35. +25 −0 2013/go-stdlib-part3/reflect_call.go
  36. +36 −0 2013/go-stdlib-part3/reflect_change_struct.go
  37. +24 −0 2013/go-stdlib-part3/reflect_chann.go
  38. +42 −0 2013/go-stdlib-part3/reflect_interface.go
  39. +17 −0 2013/go-stdlib-part3/reflect_interface_wrong.go
  40. +31 −0 2013/go-stdlib-part3/reflect_kind.go
  41. +24 −0 2013/go-stdlib-part3/reflect_map.go
  42. +24 −0 2013/go-stdlib-part3/reflect_new.go
  43. +36 −0 2013/go-stdlib-part3/reflect_settable.go
  44. +15 −0 2013/go-stdlib-part3/reflect_slice.go
  45. +32 −0 2013/go-stdlib-part3/reflect_struct.go
  46. +11 −0 2013/go-stdlib-part3/reflection1.go
  47. +30 −0 2013/go-stdlib-part3/reflection2.go
  48. BIN 2013/nopanic.jpg
  49. BIN 2013/panic.jpg
  50. BIN 2013/wat_grande.jpg
  51. +9 −2 README.md
@@ -13,9 +13,10 @@ Part 1: I/O
Fabrizio Milo
Los Angeles Meetup Group - November 20 2012
@fabmilo
-mistobaan@gmail.com
+lagomeetup@gmail.com
http://www.meetup.com/Los-Angeles-Gophers/
+
* What will be covered:
- io
- os
Binary file not shown.
@@ -0,0 +1,17 @@
+package main
+
+import (
+ "runtime"
+)
+
+func main() {
+ ch := make(chan int)
+ ch2 := make(chan int)
+ for {
+ go func() {
+ ch <- 0
+ }()
+ runtime.Gosched()
+ }
+ ch2 <- 0
+}
@@ -0,0 +1,14 @@
+package main
+
+
+type ch2 chan chan interface{}
+
+
+func main() {
+ mych2 := make(ch2,1)
+ ch := make(chan interface{},1)
+ ch <- 1
+ mych2 <- ch
+ <- <- mych2
+ close(mych2)
+}
@@ -0,0 +1,22 @@
+package main
+
+import (
+ "fmt"
+)
+
+type MyType struct {
+ state int
+}
+
+func main() {
+ // START1 OMIT
+ my_channel := make(chan MyType, 1)
+ reference := MyType{}
+ reference.state = 100 // HL
+ my_channel <- reference
+ reference.state = 200 // HL
+ fmt.Printf("%v\n", reference)
+ received := <-my_channel
+ fmt.Printf("%v\n", received)
+ // END1 OMIT
+}
@@ -0,0 +1,16 @@
+package main
+
+import (
+ "fmt"
+)
+
+func main() {
+ // START1 OMIT
+ blocking := make(chan int, 1)
+ go func () { blocking <- 1 }()
+ // go func () { blocking <- 1 }()
+ <-blocking
+ <-blocking
+ fmt.Printf("Completed\n")
+ // END1 OMIT
+}
@@ -0,0 +1,21 @@
+package main
+
+import (
+ "fmt"
+)
+
+func main() {
+
+ blocking := make(chan int, 5)
+
+ for i := 0; i < 10; i++ {
+ blocking <- i
+ }
+
+ //close(blocking)
+
+ for value := range blocking {
+ fmt.Printf("Completed with %v\n", value)
+ }
+
+}
@@ -0,0 +1,15 @@
+package main
+
+import (
+ "fmt"
+)
+
+func main() {
+ // START1 OMIT
+ blocking := make(chan int)
+ // blocking := make(chan string)
+ close(blocking)
+ value := <-blocking
+ fmt.Printf("Completed with %v\n", value)
+ // END1 OMIT
+}
@@ -0,0 +1,18 @@
+package main
+
+import (
+ "fmt"
+)
+
+func main() {
+ // START1 OMIT
+ blocking := make(chan int, 1)
+ // blocking <-1
+ close(blocking)
+ if value, ok := <-blocking; ok {
+ fmt.Printf("Completed with %v\n", value)
+ } else {
+ fmt.Printf("Channel is closed\n")
+ }
+ // END1 OMIT
+}
@@ -0,0 +1,22 @@
+package main
+
+import (
+ "fmt"
+)
+
+// START1 OMIT
+type MyType struct {
+ state int
+}
+
+func main() {
+ my_channel := make(chan *MyType, 1)
+ reference := new(MyType)
+ reference.state = 100 // HL
+ my_channel <- reference
+ reference.state = 200 // HL
+ fmt.Printf("%v\n", reference)
+ received := <-my_channel
+ fmt.Printf("%v\n", received)
+ // END1 OMIT
+}
@@ -0,0 +1,14 @@
+package main
+
+import (
+ "fmt"
+)
+
+func main() {
+ // START1 OMIT
+ blocking := make(chan int)
+ blocking <- 1
+ <-blocking
+ fmt.Printf("Completed\n")
+ // END1 OMIT
+}
@@ -0,0 +1,14 @@
+package main
+
+import (
+ "fmt"
+)
+
+func main() {
+ // START1 OMIT
+ blocking := make(chan int)
+ go func() { blocking <- 1 }()
+ <-blocking
+ fmt.Printf("Completed\n")
+ // END1 OMIT
+}
@@ -0,0 +1,22 @@
+package main
+
+import (
+ "fmt"
+)
+
+type Callback func()
+
+func main() {
+ // START1 OMIT
+ funcArray := make([]Callback, 0)
+
+ for i := 0; i < 10; i++ {
+ aNewFunc := func() { fmt.Printf("%d\n", i) } // HL
+ funcArray = append(funcArray, aNewFunc)
+ }
+
+ for i := 0; i < 10; i++ {
+ funcArray[i]()
+ }
+ // END1 OMIT
+}
@@ -0,0 +1,29 @@
+package main
+
+import (
+ "fmt"
+)
+
+type Callback func()
+
+// START2 OMIT
+func mkCallback(i int) Callback {
+ return func() { fmt.Printf("%d\n", i) } // HL
+}
+
+// END2 OMIT
+
+func main() {
+ // START1 OMIT
+ funcArray := make([]Callback, 0)
+
+ for i := 0; i < 10; i++ {
+ aNewFunc := mkCallback(i) // HL
+ funcArray = append(funcArray, aNewFunc)
+ }
+
+ for i := 0; i < 10; i++ {
+ funcArray[i]()
+ }
+ // END1 OMIT
+}
@@ -0,0 +1,19 @@
+package main
+
+import (
+ "fmt"
+)
+
+// START1 OMIT
+type Callback func() // HL
+// END1 OMIT
+
+func main() {
+ //START2 OMIT
+ var my_function Callback // HL
+ my_function = func() {
+ fmt.Printf("%d\n", 10)
+ }
+ my_function()
+ //END2 OMIT
+}
@@ -0,0 +1,15 @@
+package main
+
+func main() {
+ // START1 OMIT
+ for i := 0; i < 1000; i++ {
+ go func() {
+ for {
+ }
+ }()
+ }
+
+ for {
+ }
+ // END1 OMIT
+}
@@ -0,0 +1,11 @@
+package main
+
+func main() {
+ // START1 OMIT
+ for i:= 0; i < 1000; i++ {
+ go func() { for {} } ()
+ }
+
+ fmt.Scanf("Wait For It:%d", &i)
+ // END1 OMIT
+}
@@ -0,0 +1,22 @@
+package main
+
+import (
+ "fmt"
+ "runtime"
+)
+
+func main() {
+ // START1 OMIT
+ for i := 0; i < 1000; i++ {
+ go func() {
+ for {
+ }
+ }()
+ fmt.Printf("GoRoutines: %d \n", runtime.NumGoroutine())
+ }
+
+ for {
+ fmt.Printf("GoRoutines: %d \n", runtime.NumGoroutine())
+ }
+ // END1 OMIT
+}
@@ -0,0 +1,24 @@
+package main
+
+import (
+ "fmt"
+ "runtime"
+)
+
+func main() {
+ // START1 OMIT
+ for i := 0; i < 1000; i++ {
+ go func() {
+ for {
+ runtime.Gosched() // HL
+ }
+ }()
+ fmt.Printf("GoRoutines: %d \n", runtime.NumGoroutine() )
+ }
+
+ for {
+ fmt.Printf("GoRoutines: %d \n", runtime.NumGoroutine() )
+ runtime.Gosched() // HL
+ }
+ // END1 OMIT
+}
@@ -0,0 +1,14 @@
+package main
+
+import (
+ "fmt"
+)
+
+func status() {
+ fmt.Printf("It works !")
+}
+
+
+func main() {
+ go status()
+}
@@ -0,0 +1,15 @@
+package main
+
+import (
+ "fmt"
+)
+
+func status() {
+ fmt.Printf("It works !")
+}
+
+
+func main() {
+ go status()
+ for {}
+}
Oops, something went wrong.

0 comments on commit b575f50

Please sign in to comment.