aboutsummaryrefslogtreecommitdiff
path: root/src/example.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/example.go')
-rw-r--r--src/example.go31
1 files changed, 31 insertions, 0 deletions
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 @@
1package main
2
3import (
4 "encoding/json"
5 "fmt"
6 "os"
7 "vparse"
8)
9
10func check(err error) {
11 if err != nil {
12 panic(err)
13 }
14}
15
16func vToJson(filename string) string {
17 f, err := os.Open(filename)
18 check(err)
19
20 parsed := vparse.Parse(f)
21
22 jsonEncoded, err := json.MarshalIndent(parsed, "", "\t")
23 check(err)
24
25 return string(jsonEncoded)
26}
27
28func main() {
29 fmt.Println(vToJson("vcal.ics"))
30 fmt.Println(vToJson("vcard.vcs"))
31}