runtime: add byte count parser for GOMEMLIMIT

This change adds a parser for the GOMEMLIMIT environment variable's
input. This environment variable accepts a number followed by an
optional prefix expressing the unit. Acceptable units include
B, KiB, MiB, GiB, TiB, where *iB is a power-of-two byte unit.

For #48409.

Change-Id: I6a3b4c02b175bfcf9c4debee6118cf5dda93bb6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/393400
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
This commit is contained in:
Michael Anthony Knyszek 2022-02-15 00:22:20 +00:00 committed by Michael Knyszek
parent 01359b4681
commit 0feebe6eb5
3 changed files with 229 additions and 12 deletions

View file

@ -33,6 +33,7 @@ var Fastlog2 = fastlog2
var Atoi = atoi
var Atoi32 = atoi32
var ParseByteCount = parseByteCount
var Nanotime = nanotime
var NetpollBreak = netpollBreak