Skip to content

Commit

Permalink
ref(tmpl): use humanize funcs directly in func map, no need to alias
Browse files Browse the repository at this point in the history
  • Loading branch information
tjhop committed Aug 10, 2024
1 parent b287c01 commit 5ddfe49
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
5 changes: 3 additions & 2 deletions internal/manager/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"text/template"

"github.com/dominikbraun/graph"
"github.com/dustin/go-humanize"
"github.com/oklog/ulid/v2"
"github.com/prometheus/client_golang/prometheus"
"mvdan.cc/sh/v3/syntax"
Expand Down Expand Up @@ -52,8 +53,8 @@ func NewManager(id string) *Manager {
funcs := template.FuncMap{
"isIPv4": isIPv4,
"isIPv6": isIPv6,
"humanizeBytes": humanizeBytes,
"humanizeIBytes": humanizeIBytes,
"humanizeBytes": humanize.Bytes,
"humanizeIBytes": humanize.IBytes,
}

return &Manager{
Expand Down
9 changes: 0 additions & 9 deletions internal/manager/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"sync"
"text/template"

"github.com/dustin/go-humanize"
"github.com/go-sprout/sprout"
socktmpl "github.com/hashicorp/go-sockaddr/template"
"github.com/oklog/ulid/v2"
Expand Down Expand Up @@ -152,11 +151,3 @@ func isIPv6(s string) bool {
ip6 := ip.To16()
return ip6 != nil
}

func humanizeBytes(b uint64) string {
return humanize.Bytes(b)
}

func humanizeIBytes(b uint64) string {
return humanize.IBytes(b)
}

0 comments on commit 5ddfe49

Please sign in to comment.