1
0
mirror of https://github.com/Luzifer/cloudkeys-go.git synced 2024-09-16 14:18:32 +00:00
cloudkeys-go/dataObject.go

37 lines
659 B
Go

package main
import (
"bytes"
"encoding/gob"
"encoding/json"
"io"
)
type authorizedAccounts []authorizedAccount
type authorizedAccount struct {
Name string
UserFile string
}
func init() {
gob.Register(authorizedAccounts{})
}
type dataObject struct {
MetaData struct {
Version string `json:"version"`
Password string `json:"password"`
} `json:"metadata"`
Data string `json:"data"`
}
func readDataObject(in io.Reader) (*dataObject, error) {
t := &dataObject{}
return t, json.NewDecoder(in).Decode(t)
}
func (d *dataObject) GetData() (io.Reader, error) {
buf := bytes.NewBuffer([]byte{})
return buf, json.NewEncoder(buf).Encode(d)
}