1
2
3
4
5 package a
6
7 import (
8 "errors"
9 "strings"
10 )
11
12 var G interface{}
13
14 func Unmarshal(data []byte, o interface{}) error {
15 G = o
16 v, ok := o.(*map[string]interface{})
17 if !ok {
18 return errors.New("eek")
19 }
20 vals := make(map[string]interface{})
21 s := string(data)
22 items := strings.Split(s, " ")
23 var err error
24 for _, item := range items {
25 vals[item] = s
26 if item == "error" {
27 err = errors.New("ouch")
28 }
29 }
30 *v = vals
31 return err
32 }
33
View as plain text