Skip to content

Commit

Permalink
fix component.Reference Unmarshal
Browse files Browse the repository at this point in the history
  • Loading branch information
mkideal committed Aug 12, 2024
1 parent 3d29d73 commit b5cd537
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions component/component.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,13 @@ func (r Reference[T]) Marshal() ([]byte, error) {
}

// Unmarshal unmarshals the referenced component UUID from quoted bytes.
func (r *Reference[T]) Unmarshal(data any) error {
switch v := data.(type) {
case string:
r.uuid = v
return r.validate()
default:
return fmt.Errorf("unexpected type %T for reference UUID", data)
func (r *Reference[T]) Unmarshal(data []byte) error {
s, err := encoding.UnmarshalString(data, '\'', false)
if err != nil {
return err
}
r.uuid = s
return r.validate()
}

func (r Reference[T]) validate() error {
Expand Down

0 comments on commit b5cd537

Please sign in to comment.