// helpers to marshal / unmarshal a pin set func storeSet(d ds.Datastore, k ds.Key, val interface{}) error { buf, err := json.Marshal(val) if err != nil { return err } return d.Put(k, buf) }
func loadSet(d ds.Datastore, k ds.Key, val interface{}) error { buf, err := d.Get(k) if err != nil { return err } bf, ok := buf.([]byte) if !ok { return errors.New("invalid pin set value in datastore") } return json.Unmarshal(bf, val) }