-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjunk.go
37 lines (27 loc) · 765 Bytes
/
junk.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package main
// import (
// "fmt"
// "encoding/json"
// )
func main1(){
// recRawMsg := []byte (`{"name":"channel add", "data":{"name":"Hardware Support"}}`)
// var recMessage Message
// err := json.Unmarshal(recRawMsg, &recMessage)
// if err != nil{
// fmt.Println(err)
// return
// }
// fmt.Printf("%#v\n", recMessage) // %#v prints out the struct with the field names
// if recMessage.Name == "channel add"{
// channel, err := addChannel(recMessage.Data)
// var sendMessage Message
// sendMessage.Name = "channel add"
// sendMessage.Data = channel
// sendRawMsg, err := json.Marshal(sendMessage) // returns a byte array
// if err != nil{
// fmt.Println(err)
// return
// }
// fmt.Println(string(sendRawMsg))
// }
}