Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
delandtj authored Jul 27, 2017
1 parent aaf43bc commit 78c9372
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,60 @@
package main

import "fmt"
import (
"fmt"
"strconv"
"time"
)

type Message struct {
Command string
Data string
}
type Event struct {
Originator string
Time string
Message
}
type iface string

func gendata(i iface) <-chan Message {
data := make(chan Message)
counter := 1
go func() {
for {
<-time.After(200 * time.Millisecond)
msg := Message{
Command: fmt.Sprintf("cmd : %s", strconv.Itoa(counter)),
Data: fmt.Sprintf("data: %s", strconv.Itoa(counter)),
}
data <- msg
counter++
}
}()
return data
}
func NewMon(iface string, c chan struct{}) {
fmt.Println("Starting new mon", iface)
c <- struct{}{}
}

func (m Message) String() string {
return fmt.Sprintf("Message:\n\tCommand: %s\n\tData: %s", m.Command, m.Data)
}
func main() {
fmt.Println("vim-go")
Events := gendata("eth0")
//interval := time.Minute * 1
var ifmoncnl chan struct{}

for {
select {
case msg := <-Events:
fmt.Println(msg.String())
if msg.Command == "newmon" {
go NewMon(msg.Data, ifmoncnl)
}
default:
}
<-time.After(200 * time.Millisecond)
}
}

0 comments on commit 78c9372

Please sign in to comment.