Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/alecthomas/units
/ functions
Functions
26 in github.com/alecthomas/units
⨍
Functions
26
◇
Types & classes
4
↓ 33 callers
Method
String
()
bytes.go:39
↓ 10 callers
Function
ParseBase2Bytes
ParseBase2Bytes supports both iB and B in base-2 multipliers. That is, KB and KiB are both 1024. However "kB", which is the correct SI spelling of 100
bytes.go:31
↓ 10 callers
Function
ParseStrictBytes
ParseStrictBytes supports both iB and B suffixes for base 2 and metric, respectively. That is, KiB represents 1024 and kB, KB represent 1000.
bytes.go:203
↓ 9 callers
Method
UnmarshalText
UnmarshalText implement encoding.TextUnmarshaler to process json/yaml.
bytes.go:49
↓ 8 callers
Method
Round
Round returns Base2Bytes with all but the first n units zeroed out. So that e.g. 1GiB1MiB1KiB → 1GiB1MiB, if n is 2.
bytes.go:76
↓ 8 callers
Method
Round
Round returns MetricBytes with all but the first n units zeroed out. So that e.g. 1GB1MB1KB → 1GB1MB, if n is 2.
bytes.go:165
↓ 5 callers
Function
ParseMetricBytes
ParseMetricBytes parses base-10 metric byte units. That is, KB is 1000 bytes.
bytes.go:134
↓ 5 callers
Function
ParseUnit
(s string, unitMap map[string]float64)
util.go:52
↓ 4 callers
Method
Floor
Floor returns Base2Bytes with all but the largest unit zeroed out. So that e.g. 1GiB1MiB1KiB → 1GiB.
bytes.go:56
↓ 4 callers
Method
Floor
Floor returns MetricBytes with all but the largest unit zeroed out. So that e.g. 1GB1MB1KB → 1GB.
bytes.go:145
↓ 3 callers
Function
MakeUnitMap
(suffix, shortSuffix string, scale int64)
si.go:16
↓ 2 callers
Function
ToString
(n int64, scale int64, suffix, baseSuffix string)
util.go:13
↓ 2 callers
Function
leadingInt
never printed leadingInt consumes the leading [0-9]* from s.
util.go:36
Method
MarshalText
MarshalText implement encoding.TextMarshaler to process json/yaml.
bytes.go:44
Method
String
TODO: represents 1000B as uppercase "KB", while SI standard requires "kB".
bytes.go:140
Function
TestBase2BytesString
(t *testing.T)
bytes_test.go:10
Function
TestBase2BytesUnmarshalText
(t *testing.T)
bytes_test.go:45
Function
TestBase2Floor
(t *testing.T)
bytes_test.go:75
Function
TestBase2Round
(t *testing.T)
bytes_test.go:86
Function
TestJSON
(t *testing.T)
bytes_test.go:194
Function
TestMetricBytesString
(t *testing.T)
bytes_test.go:105
Function
TestMetricFloor
(t *testing.T)
bytes_test.go:164
Function
TestMetricRound
(t *testing.T)
bytes_test.go:175
Function
TestParseBase2Bytes
(t *testing.T)
bytes_test.go:16
Function
TestParseMetricBytes
(t *testing.T)
bytes_test.go:112
Function
TestParseStrictBytes
(t *testing.T)
bytes_test.go:130