Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add FromSize method #37

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Add FromSize method #37

wants to merge 2 commits into from

Commits on Dec 15, 2020

  1. Improve regexp to reject '1.3.3' as a valid size

    Currently, the regexp will match any number of (.\d+) occurrences
    because of its use of (.\d+)*. This commit changes this to (.\d+)? as
    a valid decimal number will have at most one decimal part.
    cfergeau committed Dec 15, 2020
    Configuration menu
    Copy the full SHA
    27b1dec View commit details
    Browse the repository at this point in the history
  2. Add FromSize method

    go-units API is missing a method which would parse "32kB" as 32000
    bytes, and "32kiB" as 32768 bytes.
    FromHumanSize() parses both as 32000 bytes, while RAMInBytes() parses
    both as 32768 bytes.
    
    This commit introduces a FromSize method a more litteral parsing of the
    unit is needed. Modifiers without a unit ('32k') will be assumed to be
    using a decimal unit, so they'll equivalent to 32 kB/32000 bytes.
    
    This fixes docker#31
    cfergeau committed Dec 15, 2020
    Configuration menu
    Copy the full SHA
    dc6d94f View commit details
    Browse the repository at this point in the history