1
0
Fork 0
photos/pkg/bucket/photometadata.go

30 lines
624 B
Go

package bucket
import (
"encoding/json"
"strings"
)
type PhotoMetadataSize struct {
Width int `json:"width"`
Height int `json:"height"`
}
func PhotoMetadataSizeUnmarshal(buf []byte) (PhotoMetadataSize, error) {
s := PhotoMetadataSize{}
err := json.Unmarshal(buf, &s)
return s, err
}
func PhotoMetadataSizeMarshal(s PhotoMetadataSize) ([]byte, error) {
return json.MarshalIndent(s, "", "\t")
}
type PhotoMetadataTitle string
type PhotoMetadataTags []string
func PhotoMetadataTagsUnmarshal(buf []byte) (PhotoMetadataTags, error) {
tags := string(buf)
return PhotoMetadataTags(strings.Split(tags, ",")), nil
}