init
All checks were successful
continuous-integration/drone/tag Build is passing

This commit is contained in:
2024-10-04 14:55:21 +03:00
parent 01de72c729
commit 779818e067
9 changed files with 775 additions and 0 deletions

20
size_text.go Normal file
View File

@@ -0,0 +1,20 @@
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
}