This commit is contained in:
Livio Amstutz 2021-02-12 07:02:10 +01:00
parent 01ff740f4e
commit 0c7b2605bd
8 changed files with 51 additions and 65 deletions

View file

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