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
+2 -2
View File
@@ -16,14 +16,14 @@ package js
import (
"context"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/hmaps"
"github.com/gohugoio/hugo/resources/resource"
)
// BatcherClient is used to do JS batch operations.
type BatcherClient interface {
New(id string) (Batcher, error)
Store() *maps.Cache[string, Batcher]
Store() *hmaps.Cache[string, Batcher]
}
// BatchPackage holds a group of JavaScript resources.
+14 -14
View File
@@ -31,9 +31,9 @@ import (
"github.com/evanw/esbuild/pkg/api"
"github.com/gohugoio/hugo/cache/dynacache"
"github.com/gohugoio/hugo/common/hmaps"
"github.com/gohugoio/hugo/common/hsync"
"github.com/gohugoio/hugo/common/hugio"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/paths"
"github.com/gohugoio/hugo/deps"
"github.com/gohugoio/hugo/helpers"
@@ -74,8 +74,8 @@ func NewBatcherClient(deps *deps.Deps) (js.BatcherClient, error) {
d: deps,
buildClient: NewBuildClient(deps.BaseFs.Assets, deps.ResourceSpec),
createClient: create.New(deps.ResourceSpec),
batcherStore: maps.NewCache[string, js.Batcher](),
bundlesStore: maps.NewCache[string, js.BatchPackage](),
batcherStore: hmaps.NewCache[string, js.Batcher](),
bundlesStore: hmaps.NewCache[string, js.BatchPackage](),
}
deps.BuildEndListeners.Add(func(...any) bool {
@@ -196,8 +196,8 @@ type BatcherClient struct {
createClient *create.Client
buildClient *BuildClient
batcherStore *maps.Cache[string, js.Batcher]
bundlesStore *maps.Cache[string, js.BatchPackage]
batcherStore *hmaps.Cache[string, js.Batcher]
bundlesStore *hmaps.Cache[string, js.BatchPackage]
}
// New creates a new Batcher with the given ID.
@@ -279,7 +279,7 @@ func (c *BatcherClient) New(id string) (js.Batcher, error) {
return b, nil
}
func (c *BatcherClient) Store() *maps.Cache[string, js.Batcher] {
func (c *BatcherClient) Store() *hmaps.Cache[string, js.Batcher] {
return c.batcherStore
}
@@ -435,15 +435,15 @@ func (b *batcher) doBuild(ctx context.Context) (*Package, error) {
}
state := struct {
importResource *maps.Cache[string, resource.Resource]
resultResource *maps.Cache[string, resource.Resource]
importerImportContext *maps.Cache[string, importContext]
pathGroup *maps.Cache[string, string]
importResource *hmaps.Cache[string, resource.Resource]
resultResource *hmaps.Cache[string, resource.Resource]
importerImportContext *hmaps.Cache[string, importContext]
pathGroup *hmaps.Cache[string, string]
}{
importResource: maps.NewCache[string, resource.Resource](),
resultResource: maps.NewCache[string, resource.Resource](),
importerImportContext: maps.NewCache[string, importContext](),
pathGroup: maps.NewCache[string, string](),
importResource: hmaps.NewCache[string, resource.Resource](),
resultResource: hmaps.NewCache[string, resource.Resource](),
importerImportContext: hmaps.NewCache[string, importContext](),
pathGroup: hmaps.NewCache[string, string](),
}
multihostBasePaths := b.client.d.ResourceSpec.MultihostTargetBasePaths
+2 -2
View File
@@ -19,8 +19,8 @@ import (
"path/filepath"
"strings"
"github.com/gohugoio/hugo/common/hmaps"
"github.com/gohugoio/hugo/common/hugio"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/paths"
"github.com/gohugoio/hugo/identity"
@@ -299,7 +299,7 @@ func (opts *Options) compile() (err error) {
var defines map[string]string
if opts.Defines != nil {
defines = maps.ToStringMapString(opts.Defines)
defines = hmaps.ToStringMapString(opts.Defines)
}
var drop api.Drop
+4 -4
View File
@@ -18,16 +18,16 @@ import (
"fmt"
"os"
"path/filepath"
"slices"
"strings"
"github.com/evanw/esbuild/pkg/api"
"github.com/gohugoio/hugo/common/maps"
"github.com/gohugoio/hugo/common/hmaps"
"github.com/gohugoio/hugo/hugofs"
"github.com/gohugoio/hugo/identity"
"github.com/gohugoio/hugo/resources"
"github.com/gohugoio/hugo/resources/resource"
"github.com/spf13/afero"
"slices"
)
const (
@@ -132,12 +132,12 @@ func ResolveResource(impPath string, resourceGetter resource.ResourceGetter) (r
}
func newFSResolver(fs afero.Fs) *fsResolver {
return &fsResolver{fs: fs, resolved: maps.NewCache[string, *hugofs.FileMeta]()}
return &fsResolver{fs: fs, resolved: hmaps.NewCache[string, *hugofs.FileMeta]()}
}
type fsResolver struct {
fs afero.Fs
resolved *maps.Cache[string, *hugofs.FileMeta]
resolved *hmaps.Cache[string, *hugofs.FileMeta]
}
func (r *fsResolver) resolveComponent(impPath string) *hugofs.FileMeta {
+3 -3
View File
@@ -30,9 +30,9 @@ import (
"github.com/bep/textandbinarywriter"
"github.com/gohugoio/hugo/common/hmaps"
"github.com/gohugoio/hugo/common/hstrings"
"github.com/gohugoio/hugo/common/hugio"
"github.com/gohugoio/hugo/common/maps"
"golang.org/x/sync/errgroup"
"github.com/tetratelabs/wazero"
@@ -253,7 +253,7 @@ func (d *dispatcher[Q, R]) newCall(q Message[Q]) (*call[Q, R], error) {
if err := q.init(); err != nil {
return nil, err
}
responseKinds := maps.NewMap[string, bool]()
responseKinds := hmaps.NewMap[string, bool]()
for _, rk := range q.Header.ResponseKinds {
responseKinds.Set(rk, true)
}
@@ -424,7 +424,7 @@ func (d *dispatcher[Q, R]) pendingCall(id uint32) *call[Q, R] {
type call[Q, R any] struct {
request Message[Q]
response Message[R]
responseKinds *maps.Map[string, bool]
responseKinds *hmaps.Map[string, bool]
err error
donec chan *call[Q, R]
}