Files
bytesize/size_text.go
andrey1s 779818e067
All checks were successful
continuous-integration/drone/tag Build is passing
init
2024-10-04 14:55:21 +03:00

21 lines
302 B
Go

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
}