From 1be0cb5a3fa5b2abe5f5d10ec827f06617861d4b Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Tue, 30 Sep 2014 22:07:44 +0200 Subject: First version --- src/example.go | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/example.go (limited to 'src/example.go') diff --git a/src/example.go b/src/example.go new file mode 100644 index 0000000..9196336 --- /dev/null +++ b/src/example.go @@ -0,0 +1,31 @@ +package main + +import ( + "encoding/json" + "fmt" + "os" + "vparse" +) + +func check(err error) { + if err != nil { + panic(err) + } +} + +func vToJson(filename string) string { + f, err := os.Open(filename) + check(err) + + parsed := vparse.Parse(f) + + jsonEncoded, err := json.MarshalIndent(parsed, "", "\t") + check(err) + + return string(jsonEncoded) +} + +func main() { + fmt.Println(vToJson("vcal.ics")) + fmt.Println(vToJson("vcard.vcs")) +} -- cgit v1.2.3