introspect

This commit is contained in:
Livio Amstutz 2021-02-10 16:42:01 +01:00
parent 134999bc33
commit 138da8a208
13 changed files with 305 additions and 98 deletions

View file

@ -59,6 +59,7 @@ type Prompt string
type ResponseType string
type Scopes []string
type Scope []string //TODO: hurst?
func (s Scopes) Encode() string {
return strings.Join(s, " ")
@ -73,6 +74,19 @@ func (s *Scopes) MarshalText() ([]byte, error) {
return []byte(s.Encode()), nil
}
func (s *Scope) MarshalJSON() ([]byte, error) {
return json.Marshal(Scopes(*s).Encode())
}
func (s *Scope) UnmarshalJSON(data []byte) error {
var str string
if err := json.Unmarshal(data, &str); err != nil {
return err
}
*s = Scope(strings.Split(str, " "))
return nil
}
type Time time.Time
func (t *Time) UnmarshalJSON(data []byte) error {