Rename common/maps to common/hmaps (#14384)

Go's stdlid now has a maps package, which is very useful. We have been using imports on the form `xmaps "maps"`, but auto import tools doesn't handle this, which is annoying.

I have been thinking about this for some time, but have been holding back because of all the import changes. However, now is a good time to do this, with very little unmerged code.
This commit is contained in:
Bjørn Erik Pedersen
2026-01-16 11:47:46 +01:00
committed by GitHub
parent 94f1ede3aa
commit 608ed09a0a
103 changed files with 591 additions and 604 deletions
+4 -5
View File
@@ -14,20 +14,19 @@
package resource
import (
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/hmaps"
"github.com/spf13/cast"
)
func Param(r ResourceParamsProvider, fallback maps.Params, key any) (any, error) {
func Param(r ResourceParamsProvider, fallback hmaps.Params, key any) (any, error) {
keyStr, err := cast.ToStringE(key)
if err != nil {
return nil, err
}
if fallback == nil {
return maps.GetNestedParam(keyStr, ".", r.Params())
return hmaps.GetNestedParam(keyStr, ".", r.Params())
}
return maps.GetNestedParam(keyStr, ".", r.Params(), fallback)
return hmaps.GetNestedParam(keyStr, ".", r.Params(), fallback)
}
+2 -3
View File
@@ -17,8 +17,7 @@ import (
"strings"
"time"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/hmaps"
"github.com/gohugoio/hugo/helpers"
"github.com/pelletier/go-toml/v2"
@@ -38,7 +37,7 @@ func GetParamToLower(r Resource, key string) any {
}
func getParam(r Resource, key string, stringToLower bool) any {
v, err := maps.GetNestedParam(key, ".", r.Params())
v, err := hmaps.GetNestedParam(key, ".", r.Params())
if v == nil || err != nil {
return nil
+3 -3
View File
@@ -20,8 +20,8 @@ import (
"slices"
"strings"
"github.com/gohugoio/hugo/common/hmaps"
"github.com/gohugoio/hugo/common/hreflect"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/paths"
"github.com/gohugoio/hugo/hugofs/hglob"
"github.com/spf13/cast"
@@ -330,7 +330,7 @@ func NewCachedResourceGetter(os ...any) *cachedResourceGetter {
}
return &cachedResourceGetter{
cache: maps.NewCache[string, Resource](),
cache: hmaps.NewCache[string, Resource](),
delegate: getters,
}
}
@@ -352,7 +352,7 @@ var (
)
type cachedResourceGetter struct {
cache *maps.Cache[string, Resource]
cache *hmaps.Cache[string, Resource]
delegate ResourceGetter
}
+2 -2
View File
@@ -16,7 +16,7 @@ package resource
import (
"context"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/hmaps"
"github.com/gohugoio/hugo/common/types"
"github.com/gohugoio/hugo/langs"
"github.com/gohugoio/hugo/media"
@@ -139,7 +139,7 @@ type NameNormalizedProvider interface {
type ResourceParamsProvider interface {
// Params set in front matter for this resource.
Params() maps.Params
Params() hmaps.Params
}
type ResourceDataProvider interface {