MCPcopy Create free account
hub / github.com/labstack/gommon / Parse

Method Parse

bytes/bytes.go:124–132  ·  view source on GitHub ↗

Parse parses human readable bytes string to bytes integer. For example, 6GiB (6Gi is also valid) will return 6442450944, and 6GB (6G is also valid) will return 6000000000.

(value string)

Source from the content-addressed store, hash-verified

122// For example, 6GiB (6Gi is also valid) will return 6442450944, and
123// 6GB (6G is also valid) will return 6000000000.
124func (b *Bytes) Parse(value string) (int64, error) {
125
126 i, err := b.ParseBinary(value)
127 if err == nil {
128 return i, err
129 }
130
131 return b.ParseDecimal(value)
132}
133
134// ParseBinary parses human readable bytes string to bytes integer.
135// For example, 6GiB (6Gi is also valid) will return 6442450944.

Callers 1

ParseFunction · 0.80

Calls 2

ParseBinaryMethod · 0.95
ParseDecimalMethod · 0.95

Tested by

no test coverage detected