Skip to content

Commit

Permalink
Regurgitating some Go example code
Browse files Browse the repository at this point in the history
  • Loading branch information
ahbishop committed May 3, 2013
1 parent d42a4e1 commit 01ffa43
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions really_basic.go
@@ -1,15 +1,56 @@
package main package main

import ( import (
"fmt" "fmt"
"os" "os"
"strings" "strings"
"time"
) )


func main() func a_function(data []float32, comm_link chan float32){
{ result := float32(0)
for _, val := range data {
result += val
}
time.Sleep(1000 * time.Millisecond)
comm_link <- result
}

func thingy(derp,quit chan int){
x, y:=0,1
for{
select{
case derp <- x:
x, y = y, x+y
case <- quit:
fmt.Println("Die bitch")
return
}
}

}

func main() {
da_var := "Sup sup" da_var := "Sup sup"
if len(os.Args) > 1 { if len(os.Args) > 1 {
da_var = strings.Join(os.Args[1:], " ") da_var = strings.Join(os.Args[1:], " ")
} }
fmt.Println("I can haz: ", da_var) fmt.Println("I can haz: ", da_var)

data := []float32{3.14, 5.3, 13, 50.32, 10.13, 1513.123132143, 531234.1231}
c := make(chan float32)
go a_function(data, c)
result := <- c

fmt.Println(result)

derp := make(chan int)
quit := make(chan int)
go func() {
for i:=0; i<10; i++ {
fmt.Println(<-derp)
}
quit <-0
}()
thingy(derp, quit)
} }

0 comments on commit 01ffa43

Please sign in to comment.