Skip to content

Commit

Permalink
chore: lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
adityathebe committed Jul 20, 2023
1 parent 100df9a commit 364101a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ linters:
# - gci
# - gochecknoglobals
# - gochecknoinits
- gocognit
# - gocognit
- goconst
- gocritic
# - gocyclo
Expand All @@ -63,7 +63,7 @@ linters:
# - lll
- misspell
- nakedret
- nestif
# - nestif
# - nlreturn
# - noctx
# - nolintlint
Expand Down
10 changes: 5 additions & 5 deletions funcs/strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ func CreateStringFuncs(ctx context.Context) map[string]interface{} {
return f
}

func (ns StringFuncs) HumanDuration(in interface{}) (string, error) {
func (f StringFuncs) HumanDuration(in interface{}) (string, error) {
return gompstrings.HumanDuration(in), nil
}

func (ns StringFuncs) HumanSize(in interface{}) (string, error) {
func (f StringFuncs) HumanSize(in interface{}) (string, error) {
return gompstrings.HumanBytes(in), nil
}

func (ns StringFuncs) Semver(in string) (*semver.Version, error) {
func (f StringFuncs) Semver(in string) (*semver.Version, error) {
return gompstrings.Semver(in)
}

func (ns StringFuncs) SemverMap(in string) (map[string]string, error) {
func (f StringFuncs) SemverMap(in string) (map[string]string, error) {
v, err := gompstrings.Semver(in)
if err != nil {
return nil, err
Expand All @@ -102,7 +102,7 @@ func (ns StringFuncs) SemverMap(in string) (map[string]string, error) {
return res, nil
}

func (ns StringFuncs) SemverCompare(v1, v2 string) (bool, error) {
func (f StringFuncs) SemverCompare(v1, v2 string) (bool, error) {
return gompstrings.SemverCompare(v1, v2)
}

Expand Down
12 changes: 6 additions & 6 deletions strings/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,22 @@ func HumanBytes(size interface{}) string {
switch {
case bytes >= EXABYTE:
unit = "E"
value = value / EXABYTE
value /= EXABYTE
case bytes >= PETABYTE:
unit = "P"
value = value / PETABYTE
value /= PETABYTE
case bytes >= TERABYTE:
unit = "T"
value = value / TERABYTE
value /= TERABYTE
case bytes >= GIGABYTE:
unit = "G"
value = value / GIGABYTE
value /= GIGABYTE
case bytes >= MEGABYTE:
unit = "M"
value = value / MEGABYTE
value /= MEGABYTE
case bytes >= KILOBYTE:
unit = "K"
value = value / KILOBYTE
value /= KILOBYTE
case bytes >= BYTE:
unit = "B"
case bytes == 0:
Expand Down
3 changes: 2 additions & 1 deletion strings/duration.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func (d Duration) String() string {
u = -u
}

//nolint:gocritic
if u < uint64(Second) {
// Special case: if duration is smaller than a second,
// use smaller units, like 1.2ms
Expand Down Expand Up @@ -409,7 +410,7 @@ func parseDuration(s string) (Duration, error) {
func HumanDuration(duration interface{}) string {
switch v := duration.(type) {
case int64:
return Duration(time.Duration(int64(v))).String()
return Duration(time.Duration(v)).String()
case float64:
return Duration(time.Duration(int64(v))).String()
case time.Duration:
Expand Down

0 comments on commit 364101a

Please sign in to comment.