26 lines
411 B
Go
26 lines
411 B
Go
|
package models
|
||
|
|
||
|
import (
|
||
|
"io"
|
||
|
"encoding/json"
|
||
|
)
|
||
|
|
||
|
type Tag struct {
|
||
|
Id string `json:"id",omitempty`
|
||
|
Name string `json:"name",omitempty`
|
||
|
Resources []string `json:"resources"`
|
||
|
}
|
||
|
|
||
|
func NewTag() *Tag {
|
||
|
return &Tag{}
|
||
|
}
|
||
|
|
||
|
func NewTagFromJson(jsonReader io.ReadCloser) (*Tag, error) {
|
||
|
t := NewTag()
|
||
|
err := json.NewDecoder(jsonReader).Decode(t)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
return t, nil
|
||
|
}
|