You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
302 B

package bytesize
import "fmt"
func (s Size) MarshalText() ([]byte, error) {
val := s.String()
return []byte(val), nil
}
func (s *Size) UnmarshalText(text []byte) error {
val, err := Parse(string(text))
if err != nil {
return fmt.Errorf("%w: unmarshal text", err)
}
*s = val
return nil
}