From d38431533e517dfa3efc48d219701b25f77289ac Mon Sep 17 00:00:00 2001 From: "Paul Buetow (europa)" Date: Mon, 25 May 2015 01:10:10 +0100 Subject: move --- Makefile | 2 +- gstat/main.go | 46 ++++++++++++++++++++++++++++++++++++++++++++++ main/main.go | 46 ---------------------------------------------- 3 files changed, 47 insertions(+), 47 deletions(-) create mode 100644 gstat/main.go delete mode 100644 main/main.go diff --git a/Makefile b/Makefile index 8cda6f7..b08c4f0 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,2 @@ install: - go install github.com/buetow/gstat/main + go install github.com/buetow/gstat/gstat diff --git a/gstat/main.go b/gstat/main.go new file mode 100644 index 0000000..6cef683 --- /dev/null +++ b/gstat/main.go @@ -0,0 +1,46 @@ +package main + +import ( + "fmt" + "github.com/buetow/gstat/process" + "time" +) + +func gather(timer <-chan bool, processes chan<- process.Process) { + for { + switch <-timer { + case false: + { + break + } + case true: + { + process.Gather(processes) + } + } + } + close(processes) +} + +func receive(processes <-chan process.Process) { + for process := range processes { + process.Print() + } +} + +func main() { + timer := make(chan bool) + res := make(chan process.Process) + + go gather(timer, res) + go receive(res) + + for counter := 0; counter < 3; counter++ { + timer <- true + time.Sleep(time.Second) + fmt.Printf("Next... %d\n", counter) + } + timer <- false + + fmt.Println("Good bye") +} diff --git a/main/main.go b/main/main.go deleted file mode 100644 index 6cef683..0000000 --- a/main/main.go +++ /dev/null @@ -1,46 +0,0 @@ -package main - -import ( - "fmt" - "github.com/buetow/gstat/process" - "time" -) - -func gather(timer <-chan bool, processes chan<- process.Process) { - for { - switch <-timer { - case false: - { - break - } - case true: - { - process.Gather(processes) - } - } - } - close(processes) -} - -func receive(processes <-chan process.Process) { - for process := range processes { - process.Print() - } -} - -func main() { - timer := make(chan bool) - res := make(chan process.Process) - - go gather(timer, res) - go receive(res) - - for counter := 0; counter < 3; counter++ { - timer <- true - time.Sleep(time.Second) - fmt.Printf("Next... %d\n", counter) - } - timer <- false - - fmt.Println("Good bye") -} -- cgit v1.2.3