From 833deb095cf7a8e0391304067c96d0c89e699e1a Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 23 May 2019 18:04:00 -0700 Subject: [PATCH] remove unused code Signed-off-by: Jeff Carr --- eventChannel.go | 97 ++++++++----------------------------------------- gorilla.go | 39 -------------------- 2 files changed, 16 insertions(+), 120 deletions(-) diff --git a/eventChannel.go b/eventChannel.go index 2ac7bb3..fa4abe3 100644 --- a/eventChannel.go +++ b/eventChannel.go @@ -2,11 +2,6 @@ package main import "fmt" import "log" -import "net" -import "os" -import "io" -import "bytes" -import "strconv" import "image/color" import "runtime" @@ -39,6 +34,22 @@ func initChannel() { mychannel = make(chan *pb.Event) } +// Marshal & Unmarshal just to see if it ever fails +func addEvent(msg *pb.Event) { + data, err := proto.Marshal(msg) + if (err != nil) { + log.Printf("addEvent() something fucked up happened in Marshal") + } + + pdata := new(pb.Event) + err = proto.Unmarshal(data, pdata) + if (err != nil) { + log.Printf("addEvent() something fucked up happened in Unmarshal") + } + + mychannel <- pdata +} + // func processEvents(mychannel chan *pb.Event) { func processEvents() { for { @@ -118,80 +129,4 @@ func ReadReceivedData(data *pb.Event, mh *gui.TableData) { log.Println(item) row += 1 } - -/* - log.Println("ReadReceivedData() mh rows") - for row := 0; row < mh.RowCount; row++ { - log.Println("\trow=", row) - log.Println("\tRows[row]=", mh.Rows[row]) - } -*/ -} - -func addSampleEvent() { - msg := pb.CreateSampleEvent() - msg.Name = "generated in addSampleEvent()" - - addEvent(msg) -} - -// Marshal & Unmarshal just to see if it ever fails -func addEvent(msg *pb.Event) { - data, err := proto.Marshal(msg) - if (err != nil) { - log.Printf("addEvent() something fucked up happened in Marshal") - } - - pdata := new(pb.Event) - err = proto.Unmarshal(data, pdata) - if (err != nil) { - log.Printf("addEvent() something fucked up happened in Unmarshal") - } - - mychannel <- pdata -} - -func sendDataToDest() { - msg := pb.CreateSampleEvent() - msg.Name = "from dnssecsockettest()" - - data, err := proto.Marshal(msg) - if (err != nil) { - log.Printf("something fucked up happened") - } - - conn, err := net.Dial("tcp", "localhost:8080") - if err != nil { - log.Println("Fatal error: %s", err.Error()) - return - } - n, err := conn.Write(data) - if err != nil { - // fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error()) - log.Println("Fatal error: %s", err.Error()) - return - } - - pb.DumpEventData(msg) - log.Println("Sent " + strconv.Itoa(n) + " bytes") - // time.Sleep(3 * 1000 * 1000 * 1000) - conn.Close() -} - -func handleProtoClient(conn net.Conn) { - fmt.Println("Connected!") - defer conn.Close() - var buf bytes.Buffer - _, err := io.Copy(&buf, conn) - if err != nil { - fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error()) - return - } - pdata := pb.CreateSampleEvent() - err = proto.Unmarshal(buf.Bytes(), pdata) - if err != nil { - fmt.Fprintf(os.Stderr, "Fatal error: %s", err.Error()) - return - } - mychannel <- pdata } diff --git a/gorilla.go b/gorilla.go index bf16186..5de8225 100644 --- a/gorilla.go +++ b/gorilla.go @@ -4,11 +4,8 @@ package main -// import "flag" import "log" import "net/url" -import "os" -import "os/signal" import "time" import "github.com/gorilla/websocket" @@ -103,39 +100,3 @@ func gorillaDial(hostname string) { time.Sleep(time.Second * 5) // try every 5 seconds } } - -// -// this is a facinating code snippet that I wanted to leave here because it is -// so interesting. Complements to the gorilla websocket example developers -// -func beautifulAndFacinatingChannel() { - done := make(chan struct{}) - - interrupt := make(chan os.Signal, 1) - signal.Notify(interrupt, os.Interrupt) - - ticker := time.NewTicker(time.Second * 1) - - defer ticker.Stop() - defer close(done) - - for { - select { - case <-done: - return - case t := <-ticker.C: - log.Println("gorilla NewTicker()", t.String()) - case <-interrupt: - log.Println("interrupt") - - gorillaSendProtobuf() - - // not sure what this does. nothing right? - select { - case <-done: - case <-time.After(time.Second): - } - return - } - } -}