build(deps): bump github.com/labstack/gommon from 0.3.1 to 0.4.0
Bumps [github.com/labstack/gommon](https://github.com/labstack/gommon) from 0.3.1 to 0.4.0. - [Release notes](https://github.com/labstack/gommon/releases) - [Commits](https://github.com/labstack/gommon/compare/v0.3.1...v0.4.0) --- updated-dependencies: - dependency-name: github.com/labstack/gommon dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
parent
9a7027ef77
commit
b7418d6bba
5 changed files with 154 additions and 44 deletions
2
go.mod
2
go.mod
|
|
@ -33,7 +33,7 @@ require (
|
||||||
github.com/julienschmidt/httprouter v1.3.0
|
github.com/julienschmidt/httprouter v1.3.0
|
||||||
github.com/kolo/xmlrpc v0.0.0-20201022064351-38db28db192b
|
github.com/kolo/xmlrpc v0.0.0-20201022064351-38db28db192b
|
||||||
github.com/labstack/echo/v4 v4.9.0
|
github.com/labstack/echo/v4 v4.9.0
|
||||||
github.com/labstack/gommon v0.3.1
|
github.com/labstack/gommon v0.4.0
|
||||||
github.com/opencontainers/go-digest v1.0.0
|
github.com/opencontainers/go-digest v1.0.0
|
||||||
github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198
|
github.com/opencontainers/image-spec v1.0.3-0.20220114050600-8b9d41f48198
|
||||||
github.com/openshift-online/ocm-sdk-go v0.1.287
|
github.com/openshift-online/ocm-sdk-go v0.1.287
|
||||||
|
|
|
||||||
3
go.sum
3
go.sum
|
|
@ -1164,8 +1164,9 @@ github.com/labstack/echo/v4 v4.3.0/go.mod h1:PvmtTvhVqKDzDQy4d3bWzPjZLzom4iQbAZy
|
||||||
github.com/labstack/echo/v4 v4.9.0 h1:wPOF1CE6gvt/kmbMR4dGzWvHMPT+sAEUJOwOTtvITVY=
|
github.com/labstack/echo/v4 v4.9.0 h1:wPOF1CE6gvt/kmbMR4dGzWvHMPT+sAEUJOwOTtvITVY=
|
||||||
github.com/labstack/echo/v4 v4.9.0/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks=
|
github.com/labstack/echo/v4 v4.9.0/go.mod h1:xkCDAdFCIf8jsFQ5NnbK7oqaF/yU1A1X20Ltm0OvSks=
|
||||||
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
|
github.com/labstack/gommon v0.3.0/go.mod h1:MULnywXg0yavhxWKc+lOruYdAhDwPK9wf0OL7NoOu+k=
|
||||||
github.com/labstack/gommon v0.3.1 h1:OomWaJXm7xR6L1HmEtGyQf26TEn7V6X88mktX9kee9o=
|
|
||||||
github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM=
|
github.com/labstack/gommon v0.3.1/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM=
|
||||||
|
github.com/labstack/gommon v0.4.0 h1:y7cvthEAEbU0yHOf4axH8ZG2NH8knB9iNSoTO8dyIk8=
|
||||||
|
github.com/labstack/gommon v0.4.0/go.mod h1:uW6kP17uPlLJsD3ijUYn3/M5bAxtlZhMI6m3MFxTMTM=
|
||||||
github.com/ldez/gomoddirectives v0.2.2/go.mod h1:cpgBogWITnCfRq2qGoDkKMEVSaarhdBr6g8G04uz6d0=
|
github.com/ldez/gomoddirectives v0.2.2/go.mod h1:cpgBogWITnCfRq2qGoDkKMEVSaarhdBr6g8G04uz6d0=
|
||||||
github.com/ldez/tagliatelle v0.2.0/go.mod h1:8s6WJQwEYHbKZDsp/LjArytKOG8qaMrKQQ3mFukHs88=
|
github.com/ldez/tagliatelle v0.2.0/go.mod h1:8s6WJQwEYHbKZDsp/LjArytKOG8qaMrKQQ3mFukHs88=
|
||||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||||
|
|
|
||||||
185
vendor/github.com/labstack/gommon/bytes/bytes.go
generated
vendored
185
vendor/github.com/labstack/gommon/bytes/bytes.go
generated
vendored
|
|
@ -12,19 +12,31 @@ type (
|
||||||
Bytes struct{}
|
Bytes struct{}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// binary units (IEC 60027)
|
||||||
const (
|
const (
|
||||||
_ = 1.0 << (10 * iota) // ignore first value by assigning to blank identifier
|
_ = 1.0 << (10 * iota) // ignore first value by assigning to blank identifier
|
||||||
KB
|
KiB
|
||||||
MB
|
MiB
|
||||||
GB
|
GiB
|
||||||
TB
|
TiB
|
||||||
PB
|
PiB
|
||||||
EB
|
EiB
|
||||||
|
)
|
||||||
|
|
||||||
|
// decimal units (SI international system of units)
|
||||||
|
const (
|
||||||
|
KB = 1000
|
||||||
|
MB = KB * 1000
|
||||||
|
GB = MB * 1000
|
||||||
|
TB = GB * 1000
|
||||||
|
PB = TB * 1000
|
||||||
|
EB = PB * 1000
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
pattern = regexp.MustCompile(`(?i)^(-?\d+(?:\.\d+)?)\s?([KMGTPE]B?|B?)$`)
|
patternBinary = regexp.MustCompile(`(?i)^(-?\d+(?:\.\d+)?)\s?([KMGTPE]iB?)$`)
|
||||||
global = New()
|
patternDecimal = regexp.MustCompile(`(?i)^(-?\d+(?:\.\d+)?)\s?([KMGTPE]B?|B?)$`)
|
||||||
|
global = New()
|
||||||
)
|
)
|
||||||
|
|
||||||
// New creates a Bytes instance.
|
// New creates a Bytes instance.
|
||||||
|
|
@ -32,44 +44,97 @@ func New() *Bytes {
|
||||||
return &Bytes{}
|
return &Bytes{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format formats bytes integer to human readable string.
|
// Format formats bytes integer to human readable string according to IEC 60027.
|
||||||
// For example, 31323 bytes will return 30.59KB.
|
// For example, 31323 bytes will return 30.59KB.
|
||||||
func (*Bytes) Format(b int64) string {
|
func (b *Bytes) Format(value int64) string {
|
||||||
|
return b.FormatBinary(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FormatBinary formats bytes integer to human readable string according to IEC 60027.
|
||||||
|
// For example, 31323 bytes will return 30.59KB.
|
||||||
|
func (*Bytes) FormatBinary(value int64) string {
|
||||||
multiple := ""
|
multiple := ""
|
||||||
value := float64(b)
|
val := float64(value)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
case b >= EB:
|
case value >= EiB:
|
||||||
value /= EB
|
val /= EiB
|
||||||
multiple = "EB"
|
multiple = "EiB"
|
||||||
case b >= PB:
|
case value >= PiB:
|
||||||
value /= PB
|
val /= PiB
|
||||||
multiple = "PB"
|
multiple = "PiB"
|
||||||
case b >= TB:
|
case value >= TiB:
|
||||||
value /= TB
|
val /= TiB
|
||||||
multiple = "TB"
|
multiple = "TiB"
|
||||||
case b >= GB:
|
case value >= GiB:
|
||||||
value /= GB
|
val /= GiB
|
||||||
multiple = "GB"
|
multiple = "GiB"
|
||||||
case b >= MB:
|
case value >= MiB:
|
||||||
value /= MB
|
val /= MiB
|
||||||
multiple = "MB"
|
multiple = "MiB"
|
||||||
case b >= KB:
|
case value >= KiB:
|
||||||
value /= KB
|
val /= KiB
|
||||||
multiple = "KB"
|
multiple = "KiB"
|
||||||
case b == 0:
|
case value == 0:
|
||||||
return "0"
|
return "0"
|
||||||
default:
|
default:
|
||||||
return strconv.FormatInt(b, 10) + "B"
|
return strconv.FormatInt(value, 10) + "B"
|
||||||
}
|
}
|
||||||
|
|
||||||
return fmt.Sprintf("%.2f%s", value, multiple)
|
return fmt.Sprintf("%.2f%s", val, multiple)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FormatDecimal formats bytes integer to human readable string according to SI international system of units.
|
||||||
|
// For example, 31323 bytes will return 31.32KB.
|
||||||
|
func (*Bytes) FormatDecimal(value int64) string {
|
||||||
|
multiple := ""
|
||||||
|
val := float64(value)
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case value >= EB:
|
||||||
|
val /= EB
|
||||||
|
multiple = "EB"
|
||||||
|
case value >= PB:
|
||||||
|
val /= PB
|
||||||
|
multiple = "PB"
|
||||||
|
case value >= TB:
|
||||||
|
val /= TB
|
||||||
|
multiple = "TB"
|
||||||
|
case value >= GB:
|
||||||
|
val /= GB
|
||||||
|
multiple = "GB"
|
||||||
|
case value >= MB:
|
||||||
|
val /= MB
|
||||||
|
multiple = "MB"
|
||||||
|
case value >= KB:
|
||||||
|
val /= KB
|
||||||
|
multiple = "KB"
|
||||||
|
case value == 0:
|
||||||
|
return "0"
|
||||||
|
default:
|
||||||
|
return strconv.FormatInt(value, 10) + "B"
|
||||||
|
}
|
||||||
|
|
||||||
|
return fmt.Sprintf("%.2f%s", val, multiple)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse parses human readable bytes string to bytes integer.
|
// Parse parses human readable bytes string to bytes integer.
|
||||||
// For example, 6GB (6G is also valid) will return 6442450944.
|
// For example, 6GiB (6Gi is also valid) will return 6442450944, and
|
||||||
func (*Bytes) Parse(value string) (i int64, err error) {
|
// 6GB (6G is also valid) will return 6000000000.
|
||||||
parts := pattern.FindStringSubmatch(value)
|
func (b *Bytes) Parse(value string) (int64, error) {
|
||||||
|
|
||||||
|
i, err := b.ParseBinary(value)
|
||||||
|
if err == nil {
|
||||||
|
return i, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return b.ParseDecimal(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseBinary parses human readable bytes string to bytes integer.
|
||||||
|
// For example, 6GiB (6Gi is also valid) will return 6442450944.
|
||||||
|
func (*Bytes) ParseBinary(value string) (i int64, err error) {
|
||||||
|
parts := patternBinary.FindStringSubmatch(value)
|
||||||
if len(parts) < 3 {
|
if len(parts) < 3 {
|
||||||
return 0, fmt.Errorf("error parsing value=%s", value)
|
return 0, fmt.Errorf("error parsing value=%s", value)
|
||||||
}
|
}
|
||||||
|
|
@ -81,8 +146,38 @@ func (*Bytes) Parse(value string) (i int64, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch multiple {
|
switch multiple {
|
||||||
|
case "KI", "KIB":
|
||||||
|
return int64(bytes * KiB), nil
|
||||||
|
case "MI", "MIB":
|
||||||
|
return int64(bytes * MiB), nil
|
||||||
|
case "GI", "GIB":
|
||||||
|
return int64(bytes * GiB), nil
|
||||||
|
case "TI", "TIB":
|
||||||
|
return int64(bytes * TiB), nil
|
||||||
|
case "PI", "PIB":
|
||||||
|
return int64(bytes * PiB), nil
|
||||||
|
case "EI", "EIB":
|
||||||
|
return int64(bytes * EiB), nil
|
||||||
default:
|
default:
|
||||||
return int64(bytes), nil
|
return int64(bytes), nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ParseDecimal parses human readable bytes string to bytes integer.
|
||||||
|
// For example, 6GB (6G is also valid) will return 6000000000.
|
||||||
|
func (*Bytes) ParseDecimal(value string) (i int64, err error) {
|
||||||
|
parts := patternDecimal.FindStringSubmatch(value)
|
||||||
|
if len(parts) < 3 {
|
||||||
|
return 0, fmt.Errorf("error parsing value=%s", value)
|
||||||
|
}
|
||||||
|
bytesString := parts[1]
|
||||||
|
multiple := strings.ToUpper(parts[2])
|
||||||
|
bytes, err := strconv.ParseFloat(bytesString, 64)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
switch multiple {
|
||||||
case "K", "KB":
|
case "K", "KB":
|
||||||
return int64(bytes * KB), nil
|
return int64(bytes * KB), nil
|
||||||
case "M", "MB":
|
case "M", "MB":
|
||||||
|
|
@ -95,15 +190,27 @@ func (*Bytes) Parse(value string) (i int64, err error) {
|
||||||
return int64(bytes * PB), nil
|
return int64(bytes * PB), nil
|
||||||
case "E", "EB":
|
case "E", "EB":
|
||||||
return int64(bytes * EB), nil
|
return int64(bytes * EB), nil
|
||||||
|
default:
|
||||||
|
return int64(bytes), nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Format wraps global Bytes's Format function.
|
// Format wraps global Bytes's Format function.
|
||||||
func Format(b int64) string {
|
func Format(value int64) string {
|
||||||
return global.Format(b)
|
return global.Format(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FormatBinary wraps global Bytes's FormatBinary function.
|
||||||
|
func FormatBinary(value int64) string {
|
||||||
|
return global.FormatBinary(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
// FormatDecimal wraps global Bytes's FormatDecimal function.
|
||||||
|
func FormatDecimal(value int64) string {
|
||||||
|
return global.FormatDecimal(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse wraps global Bytes's Parse function.
|
// Parse wraps global Bytes's Parse function.
|
||||||
func Parse(val string) (int64, error) {
|
func Parse(value string) (int64, error) {
|
||||||
return global.Parse(val)
|
return global.Parse(value)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
vendor/github.com/labstack/gommon/log/log.go
generated
vendored
6
vendor/github.com/labstack/gommon/log/log.go
generated
vendored
|
|
@ -391,7 +391,7 @@ func (l *Logger) log(level Lvl, format string, args ...interface{}) {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
s := buf.String()
|
s := buf.String()
|
||||||
i := buf.Len() - 1
|
i := buf.Len() - 1
|
||||||
if s[i] == '}' {
|
if i >= 0 && s[i] == '}' {
|
||||||
// JSON header
|
// JSON header
|
||||||
buf.Truncate(i)
|
buf.Truncate(i)
|
||||||
buf.WriteByte(',')
|
buf.WriteByte(',')
|
||||||
|
|
@ -404,7 +404,9 @@ func (l *Logger) log(level Lvl, format string, args ...interface{}) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Text header
|
// Text header
|
||||||
buf.WriteByte(' ')
|
if len(s) > 0 {
|
||||||
|
buf.WriteByte(' ')
|
||||||
|
}
|
||||||
buf.WriteString(message)
|
buf.WriteString(message)
|
||||||
}
|
}
|
||||||
buf.WriteByte('\n')
|
buf.WriteByte('\n')
|
||||||
|
|
|
||||||
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
|
|
@ -412,7 +412,7 @@ github.com/kr/text
|
||||||
## explicit
|
## explicit
|
||||||
github.com/labstack/echo/v4
|
github.com/labstack/echo/v4
|
||||||
github.com/labstack/echo/v4/middleware
|
github.com/labstack/echo/v4/middleware
|
||||||
# github.com/labstack/gommon v0.3.1
|
# github.com/labstack/gommon v0.4.0
|
||||||
## explicit
|
## explicit
|
||||||
github.com/labstack/gommon/bytes
|
github.com/labstack/gommon/bytes
|
||||||
github.com/labstack/gommon/color
|
github.com/labstack/gommon/color
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue