From 726b399e4747032a3d052339cd62c57ae5b6767c Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Sat, 15 Jul 2017 01:26:39 +0100 Subject: pipeline from spool to worker is done -- added examples --- sandpit/test_parse_message.go | 44 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 sandpit/test_parse_message.go (limited to 'sandpit/test_parse_message.go') diff --git a/sandpit/test_parse_message.go b/sandpit/test_parse_message.go new file mode 100644 index 0000000..f60f03c --- /dev/null +++ b/sandpit/test_parse_message.go @@ -0,0 +1,44 @@ +package main + +import( + "fmt" + "github.com/go-yaml/yaml" + "io/ioutil" + "log" + "os" +) + + +var orig_msg= ` +--- +m_id: 123456 +m_repo: master +m_branch: test_branch +m_oldrev: a1b2c3d4e5f6 +m_newrev: 9a8b7c6d5e4f +... + +` + + +func main(){ + + var msg *SCORSHmsg + msg = new(SCORSHmsg) + + + fname := "spool/test_2" + + data, err := ioutil.ReadFile(fname) + if err != nil { + log.Printf("Unable to open file: %s\n", fname) + os.Exit(1) + } + err = yaml.Unmarshal([]byte(data), msg) + if err != nil{ + log.Printf("Error parsing message: %s", err) + } + + fmt.Printf("%s\n", msg) + +} -- cgit v1.2.3