docker / go-units

Parse and print size and time units in human-readable format
https://godoc.org/github.com/docker/go-units
Apache License 2.0
218 stars 38 forks source link

FromHumanSize accepts MiB but returns MB #31

Open smoser opened 5 years ago

smoser commented 5 years ago

One might expect that FromHumanSize("1MiB") would either

Currently it does not raise error and returns units.MB (1000 1000 1000)

smoser commented 5 years ago

units-fromhumansize.go.txt

kolyshkin commented 2 years ago

Yes, this is the way it works. I think we can fix this and accept e.g. KB as "human size" (1000) and KiB as "computer size" (1024), defaulting to "human size" for "FromHumanSize" and to "computer size" for "RAMInBytes".

Problem is, this will make things slightly incompatible with the current behavior.