1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/vendor/github.com/tonistiigi/units
Tibor Vass de56a90929 vendor buildkit 6861f17f15364de0fe1fd1e6e8da07598a485123
Signed-off-by: Tibor Vass <tibor@docker.com>
2020-11-14 03:57:36 +00:00
..
bytes.go vendor buildkit 6861f17f15364de0fe1fd1e6e8da07598a485123 2020-11-14 03:57:36 +00:00
LICENSE vendor buildkit 6861f17f15364de0fe1fd1e6e8da07598a485123 2020-11-14 03:57:36 +00:00
readme.md vendor buildkit 6861f17f15364de0fe1fd1e6e8da07598a485123 2020-11-14 03:57:36 +00:00

Simple byte size formatting.

This package implements types that can be used in stdlib formatting functions like fmt.Printf to control the output of the expected printed string.

Floating point flags %f and %g print the value in using the correct unit suffix. Decimal units are default, # switches to binary units. If a value is best represented as full bytes, integer bytes are printed instead.

Examples:
fmt.Printf("%.2f", 123 * B)   => "123B"
fmt.Printf("%.2f", 1234 * B)  => "1.23kB"
fmt.Printf("%g", 1200 * B)    => "1.2kB"
fmt.Printf("%#g", 1024 * B)   => "1KiB"

Integer flag %d always prints the value in bytes. # flag adds an unit prefix.

Examples:
fmt.Printf("%d", 1234 * B)    => "1234"
fmt.Printf("%#d", 1234 * B)   => "1234B"

%v is equal to %g