Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-18 00:03:27 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-18 00:03:27 +0300
commitb80853de90b10171155b8f3fde47d64ec7bfa0dd (patch)
tree435d3dbf7a495a0c6ce64c9769e037179aa0d27b /resources
parent423594e03a906ef4150f433666ff588b022c3c92 (diff)
all: gofmt -w -r 'interface{} -> any' .
Updates #9687
Diffstat (limited to 'resources')
-rw-r--r--resources/errorResource.go6
-rw-r--r--resources/image.go2
-rw-r--r--resources/image_extended_test.go1
-rw-r--r--resources/image_test.go4
-rw-r--r--resources/images/color_test.go2
-rw-r--r--resources/images/config.go4
-rw-r--r--resources/images/config_test.go18
-rw-r--r--resources/images/exif/exif.go12
-rw-r--r--resources/images/filters.go32
-rw-r--r--resources/images/image.go2
-rw-r--r--resources/images/webp/webp.go1
-rw-r--r--resources/images/webp/webp_notavailable.go1
-rw-r--r--resources/internal/key.go4
-rw-r--r--resources/page/page.go25
-rw-r--r--resources/page/page_data.go2
-rw-r--r--resources/page/page_lazy_contentprovider.go6
-rw-r--r--resources/page/page_marshaljson.autogen.go4
-rw-r--r--resources/page/page_matcher.go4
-rw-r--r--resources/page/page_matcher_test.go14
-rw-r--r--resources/page/page_nop.go30
-rw-r--r--resources/page/pagegroup.go16
-rw-r--r--resources/page/pagemeta/page_frontmatter.go8
-rw-r--r--resources/page/pagemeta/page_frontmatter_test.go14
-rw-r--r--resources/page/pagemeta/pagemeta.go2
-rw-r--r--resources/page/pagemeta/pagemeta_test.go14
-rw-r--r--resources/page/pages.go8
-rw-r--r--resources/page/pages_language_merge.go4
-rw-r--r--resources/page/pages_related.go4
-rw-r--r--resources/page/pages_related_test.go6
-rw-r--r--resources/page/pages_sort.go4
-rw-r--r--resources/page/pages_sort_test.go12
-rw-r--r--resources/page/pages_test.go4
-rw-r--r--resources/page/pagination.go14
-rw-r--r--resources/page/pagination_test.go4
-rw-r--r--resources/page/site.go8
-rw-r--r--resources/page/testhelpers_test.go38
-rw-r--r--resources/page/weighted.go4
-rw-r--r--resources/postpub/fields.go8
-rw-r--r--resources/postpub/fields_test.go2
-rw-r--r--resources/postpub/postpub.go14
-rw-r--r--resources/resource.go20
-rw-r--r--resources/resource/params.go2
-rw-r--r--resources/resource/resource_helpers.go10
-rw-r--r--resources/resource/resources.go2
-rw-r--r--resources/resource/resourcetypes.go8
-rw-r--r--resources/resource_cache.go16
-rw-r--r--resources/resource_factories/create/remote.go8
-rw-r--r--resources/resource_factories/create/remote_test.go12
-rw-r--r--resources/resource_metadata.go4
-rw-r--r--resources/resource_metadata_test.go24
-rw-r--r--resources/resource_spec.go2
-rw-r--r--resources/resource_test.go2
-rw-r--r--resources/resource_transformers/babel/babel.go10
-rw-r--r--resources/resource_transformers/htesting/testhelpers.go2
-rw-r--r--resources/resource_transformers/integrity/integrity_test.go2
-rw-r--r--resources/resource_transformers/js/build.go4
-rw-r--r--resources/resource_transformers/js/options.go8
-rw-r--r--resources/resource_transformers/js/options_test.go2
-rw-r--r--resources/resource_transformers/postcss/postcss.go6
-rw-r--r--resources/resource_transformers/postcss/postcss_test.go4
-rw-r--r--resources/resource_transformers/templates/execute_as_template.go4
-rw-r--r--resources/resource_transformers/tocss/dartsass/client.go4
-rw-r--r--resources/resource_transformers/tocss/dartsass/transform.go2
-rw-r--r--resources/resource_transformers/tocss/scss/client.go2
-rw-r--r--resources/resource_transformers/tocss/scss/client_extended.go1
-rw-r--r--resources/resource_transformers/tocss/scss/client_notavailable.go1
-rw-r--r--resources/resource_transformers/tocss/scss/tocss.go1
-rw-r--r--resources/testhelpers_test.go2
-rw-r--r--resources/transform.go18
-rw-r--r--resources/transform_test.go6
70 files changed, 278 insertions, 273 deletions
diff --git a/resources/errorResource.go b/resources/errorResource.go
index a7f99c2b7..70f05d3f7 100644
--- a/resources/errorResource.go
+++ b/resources/errorResource.go
@@ -56,7 +56,7 @@ func (e *errorResource) ReadSeekCloser() (hugio.ReadSeekCloser, error) {
panic(e.error)
}
-func (e *errorResource) Content() (interface{}, error) {
+func (e *errorResource) Content() (any, error) {
panic(e.error)
}
@@ -88,7 +88,7 @@ func (e *errorResource) Params() maps.Params {
panic(e.error)
}
-func (e *errorResource) Data() interface{} {
+func (e *errorResource) Data() any {
panic(e.error)
}
@@ -116,7 +116,7 @@ func (e *errorResource) Resize(spec string) (resource.Image, error) {
panic(e.error)
}
-func (e *errorResource) Filter(filters ...interface{}) (resource.Image, error) {
+func (e *errorResource) Filter(filters ...any) (resource.Image, error) {
panic(e.error)
}
diff --git a/resources/image.go b/resources/image.go
index 3a790a217..86cc3251a 100644
--- a/resources/image.go
+++ b/resources/image.go
@@ -238,7 +238,7 @@ func (i *imageResource) Fill(spec string) (resource.Image, error) {
return img, err
}
-func (i *imageResource) Filter(filters ...interface{}) (resource.Image, error) {
+func (i *imageResource) Filter(filters ...any) (resource.Image, error) {
conf := images.GetDefaultImageConfig("filter", i.Proc.Cfg)
var gfilters []gift.Filter
diff --git a/resources/image_extended_test.go b/resources/image_extended_test.go
index 6c657a92a..a0b274f3e 100644
--- a/resources/image_extended_test.go
+++ b/resources/image_extended_test.go
@@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+//go:build extended
// +build extended
package resources
diff --git a/resources/image_test.go b/resources/image_test.go
index e85fe9b9a..a7577e0a6 100644
--- a/resources/image_test.go
+++ b/resources/image_test.go
@@ -351,7 +351,7 @@ func TestImageWithMetadata(t *testing.T) {
image := fetchSunset(c)
- meta := []map[string]interface{}{
+ meta := []map[string]any{
{
"title": "My Sunset",
"name": "Sunset #:counter",
@@ -694,7 +694,7 @@ func TestImageOperationsGolden(t *testing.T) {
f.Overlay(gopher.(images.ImageSource), 20, 30),
f.Text("No options"),
f.Text("This long text is to test line breaks. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat."),
- f.Text("Hugo rocks!", map[string]interface{}{"x": 3, "y": 3, "size": 20, "color": "#fc03b1"}),
+ f.Text("Hugo rocks!", map[string]any{"x": 3, "y": 3, "size": 20, "color": "#fc03b1"}),
}
resized, err := orig.Fill("400x200 center")
diff --git a/resources/images/color_test.go b/resources/images/color_test.go
index 0a1718180..52871e691 100644
--- a/resources/images/color_test.go
+++ b/resources/images/color_test.go
@@ -25,7 +25,7 @@ func TestHexStringToColor(t *testing.T) {
for _, test := range []struct {
arg string
- expect interface{}
+ expect any
}{
{"f", false},
{"#f", false},
diff --git a/resources/images/config.go b/resources/images/config.go
index f9a3fa09d..e72bf5485 100644
--- a/resources/images/config.go
+++ b/resources/images/config.go
@@ -131,9 +131,9 @@ var defaultImaging = Imaging{
Quality: defaultJPEGQuality,
}
-func DecodeConfig(m map[string]interface{}) (ImagingConfig, error) {
+func DecodeConfig(m map[string]any) (ImagingConfig, error) {
if m == nil {
- m = make(map[string]interface{})
+ m = make(map[string]any)
}
i := ImagingConfig{
diff --git a/resources/images/config_test.go b/resources/images/config_test.go
index 7b2459250..816a69cf9 100644
--- a/resources/images/config_test.go
+++ b/resources/images/config_test.go
@@ -23,7 +23,7 @@ import (
func TestDecodeConfig(t *testing.T) {
c := qt.New(t)
- m := map[string]interface{}{
+ m := map[string]any{
"quality": 42,
"resampleFilter": "NearestNeighbor",
"anchor": "topLeft",
@@ -37,7 +37,7 @@ func TestDecodeConfig(t *testing.T) {
c.Assert(imaging.ResampleFilter, qt.Equals, "nearestneighbor")
c.Assert(imaging.Anchor, qt.Equals, "topleft")
- m = map[string]interface{}{}
+ m = map[string]any{}
imagingConfig, err = DecodeConfig(m)
c.Assert(err, qt.IsNil)
@@ -45,30 +45,30 @@ func TestDecodeConfig(t *testing.T) {
c.Assert(imaging.ResampleFilter, qt.Equals, "box")
c.Assert(imaging.Anchor, qt.Equals, "smart")
- _, err = DecodeConfig(map[string]interface{}{
+ _, err = DecodeConfig(map[string]any{
"quality": 123,
})
c.Assert(err, qt.Not(qt.IsNil))
- _, err = DecodeConfig(map[string]interface{}{
+ _, err = DecodeConfig(map[string]any{
"resampleFilter": "asdf",
})
c.Assert(err, qt.Not(qt.IsNil))
- _, err = DecodeConfig(map[string]interface{}{
+ _, err = DecodeConfig(map[string]any{
"anchor": "asdf",
})
c.Assert(err, qt.Not(qt.IsNil))
- imagingConfig, err = DecodeConfig(map[string]interface{}{
+ imagingConfig, err = DecodeConfig(map[string]any{
"anchor": "Smart",
})
imaging = imagingConfig.Cfg
c.Assert(err, qt.IsNil)
c.Assert(imaging.Anchor, qt.Equals, "smart")
- imagingConfig, err = DecodeConfig(map[string]interface{}{
- "exif": map[string]interface{}{
+ imagingConfig, err = DecodeConfig(map[string]any{
+ "exif": map[string]any{
"disableLatLong": true,
},
})
@@ -81,7 +81,7 @@ func TestDecodeConfig(t *testing.T) {
func TestDecodeImageConfig(t *testing.T) {
for i, this := range []struct {
in string
- expect interface{}
+ expect any
}{
{"300x400", newImageConfig(300, 400, 75, 0, "box", "smart", "")},
{"300x400 #fff", newImageConfig(300, 400, 75, 0, "box", "smart", "fff")},
diff --git a/resources/images/exif/exif.go b/resources/images/exif/exif.go
index 5406665cf..2841bd153 100644
--- a/resources/images/exif/exif.go
+++ b/resources/images/exif/exif.go
@@ -134,7 +134,7 @@ func (d *Decoder) Decode(r io.Reader) (ex *Exif, err error) {
lat, long, _ = x.LatLong()
}
- walker := &exifWalker{x: x, vals: make(map[string]interface{}), includeMatcher: d.includeFieldsRe, excludeMatcher: d.excludeFieldsrRe}
+ walker := &exifWalker{x: x, vals: make(map[string]any), includeMatcher: d.includeFieldsRe, excludeMatcher: d.excludeFieldsrRe}
if err = x.Walk(walker); err != nil {
return
}
@@ -144,7 +144,7 @@ func (d *Decoder) Decode(r io.Reader) (ex *Exif, err error) {
return
}
-func decodeTag(x *_exif.Exif, f _exif.FieldName, t *tiff.Tag) (interface{}, error) {
+func decodeTag(x *_exif.Exif, f _exif.FieldName, t *tiff.Tag) (any, error) {
switch t.Format() {
case tiff.StringVal, tiff.UndefVal:
s := nullString(t.Val)
@@ -158,7 +158,7 @@ func decodeTag(x *_exif.Exif, f _exif.FieldName, t *tiff.Tag) (interface{}, erro
return "unknown", nil
}
- var rv []interface{}
+ var rv []any
for i := 0; i < int(t.Count); i++ {
switch t.Format() {
@@ -203,7 +203,7 @@ func tryParseDate(x *_exif.Exif, s string) (time.Time, error) {
type exifWalker struct {
x *_exif.Exif
- vals map[string]interface{}
+ vals map[string]any
includeMatcher *regexp.Regexp
excludeMatcher *regexp.Regexp
}
@@ -246,10 +246,10 @@ func init() {
}
}
-type Tags map[string]interface{}
+type Tags map[string]any
func (v *Tags) UnmarshalJSON(b []byte) error {
- vv := make(map[string]interface{})
+ vv := make(map[string]any)
if err := tcodec.Unmarshal(b, &vv); err != nil {
return err
}
diff --git a/resources/images/filters.go b/resources/images/filters.go
index fd7e31457..90667af7c 100644
--- a/resources/images/filters.go
+++ b/resources/images/filters.go
@@ -32,7 +32,7 @@ type Filters struct {
}
// Overlay creates a filter that overlays src at position x y.
-func (*Filters) Overlay(src ImageSource, x, y interface{}) gift.Filter {
+func (*Filters) Overlay(src ImageSource, x, y any) gift.Filter {
return filter{
Options: newFilterOpts(src.Key(), x, y),
Filter: overlayFilter{src: src, x: cast.ToInt(x), y: cast.ToInt(y)},
@@ -40,7 +40,7 @@ func (*Filters) Overlay(src ImageSource, x, y interface{}) gift.Filter {
}
// Text creates a filter that draws text with the given options.
-func (*Filters) Text(text string, options ...interface{}) gift.Filter {
+func (*Filters) Text(text string, options ...any) gift.Filter {
tf := textFilter{
text: text,
color: "#ffffff",
@@ -95,7 +95,7 @@ func (*Filters) Text(text string, options ...interface{}) gift.Filter {
// Brightness creates a filter that changes the brightness of an image.
// The percentage parameter must be in range (-100, 100).
-func (*Filters) Brightness(percentage interface{}) gift.Filter {
+func (*Filters) Brightness(percentage any) gift.Filter {
return filter{
Options: newFilterOpts(percentage),
Filter: gift.Brightness(cast.ToFloat32(percentage)),
@@ -104,7 +104,7 @@ func (*Filters) Brightness(percentage interface{}) gift.Filter {
// ColorBalance creates a filter that changes the color balance of an image.
// The percentage parameters for each color channel (red, green, blue) must be in range (-100, 500).
-func (*Filters) ColorBalance(percentageRed, percentageGreen, percentageBlue interface{}) gift.Filter {
+func (*Filters) ColorBalance(percentageRed, percentageGreen, percentageBlue any) gift.Filter {
return filter{
Options: newFilterOpts(percentageRed, percentageGreen, percentageBlue),
Filter: gift.ColorBalance(cast.ToFloat32(percentageRed), cast.ToFloat32(percentageGreen), cast.ToFloat32(percentageBlue)),
@@ -115,7 +115,7 @@ func (*Filters) ColorBalance(percentageRed, percentageGreen, percentageBlue inte
// The hue parameter is the angle on the color wheel, typically in range (0, 360).
// The saturation parameter must be in range (0, 100).
// The percentage parameter specifies the strength of the effect, it must be in range (0, 100).
-func (*Filters) Colorize(hue, saturation, percentage interface{}) gift.Filter {
+func (*Filters) Colorize(hue, saturation, percentage any) gift.Filter {
return filter{
Options: newFilterOpts(hue, saturation, percentage),
Filter: gift.Colorize(cast.ToFloat32(hue), cast.ToFloat32(saturation), cast.ToFloat32(percentage)),
@@ -124,7 +124,7 @@ func (*Filters) Colorize(hue, saturation, percentage interface{}) gift.Filter {
// Contrast creates a filter that changes the contrast of an image.
// The percentage parameter must be in range (-100, 100).
-func (*Filters) Contrast(percentage interface{}) gift.Filter {
+func (*Filters) Contrast(percentage any) gift.Filter {
return filter{
Options: newFilterOpts(percentage),
Filter: gift.Contrast(cast.ToFloat32(percentage)),
@@ -134,7 +134,7 @@ func (*Filters) Contrast(percentage interface{}) gift.Filter {
// Gamma creates a filter that performs a gamma correction on an image.
// The gamma parameter must be positive. Gamma = 1 gives the original image.
// Gamma less than 1 darkens the image and gamma greater than 1 lightens it.
-func (*Filters) Gamma(gamma interface{}) gift.Filter {
+func (*Filters) Gamma(gamma any) gift.Filter {
return filter{
Options: newFilterOpts(gamma),
Filter: gift.Gamma(cast.ToFloat32(gamma)),
@@ -142,7 +142,7 @@ func (*Filters) Gamma(gamma interface{}) gift.Filter {
}
// GaussianBlur creates a filter that applies a gaussian blur to an image.
-func (*Filters) GaussianBlur(sigma interface{}) gift.Filter {
+func (*Filters) GaussianBlur(sigma any) gift.Filter {
return filter{
Options: newFilterOpts(sigma),
Filter: gift.GaussianBlur(cast.ToFloat32(sigma)),
@@ -158,7 +158,7 @@ func (*Filters) Grayscale() gift.Filter {
// Hue creates a filter that rotates the hue of an image.
// The hue angle shift is typically in range -180 to 180.
-func (*Filters) Hue(shift interface{}) gift.Filter {
+func (*Filters) Hue(shift any) gift.Filter {
return filter{
Options: newFilterOpts(shift),
Filter: gift.Hue(cast.ToFloat32(shift)),
@@ -173,7 +173,7 @@ func (*Filters) Invert() gift.Filter {
}
// Pixelate creates a filter that applies a pixelation effect to an image.
-func (*Filters) Pixelate(size interface{}) gift.Filter {
+func (*Filters) Pixelate(size any) gift.Filter {
return filter{
Options: newFilterOpts(size),
Filter: gift.Pixelate(cast.ToInt(size)),
@@ -181,7 +181,7 @@ func (*Filters) Pixelate(size interface{}) gift.Filter {
}
// Saturation creates a filter that changes the saturation of an image.
-func (*Filters) Saturation(percentage interface{}) gift.Filter {
+func (*Filters) Saturation(percentage any) gift.Filter {
return filter{
Options: newFilterOpts(percentage),
Filter: gift.Saturation(cast.ToFloat32(percentage)),
@@ -189,7 +189,7 @@ func (*Filters) Saturation(percentage interface{}) gift.Filter {
}
// Sepia creates a filter that produces a sepia-toned version of an image.
-func (*Filters) Sepia(percentage interface{}) gift.Filter {
+func (*Filters) Sepia(percentage any) gift.Filter {
return filter{
Options: newFilterOpts(percentage),
Filter: gift.Sepia(cast.ToFloat32(percentage)),
@@ -198,7 +198,7 @@ func (*Filters) Sepia(percentage interface{}) gift.Filter {
// Sigmoid creates a filter that changes the contrast of an image using a sigmoidal function and returns the adjusted image.
// It's a non-linear contrast change useful for photo adjustments as it preserves highlight and shadow detail.
-func (*Filters) Sigmoid(midpoint, factor interface{}) gift.Filter {
+func (*Filters) Sigmoid(midpoint, factor any) gift.Filter {
return filter{
Options: newFilterOpts(midpoint, factor),
Filter: gift.Sigmoid(cast.ToFloat32(midpoint), cast.ToFloat32(factor)),
@@ -210,7 +210,7 @@ func (*Filters) Sigmoid(midpoint, factor interface{}) gift.Filter {
// Sigma must be positive. Sharpen radius roughly equals 3 * sigma.
// The amount parameter controls how much darker and how much lighter the edge borders become. Typically between 0.5 and 1.5.
// The threshold parameter controls the minimum brightness change that will be sharpened. Typically between 0 and 0.05.
-func (*Filters) UnsharpMask(sigma, amount, threshold interface{}) gift.Filter {
+func (*Filters) UnsharpMask(sigma, amount, threshold any) gift.Filter {
return filter{
Options: newFilterOpts(sigma, amount, threshold),
Filter: gift.UnsharpMask(cast.ToFloat32(sigma), cast.ToFloat32(amount), cast.ToFloat32(threshold)),
@@ -225,10 +225,10 @@ type filter struct {
// For cache-busting.
type filterOpts struct {
Version int
- Vals interface{}
+ Vals any
}
-func newFilterOpts(vals ...interface{}) filterOpts {
+func newFilterOpts(vals ...any) filterOpts {
return filterOpts{
Version: filterAPIVersion,
Vals: vals,
diff --git a/resources/images/image.go b/resources/images/image.go
index 66ee9dda1..25deda925 100644
--- a/resources/images/image.go
+++ b/resources/images/image.go
@@ -341,7 +341,7 @@ func imageConfigFromImage(img image.Image) image.Config {
return image.Config{Width: b.Max.X, Height: b.Max.Y}
}
-func ToFilters(in interface{}) []gift.Filter {
+func ToFilters(in any) []gift.Filter {
switch v := in.(type) {
case []gift.Filter:
return v
diff --git a/resources/images/webp/webp.go b/resources/images/webp/webp.go
index 5393569da..28336d2e0 100644
--- a/resources/images/webp/webp.go
+++ b/resources/images/webp/webp.go
@@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+//go:build extended
// +build extended
package webp
diff --git a/resources/images/webp/webp_notavailable.go b/resources/images/webp/webp_notavailable.go
index 0c03a1749..70407f94e 100644
--- a/resources/images/webp/webp_notavailable.go
+++ b/resources/images/webp/webp_notavailable.go
@@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+//go:build !extended
// +build !extended
package webp
diff --git a/resources/internal/key.go b/resources/internal/key.go
index ba13bd2f8..1b45d4cc4 100644
--- a/resources/internal/key.go
+++ b/resources/internal/key.go
@@ -21,13 +21,13 @@ import "github.com/gohugoio/hugo/helpers"
// with the target filename and a content hash of the origin to use as cache key.
type ResourceTransformationKey struct {
Name string
- elements []interface{}
+ elements []any
}
// NewResourceTransformationKey creates a new ResourceTransformationKey from the transformation
// name and elements. We will create a 64 bit FNV hash from the elements, which when combined
// with the other key elements should be unique for all practical applications.
-func NewResourceTransformationKey(name string, elements ...interface{}) ResourceTransformationKey {
+func NewResourceTransformationKey(name string, elements ...any) ResourceTransformationKey {
return ResourceTransformationKey{Name: name, elements: elements}
}
diff --git a/resources/page/page.go b/resources/page/page.go
index d68694937..5133f46fa 100644
--- a/resources/page/page.go
+++ b/resources/page/page.go
@@ -75,7 +75,7 @@ type ChildCareProvider interface {
// ContentProvider provides the content related values for a Page.
type ContentProvider interface {
- Content() (interface{}, error)
+ Content() (any, error)
Plain() string
PlainWords() []string
Summary() template.HTML
@@ -174,7 +174,7 @@ type PageMetaProvider interface {
IsPage() bool
// Param looks for a param in Page and then in Site config.
- Param(key interface{}) (interface{}, error)
+ Param(key any) (any, error)
// Path gets the relative path, including file name and extension if relevant,
// to the source of this Page. It will be relative to any content root.
@@ -217,7 +217,7 @@ type PageMetaProvider interface {
// PageRenderProvider provides a way for a Page to render content.
type PageRenderProvider interface {
Render(layout ...string) (template.HTML, error)
- RenderString(args ...interface{}) (template.HTML, error)
+ RenderString(args ...any) (template.HTML, error)
}
// PageWithoutContent is the Page without any of the content methods.
@@ -302,10 +302,10 @@ type RawContentProvider interface {
// RefProvider provides the methods needed to create reflinks to pages.
type RefProvider interface {
- Ref(argsm map[string]interface{}) (string, error)
- RefFrom(argsm map[string]interface{}, source interface{}) (string, error)
- RelRef(argsm map[string]interface{}) (string, error)
- RelRefFrom(argsm map[string]interface{}, source interface{}) (string, error)
+ Ref(argsm map[string]any) (string, error)
+ RefFrom(argsm map[string]any, source any) (string, error)
+ RelRef(argsm map[string]any) (string, error)
+ RelRefFrom(argsm map[string]any, source any) (string, error)
}
// RelatedKeywordsProvider allows a Page to be indexed.
@@ -352,7 +352,7 @@ type TreeProvider interface {
// IsAncestor returns whether the current page is an ancestor of the given
// Note that this method is not relevant for taxonomy lists and taxonomy terms pages.
- IsAncestor(other interface{}) (bool, error)
+ IsAncestor(other any) (bool, error)
// CurrentSection returns the page's current section or the page itself if home or a section.
// Note that this will return nil for pages that is not regular, home or section pages.
@@ -360,7 +360,7 @@ type TreeProvider interface {
// IsDescendant returns whether the current page is a descendant of the given
// Note that this method is not relevant for taxonomy lists and taxonomy terms pages.
- IsDescendant(other interface{}) (bool, error)
+ IsDescendant(other any) (bool, error)
// FirstSection returns the section on level 1 below home, e.g. "/docs".
// For the home page, this will return itself.
@@ -369,7 +369,7 @@ type TreeProvider interface {
// InSection returns whether the given page is in the current section.
// Note that this will always return false for pages that are
// not either regular, home or section pages.
- InSection(other interface{}) (bool, error)
+ InSection(other any) (bool, error)
// Parent returns a section's parent section or a page's section.
// To get a section's subsections, see Page's Sections method.
@@ -387,9 +387,8 @@ type TreeProvider interface {
// DeprecatedWarningPageMethods lists deprecated Page methods that will trigger
// a WARNING if invoked.
// This was added in Hugo 0.55.
-type DeprecatedWarningPageMethods interface { // This was emptied in Hugo 0.93.0.
-}
+type DeprecatedWarningPageMethods any // This was emptied in Hugo 0.93.0.
// Move here to trigger ERROR instead of WARNING.
// TODO(bep) create wrappers and put into the Page once it has some methods.
-type DeprecatedErrorPageMethods interface{}
+type DeprecatedErrorPageMethods any
diff --git a/resources/page/page_data.go b/resources/page/page_data.go
index 3345a44da..a7806438a 100644
--- a/resources/page/page_data.go
+++ b/resources/page/page_data.go
@@ -21,7 +21,7 @@ import (
// Data represents the .Data element in a Page in Hugo. We make this
// a type so we can do lazy loading of .Data.Pages
-type Data map[string]interface{}
+type Data map[string]any
// Pages returns the pages stored with key "pages". If this is a func,
// it will be invoked.
diff --git a/resources/page/page_lazy_contentprovider.go b/resources/page/page_lazy_contentprovider.go
index 206695d18..ba4f8f8ef 100644
--- a/resources/page/page_lazy_contentprovider.go
+++ b/resources/page/page_lazy_contentprovider.go
@@ -48,7 +48,7 @@ func NewLazyContentProvider(f func() (OutputFormatContentProvider, error)) *Lazy
init: lazy.New(),
cp: NopPage,
}
- lcp.init.Add(func() (interface{}, error) {
+ lcp.init.Add(func() (any, error) {
cp, err := f()
if err != nil {
return nil, err
@@ -63,7 +63,7 @@ func (lcp *LazyContentProvider) Reset() {
lcp.init.Reset()
}
-func (lcp *LazyContentProvider) Content() (interface{}, error) {
+func (lcp *LazyContentProvider) Content() (any, error) {
lcp.init.Do()
return lcp.cp.Content()
}
@@ -113,7 +113,7 @@ func (lcp *LazyContentProvider) Render(layout ...string) (template.HTML, error)
return lcp.cp.Render(layout...)
}
-func (lcp *LazyContentProvider) RenderString(args ...interface{}) (template.HTML, error) {
+func (lcp *LazyContentProvider) RenderString(args ...any) (template.HTML, error) {
lcp.init.Do()
return lcp.cp.RenderString(args...)
}
diff --git a/resources/page/page_marshaljson.autogen.go b/resources/page/page_marshaljson.autogen.go
index 7b44d4a72..0f73d81ae 100644
--- a/resources/page/page_marshaljson.autogen.go
+++ b/resources/page/page_marshaljson.autogen.go
@@ -92,7 +92,7 @@ func MarshalPageToJSON(p Page) ([]byte, error) {
getIdentity := p.GetIdentity()
s := struct {
- Content interface{}
+ Content any
Plain string
PlainWords []string
Summary template.HTML
@@ -110,7 +110,7 @@ func MarshalPageToJSON(p Page) ([]byte, error) {
Name string
Title string
Params maps.Params
- Data interface{}
+ Data any
Date time.Time
Lastmod time.Time
PublishDate time.Time
diff --git a/resources/page/page_matcher.go b/resources/page/page_matcher.go
index 4c1409e9e..dc23b13bb 100644
--- a/resources/page/page_matcher.go
+++ b/resources/page/page_matcher.go
@@ -71,7 +71,7 @@ func (m PageMatcher) Matches(p Page) bool {
}
// DecodeCascade decodes in which could be eiter a map or a slice of maps.
-func DecodeCascade(in interface{}) (map[PageMatcher]maps.Params, error) {
+func DecodeCascade(in any) (map[PageMatcher]maps.Params, error) {
m, err := maps.ToSliceStringMap(in)
if err != nil {
return map[PageMatcher]maps.Params{
@@ -106,7 +106,7 @@ func DecodeCascade(in interface{}) (map[PageMatcher]maps.Params, error) {
}
// DecodePageMatcher decodes m into v.
-func DecodePageMatcher(m interface{}, v *PageMatcher) error {
+func DecodePageMatcher(m any, v *PageMatcher) error {
if err := mapstructure.WeakDecode(m, v); err != nil {
return err
}
diff --git a/resources/page/page_matcher_test.go b/resources/page/page_matcher_test.go
index aaef27eaa..72aec5f2a 100644
--- a/resources/page/page_matcher_test.go
+++ b/resources/page/page_matcher_test.go
@@ -54,13 +54,13 @@ func TestPageMatcher(t *testing.T) {
c.Run("Decode", func(c *qt.C) {
var v PageMatcher
- c.Assert(DecodePageMatcher(map[string]interface{}{"kind": "foo"}, &v), qt.Not(qt.IsNil))
- c.Assert(DecodePageMatcher(map[string]interface{}{"kind": "{foo,bar}"}, &v), qt.Not(qt.IsNil))
- c.Assert(DecodePageMatcher(map[string]interface{}{"kind": "taxonomy"}, &v), qt.IsNil)
- c.Assert(DecodePageMatcher(map[string]interface{}{"kind": "{taxonomy,foo}"}, &v), qt.IsNil)
- c.Assert(DecodePageMatcher(map[string]interface{}{"kind": "{taxonomy,term}"}, &v), qt.IsNil)
- c.Assert(DecodePageMatcher(map[string]interface{}{"kind": "*"}, &v), qt.IsNil)
- c.Assert(DecodePageMatcher(map[string]interface{}{"kind": "home", "path": filepath.FromSlash("/a/b/**")}, &v), qt.IsNil)
+ c.Assert(DecodePageMatcher(map[string]any{"kind": "foo"}, &v), qt.Not(qt.IsNil))
+ c.Assert(DecodePageMatcher(map[string]any{"kind": "{foo,bar}"}, &v), qt.Not(qt.IsNil))
+ c.Assert(DecodePageMatcher(map[string]any{"kind": "taxonomy"}, &v), qt.IsNil)
+ c.Assert(DecodePageMatcher(map[string]any{"kind": "{taxonomy,foo}"}, &v), qt.IsNil)
+ c.Assert(DecodePageMatcher(map[string]any{"kind": "{taxonomy,term}"}, &v), qt.IsNil)
+ c.Assert(DecodePageMatcher(map[string]any{"kind": "*"}, &v), qt.IsNil)
+ c.Assert(DecodePageMatcher(map[string]any{"kind": "home", "path": filepath.FromSlash("/a/b/**")}, &v), qt.IsNil)
c.Assert(v, qt.Equals, PageMatcher{Kind: "home", Path: "/a/b/**"})
})
}
diff --git a/resources/page/page_nop.go b/resources/page/page_nop.go
index 52345ad71..67b8b8d4b 100644
--- a/resources/page/page_nop.go
+++ b/resources/page/page_nop.go
@@ -96,7 +96,7 @@ func (p *nopPage) BundleType() files.ContentClass {
return ""
}
-func (p *nopPage) Content() (interface{}, error) {
+func (p *nopPage) Content() (any, error) {
return "", nil
}
@@ -108,7 +108,7 @@ func (p *nopPage) CurrentSection() Page {
return nil
}
-func (p *nopPage) Data() interface{} {
+func (p *nopPage) Data() any {
return nil
}
@@ -120,11 +120,11 @@ func (p *nopPage) Description() string {
return ""
}
-func (p *nopPage) RefFrom(argsm map[string]interface{}, source interface{}) (string, error) {
+func (p *nopPage) RefFrom(argsm map[string]any, source any) (string, error) {
return "", nil
}
-func (p *nopPage) RelRefFrom(argsm map[string]interface{}, source interface{}) (string, error) {
+func (p *nopPage) RelRefFrom(argsm map[string]any, source any) (string, error) {
return "", nil
}
@@ -136,7 +136,7 @@ func (p *nopPage) Draft() bool {
return false
}
-func (p *nopPage) Eq(other interface{}) bool {
+func (p *nopPage) Eq(other any) bool {
return p == other
}
@@ -182,7 +182,7 @@ func (p *nopPage) GetPageWithTemplateInfo(info tpl.Info, ref string) (Page, erro
return nil, nil
}
-func (p *nopPage) GetParam(key string) interface{} {
+func (p *nopPage) GetParam(key string) any {
return nil
}
@@ -210,15 +210,15 @@ func (p *nopPage) Hugo() (h hugo.Info) {
return
}
-func (p *nopPage) InSection(other interface{}) (bool, error) {
+func (p *nopPage) InSection(other any) (bool, error) {
return false, nil
}
-func (p *nopPage) IsAncestor(other interface{}) (bool, error) {
+func (p *nopPage) IsAncestor(other any) (bool, error) {
return false, nil
}
-func (p *nopPage) IsDescendant(other interface{}) (bool, error) {
+func (p *nopPage) IsDescendant(other any) (bool, error) {
return false, nil
}
@@ -314,15 +314,15 @@ func (p *nopPage) RegularPagesRecursive() Pages {
return nil
}
-func (p *nopPage) Paginate(seq interface{}, options ...interface{}) (*Pager, error) {
+func (p *nopPage) Paginate(seq any, options ...any) (*Pager, error) {
return nil, nil
}
-func (p *nopPage) Paginator(options ...interface{}) (*Pager, error) {
+func (p *nopPage) Paginator(options ...any) (*Pager, error) {
return nil, nil
}
-func (p *nopPage) Param(key interface{}) (interface{}, error) {
+func (p *nopPage) Param(key any) (any, error) {
return nil, nil
}
@@ -390,7 +390,7 @@ func (p *nopPage) ReadingTime() int {
return 0
}
-func (p *nopPage) Ref(argsm map[string]interface{}) (string, error) {
+func (p *nopPage) Ref(argsm map[string]any) (string, error) {
return "", nil
}
@@ -398,7 +398,7 @@ func (p *nopPage) RelPermalink() string {
return ""
}
-func (p *nopPage) RelRef(argsm map[string]interface{}) (string, error) {
+func (p *nopPage) RelRef(argsm map[string]any) (string, error) {
return "", nil
}
@@ -406,7 +406,7 @@ func (p *nopPage) Render(layout ...string) (template.HTML, error) {
return "", nil
}
-func (p *nopPage) RenderString(args ...interface{}) (template.HTML, error) {
+func (p *nopPage) RenderString(args ...any) (template.HTML, error) {
return "", nil
}
diff --git a/resources/page/pagegroup.go b/resources/page/pagegroup.go
index 4c0adb68b..18c98e70e 100644
--- a/resources/page/pagegroup.go
+++ b/resources/page/pagegroup.go
@@ -39,7 +39,7 @@ var (
// PageGroup represents a group of pages, grouped by the key.
// The key is typically a year or similar.
type PageGroup struct {
- Key interface{}
+ Key any
Pages
}
@@ -112,7 +112,7 @@ func (p Pages) GroupBy(key string, order ...string) (PagesGroup, error) {
direction = "desc"
}
- var ft interface{}
+ var ft any
index := hreflect.GetMethodIndexByName(pagePtrType, key)
if index != -1 {
m := pagePtrType.Method(index)
@@ -347,7 +347,7 @@ func (p Pages) GroupByParamDate(key string, format string, order ...string) (Pag
}
// ProbablyEq wraps compare.ProbablyEqer
-func (p PageGroup) ProbablyEq(other interface{}) bool {
+func (p PageGroup) ProbablyEq(other any) bool {
otherP, ok := other.(PageGroup)
if !ok {
return false
@@ -362,11 +362,11 @@ func (p PageGroup) ProbablyEq(other interface{}) bool {
// Slice is not meant to be used externally. It's a bridge function
// for the template functions. See collections.Slice.
-func (p PageGroup) Slice(in interface{}) (interface{}, error) {
+func (p PageGroup) Slice(in any) (any, error) {
switch items := in.(type) {
case PageGroup:
return items, nil
- case []interface{}:
+ case []any:
groups := make(PagesGroup, len(items))
for i, v := range items {
g, ok := v.(PageGroup)
@@ -391,7 +391,7 @@ func (psg PagesGroup) Len() int {
}
// ProbablyEq wraps compare.ProbablyEqer
-func (psg PagesGroup) ProbablyEq(other interface{}) bool {
+func (psg PagesGroup) ProbablyEq(other any) bool {
otherPsg, ok := other.(PagesGroup)
if !ok {
return false
@@ -411,7 +411,7 @@ func (psg PagesGroup) ProbablyEq(other interface{}) bool {
}
// ToPagesGroup tries to convert seq into a PagesGroup.
-func ToPagesGroup(seq interface{}) (PagesGroup, error) {
+func ToPagesGroup(seq any) (PagesGroup, error) {
switch v := seq.(type) {
case nil:
return nil, nil
@@ -419,7 +419,7 @@ func ToPagesGroup(seq interface{}) (PagesGroup, error) {
return v, nil
case []PageGroup:
return PagesGroup(v), nil
- case []interface{}:
+ case []any:
l := len(v)
if l == 0 {
break
diff --git a/resources/page/pagemeta/page_frontmatter.go b/resources/page/pagemeta/page_frontmatter.go
index d473c69ce..bc82773e8 100644
--- a/resources/page/pagemeta/page_frontmatter.go
+++ b/resources/page/pagemeta/page_frontmatter.go
@@ -49,7 +49,7 @@ type FrontMatterHandler struct {
type FrontMatterDescriptor struct {
// This the Page's front matter.
- Frontmatter map[string]interface{}
+ Frontmatter map[string]any
// This is the Page's base filename (BaseFilename), e.g. page.md., or
// if page is a leaf bundle, the bundle folder name (ContentBaseName).
@@ -64,7 +64,7 @@ type FrontMatterDescriptor struct {
// The below are pointers to values on Page and will be modified.
// This is the Page's params.
- Params map[string]interface{}
+ Params map[string]any
// This is the Page's dates.
Dates *resource.Dates
@@ -253,7 +253,7 @@ func expandDefaultValues(values []string, defaults []string) []string {
return out
}
-func toLowerSlice(in interface{}) []string {
+func toLowerSlice(in any) []string {
out := cast.ToStringSlice(in)
for i := 0; i < len(out); i++ {
out[i] = strings.ToLower(out[i])
@@ -335,7 +335,7 @@ func (f *FrontMatterHandler) createHandlers() error {
return nil
}
-func setParamIfNotSet(key string, value interface{}, d *FrontMatterDescriptor) {
+func setParamIfNotSet(key string, value any, d *FrontMatterDescriptor) {
if _, found := d.Params[key]; found {
return
}
diff --git a/resources/page/pagemeta/page_frontmatter_test.go b/resources/page/pagemeta/page_frontmatter_test.go
index 653ced59e..c5c4ccf2d 100644
--- a/resources/page/pagemeta/page_frontmatter_test.go
+++ b/resources/page/pagemeta/page_frontmatter_test.go
@@ -63,8 +63,8 @@ func TestDateAndSlugFromBaseFilename(t *testing.T) {
func newTestFd() *FrontMatterDescriptor {
return &FrontMatterDescriptor{
- Frontmatter: make(map[string]interface{}),
- Params: make(map[string]interface{}),
+ Frontmatter: make(map[string]any),
+ Params: make(map[string]any),
Dates: &resource.Dates{},
PageURLs: &URLPath{},
Location: time.UTC,
@@ -76,7 +76,7 @@ func TestFrontMatterNewConfig(t *testing.T) {
cfg := config.New()
- cfg.Set("frontmatter", map[string]interface{}{
+ cfg.Set("frontmatter", map[string]any{
"date": []string{"publishDate", "LastMod"},
"Lastmod": []string{"publishDate"},
"expiryDate": []string{"lastMod"},
@@ -100,7 +100,7 @@ func TestFrontMatterNewConfig(t *testing.T) {
c.Assert(fc.publishDate, qt.DeepEquals, []string{"publishdate", "pubdate", "published", "date"})
// :default keyword
- cfg.Set("frontmatter", map[string]interface{}{
+ cfg.Set("frontmatter", map[string]any{
"date": []string{"d1", ":default"},
"lastmod": []string{"d2", ":default"},
"expiryDate": []string{"d3", ":default"},
@@ -121,7 +121,7 @@ func TestFrontMatterDatesHandlers(t *testing.T) {
cfg := config.New()
- cfg.Set("frontmatter", map[string]interface{}{
+ cfg.Set("frontmatter", map[string]any{
"date": []string{handlerID, "date"},
})
@@ -160,7 +160,7 @@ func TestFrontMatterDatesCustomConfig(t *testing.T) {
c := qt.New(t)
cfg := config.New()
- cfg.Set("frontmatter", map[string]interface{}{
+ cfg.Set("frontmatter", map[string]any{
"date": []string{"mydate"},
"lastmod": []string{"publishdate"},
"publishdate": []string{"publishdate"},
@@ -208,7 +208,7 @@ func TestFrontMatterDatesDefaultKeyword(t *testing.T) {
cfg := config.New()
- cfg.Set("frontmatter", map[string]interface{}{
+ cfg.Set("frontmatter", map[string]any{
"date": []string{"mydate", ":default"},
"publishdate": []string{":default", "mypubdate"},
})
diff --git a/resources/page/pagemeta/pagemeta.go b/resources/page/pagemeta/pagemeta.go
index 19a0a7ae9..94c6b00aa 100644
--- a/resources/page/pagemeta/pagemeta.go
+++ b/resources/page/pagemeta/pagemeta.go
@@ -75,7 +75,7 @@ func (b BuildConfig) IsZero() bool {
return !b.set
}
-func DecodeBuildConfig(m interface{}) (BuildConfig, error) {
+func DecodeBuildConfig(m any) (BuildConfig, error) {
b := defaultBuildConfig
if m == nil {
return b, nil
diff --git a/resources/page/pagemeta/pagemeta_test.go b/resources/page/pagemeta/pagemeta_test.go
index d09b38e27..288dc7e26 100644
--- a/resources/page/pagemeta/pagemeta_test.go
+++ b/resources/page/pagemeta/pagemeta_test.go
@@ -36,11 +36,11 @@ list = %s
publishResources = true`
for _, test := range []struct {
- args []interface{}
+ args []any
expect BuildConfig
}{
{
- []interface{}{"true", "true"},
+ []any{"true", "true"},
BuildConfig{
Render: Always,
List: Always,
@@ -48,31 +48,31 @@ publishResources = true`
set: true,
},
},
- {[]interface{}{"true", "false"}, BuildConfig{
+ {[]any{"true", "false"}, BuildConfig{
Render: Always,
List: Never,
PublishResources: true,
set: true,
}},
- {[]interface{}{`"always"`, `"always"`}, BuildConfig{
+ {[]any{`"always"`, `"always"`}, BuildConfig{
Render: Always,
List: Always,
PublishResources: true,
set: true,
}},
- {[]interface{}{`"never"`, `"never"`}, BuildConfig{
+ {[]any{`"never"`, `"never"`}, BuildConfig{
Render: Never,
List: Never,
PublishResources: true,
set: true,
}},
- {[]interface{}{`"link"`, `"local"`}, BuildConfig{
+ {[]any{`"link"`, `"local"`}, BuildConfig{
Render: Link,
List: ListLocally,
PublishResources: true,
set: true,
}},
- {[]interface{}{`"always"`, `"asdfadf"`}, BuildConfig{
+ {[]any{`"always"`, `"asdfadf"`}, BuildConfig{
Render: Always,
List: Always,
PublishResources: true,
diff --git a/resources/page/pages.go b/resources/page/pages.go
index dff784f5c..e0f133500 100644
--- a/resources/page/pages.go
+++ b/resources/page/pages.go
@@ -52,7 +52,7 @@ func (pages Pages) ToResources() resource.Resources {
}
// ToPages tries to convert seq into Pages.
-func ToPages(seq interface{}) (Pages, error) {
+func ToPages(seq any) (Pages, error) {
if seq == nil {
return Pages{}, nil
}
@@ -72,7 +72,7 @@ func ToPages(seq interface{}) (Pages, error) {
pages[i] = vv
}
return pages, nil
- case []interface{}:
+ case []any:
pages := make(Pages, len(v))
success := true
for i, vv := range v {
@@ -91,7 +91,7 @@ func ToPages(seq interface{}) (Pages, error) {
return nil, fmt.Errorf("cannot convert type %T to Pages", seq)
}
-func (p Pages) Group(key interface{}, in interface{}) (interface{}, error) {
+func (p Pages) Group(key any, in any) (any, error) {
pages, err := ToPages(in)
if err != nil {
return nil, err
@@ -105,7 +105,7 @@ func (p Pages) Len() int {
}
// ProbablyEq wraps compare.ProbablyEqer
-func (pages Pages) ProbablyEq(other interface{}) bool {
+func (pages Pages) ProbablyEq(other any) bool {
otherPages, ok := other.(Pages)
if !ok {
return false
diff --git a/resources/page/pages_language_merge.go b/resources/page/pages_language_merge.go
index dd18b64a2..4c5a926cf 100644
--- a/resources/page/pages_language_merge.go
+++ b/resources/page/pages_language_merge.go
@@ -22,7 +22,7 @@ var _ pagesLanguageMerger = (*Pages)(nil)
type pagesLanguageMerger interface {
MergeByLanguage(other Pages) Pages
// Needed for integration with the tpl package.
- MergeByLanguageInterface(other interface{}) (interface{}, error)
+ MergeByLanguageInterface(other any) (any, error)
}
// MergeByLanguage supplies missing translations in p1 with values from p2.
@@ -50,7 +50,7 @@ func (p1 Pages) MergeByLanguage(p2 Pages) Pages {
// MergeByLanguageInterface is the generic version of MergeByLanguage. It
// is here just so it can be called from the tpl package.
-func (p1 Pages) MergeByLanguageInterface(in interface{}) (interface{}, error) {
+func (p1 Pages) MergeByLanguageInterface(in any) (any, error) {
if in == nil {
return p1, nil
}
diff --git a/resources/page/pages_related.go b/resources/page/pages_related.go
index bc3b8b55a..83910e0d4 100644
--- a/resources/page/pages_related.go
+++ b/resources/page/pages_related.go
@@ -38,7 +38,7 @@ type PageGenealogist interface {
// Template example:
// {{ $related := .RegularPages.RelatedIndices . "tags" "date" }}
- RelatedIndices(doc related.Document, indices ...interface{}) (Pages, error)
+ RelatedIndices(doc related.Document, indices ...any) (Pages, error)
// Template example:
// {{ $related := .RegularPages.RelatedTo ( keyVals "tags" "hugo", "rocks") ( keyVals "date" .Date ) }}
@@ -62,7 +62,7 @@ func (p Pages) Related(doc related.Document) (Pages, error) {
// RelatedIndices searches the given indices with the search keywords from the
// supplied document.
-func (p Pages) RelatedIndices(doc related.Document, indices ...interface{}) (Pages, error) {
+func (p Pages) RelatedIndices(doc related.Document, indices ...any) (Pages, error) {
indicesStr, err := cast.ToStringSliceE(indices)
if err != nil {
return nil, err
diff --git a/resources/page/pages_related_test.go b/resources/page/pages_related_test.go
index be75a62cd..3c5780a9a 100644
--- a/resources/page/pages_related_test.go
+++ b/resources/page/pages_related_test.go
@@ -31,21 +31,21 @@ func TestRelated(t *testing.T) {
&testPage{
title: "Page 1",
pubDate: mustParseDate("2017-01-03"),
- params: map[string]interface{}{
+ params: map[string]any{
"keywords": []string{"hugo", "says"},
},
},
&testPage{
title: "Page 2",
pubDate: mustParseDate("2017-01-02"),
- params: map[string]interface{}{
+ params: map[string]any{
"keywords": []string{"hugo", "rocks"},
},
},
&testPage{
title: "Page 3",
pubDate: mustParseDate("2017-01-01"),
- params: map[string]interface{}{
+ params: map[string]any{
"keywords": []string{"bep", "says"},
},
},
diff --git a/resources/page/pages_sort.go b/resources/page/pages_sort.go
index 644f67e1e..02096dadd 100644
--- a/resources/page/pages_sort.go
+++ b/resources/page/pages_sort.go
@@ -322,7 +322,7 @@ func (p Pages) Reverse() Pages {
// Adjacent invocations on the same receiver with the same paramsKey will return a cached result.
//
// This may safely be executed in parallel.
-func (p Pages) ByParam(paramsKey interface{}) Pages {
+func (p Pages) ByParam(paramsKey any) Pages {
paramsKeyStr := cast.ToString(paramsKey)
key := "pageSort.ByParam." + paramsKeyStr
@@ -338,7 +338,7 @@ func (p Pages) ByParam(paramsKey interface{}) Pages {
return true
}
- isNumeric := func(v interface{}) bool {
+ isNumeric := func(v any) bool {
switch v.(type) {
case uint8, uint16, uint32, uint64, int, int8, int16, int32, int64, float32, float64:
return true
diff --git a/resources/page/pages_sort_test.go b/resources/page/pages_sort_test.go
index 737a4f540..85a1cda15 100644
--- a/resources/page/pages_sort_test.go
+++ b/resources/page/pages_sort_test.go
@@ -157,7 +157,7 @@ func TestPageSortReverse(t *testing.T) {
func TestPageSortByParam(t *testing.T) {
t.Parallel()
c := qt.New(t)
- var k interface{} = "arbitrarily.nested"
+ var k any = "arbitrarily.nested"
unsorted := createSortTestPages(10)
delete(unsorted[9].Params(), "arbitrarily")
@@ -188,7 +188,7 @@ func TestPageSortByParamNumeric(t *testing.T) {
t.Parallel()
c := qt.New(t)
- var k interface{} = "arbitrarily.nested"
+ var k any = "arbitrarily.nested"
n := 10
unsorted := createSortTestPages(n)
@@ -198,8 +198,8 @@ func TestPageSortByParamNumeric(t *testing.T) {
v = 100.0 - i
}
- unsorted[i].(*testPage).params = map[string]interface{}{
- "arbitrarily": map[string]interface{}{
+ unsorted[i].(*testPage).params = map[string]any{
+ "arbitrarily": map[string]any{
"nested": v,
},
}
@@ -268,8 +268,8 @@ func createSortTestPages(num int) Pages {
p := newTestPage()
p.path = fmt.Sprintf("/x/y/p%d.md", i)
p.title = fmt.Sprintf("Title %d", i%(num+1/2))
- p.params = map[string]interface{}{
- "arbitrarily": map[string]interface{}{
+ p.params = map[string]any{
+ "arbitrarily": map[string]any{
"nested": ("xyz" + fmt.Sprintf("%v", 100-i)),
},
}
diff --git a/resources/page/pages_test.go b/resources/page/pages_test.go
index 829b029b4..22ee698da 100644
--- a/resources/page/pages_test.go
+++ b/resources/page/pages_test.go
@@ -56,7 +56,7 @@ func TestToPages(t *testing.T) {
p1, p2 := &testPage{title: "p1"}, &testPage{title: "p2"}
pages12 := Pages{p1, p2}
- mustToPages := func(in interface{}) Pages {
+ mustToPages := func(in any) Pages {
p, err := ToPages(in)
c.Assert(err, qt.IsNil)
return p
@@ -65,7 +65,7 @@ func TestToPages(t *testing.T) {
c.Assert(mustToPages(nil), eq, Pages{})
c.Assert(mustToPages(pages12), eq, pages12)
c.Assert(mustToPages([]Page{p1, p2}), eq, pages12)
- c.Assert(mustToPages([]interface{}{p1, p2}), eq, pages12)
+ c.Assert(mustToPages([]any{p1, p2}), eq, pages12)
_, err := ToPages("not a page")
c.Assert(err, qt.Not(qt.IsNil))
diff --git a/resources/page/pagination.go b/resources/page/pagination.go
index f41433183..9f4bfcff5 100644
--- a/resources/page/pagination.go
+++ b/resources/page/pagination.go
@@ -27,8 +27,8 @@ import (
// PaginatorProvider provides two ways to create a page paginator.
type PaginatorProvider interface {
- Paginator(options ...interface{}) (*Pager, error)
- Paginate(seq interface{}, options ...interface{}) (*Pager, error)
+ Paginator(options ...any) (*Pager, error)
+ Paginate(seq any, options ...any) (*Pager, error)
}
// Pager represents one of the elements in a paginator.
@@ -207,7 +207,7 @@ func splitPages(pages Pages, size int) []paginatedElement {
func splitPageGroups(pageGroups PagesGroup, size int) []paginatedElement {
type keyPage struct {
- key interface{}
+ key any
page Page
}
@@ -229,7 +229,7 @@ func splitPageGroups(pageGroups PagesGroup, size int) []paginatedElement {
var (
pg PagesGroup
- key interface{}
+ key any
groupIndex = -1
)
@@ -248,7 +248,7 @@ func splitPageGroups(pageGroups PagesGroup, size int) []paginatedElement {
return split
}
-func ResolvePagerSize(cfg config.Provider, options ...interface{}) (int, error) {
+func ResolvePagerSize(cfg config.Provider, options ...any) (int, error) {
if len(options) == 0 {
return cfg.GetInt("paginate"), nil
}
@@ -266,7 +266,7 @@ func ResolvePagerSize(cfg config.Provider, options ...interface{}) (int, error)
return pas, nil
}
-func Paginate(td TargetPathDescriptor, seq interface{}, pagerSize int) (*Paginator, error) {
+func Paginate(td TargetPathDescriptor, seq any, pagerSize int) (*Paginator, error) {
if pagerSize <= 0 {
return nil, errors.New("'paginate' configuration setting must be positive to paginate")
}
@@ -296,7 +296,7 @@ func Paginate(td TargetPathDescriptor, seq interface{}, pagerSize int) (*Paginat
// It may return false positives.
// The motivation behind this is to avoid potential costly reflect.DeepEqual
// when "probably" is good enough.
-func probablyEqualPageLists(a1 interface{}, a2 interface{}) bool {
+func probablyEqualPageLists(a1 any, a2 any) bool {
if a1 == nil || a2 == nil {
return a1 == a2
}
diff --git a/resources/page/pagination_test.go b/resources/page/pagination_test.go
index 07ad6233b..e379f9b6b 100644
--- a/resources/page/pagination_test.go
+++ b/resources/page/pagination_test.go
@@ -254,8 +254,8 @@ func TestProbablyEqualPageLists(t *testing.T) {
ninePagesByWeight, _ := createTestPages(9).GroupBy("Weight", "asc")
for i, this := range []struct {
- v1 interface{}
- v2 interface{}
+ v1 any
+ v2 any
expect bool
}{
{nil, nil, true},
diff --git a/resources/page/site.go b/resources/page/site.go
index 724f23ad7..3cc9989ee 100644
--- a/resources/page/site.go
+++ b/resources/page/site.go
@@ -39,11 +39,11 @@ type Site interface {
Sites() Sites
Hugo() hugo.Info
BaseURL() template.URL
- Taxonomies() interface{}
+ Taxonomies() any
LastChange() time.Time
Menus() navigation.Menus
Params() maps.Params
- Data() map[string]interface{}
+ Data() map[string]any
}
// Sites represents an ordered list of sites (languages).
@@ -106,7 +106,7 @@ func (t testSite) Menus() navigation.Menus {
return nil
}
-func (t testSite) Taxonomies() interface{} {
+func (t testSite) Taxonomies() any {
return nil
}
@@ -118,7 +118,7 @@ func (t testSite) Params() maps.Params {
return nil
}
-func (t testSite) Data() map[string]interface{} {
+func (t testSite) Data() map[string]any {
return nil
}
diff --git a/resources/page/testhelpers_test.go b/resources/page/testhelpers_test.go
index a655d3da9..675866799 100644
--- a/resources/page/testhelpers_test.go
+++ b/resources/page/testhelpers_test.go
@@ -58,8 +58,8 @@ func newTestPageWithFile(filename string) *testPage {
filename = filepath.FromSlash(filename)
file := source.NewTestFile(filename)
return &testPage{
- params: make(map[string]interface{}),
- data: make(map[string]interface{}),
+ params: make(map[string]any),
+ data: make(map[string]any),
file: file,
currentSection: &testPage{
sectionEntries: []string{"a", "b", "c"},
@@ -111,8 +111,8 @@ type testPage struct {
weight int
- params map[string]interface{}
- data map[string]interface{}
+ params map[string]any
+ data map[string]any
file source.File
@@ -152,7 +152,7 @@ func (p *testPage) BundleType() files.ContentClass {
panic("not implemented")
}
-func (p *testPage) Content() (interface{}, error) {
+func (p *testPage) Content() (any, error) {
panic("not implemented")
}
@@ -164,7 +164,7 @@ func (p *testPage) CurrentSection() Page {
return p.currentSection
}
-func (p *testPage) Data() interface{} {
+func (p *testPage) Data() any {
return p.data
}
@@ -192,7 +192,7 @@ func (p *testPage) Draft() bool {
panic("not implemented")
}
-func (p *testPage) Eq(other interface{}) bool {
+func (p *testPage) Eq(other any) bool {
return p == other
}
@@ -236,7 +236,7 @@ func (p *testPage) GetPageWithTemplateInfo(info tpl.Info, ref string) (Page, err
panic("not implemented")
}
-func (p *testPage) GetParam(key string) interface{} {
+func (p *testPage) GetParam(key string) any {
panic("not implemented")
}
@@ -268,15 +268,15 @@ func (p *testPage) Hugo() hugo.Info {
panic("not implemented")
}
-func (p *testPage) InSection(other interface{}) (bool, error) {
+func (p *testPage) InSection(other any) (bool, error) {
panic("not implemented")
}
-func (p *testPage) IsAncestor(other interface{}) (bool, error) {
+func (p *testPage) IsAncestor(other any) (bool, error) {
panic("not implemented")
}
-func (p *testPage) IsDescendant(other interface{}) (bool, error) {
+func (p *testPage) IsDescendant(other any) (bool, error) {
panic("not implemented")
}
@@ -390,15 +390,15 @@ func (p *testPage) RegularPagesRecursive() Pages {
panic("not implemented")
}
-func (p *testPage) Paginate(seq interface{}, options ...interface{}) (*Pager, error) {
+func (p *testPage) Paginate(seq any, options ...any) (*Pager, error) {
return nil, nil
}
-func (p *testPage) Paginator(options ...interface{}) (*Pager, error) {
+func (p *testPage) Paginator(options ...any) (*Pager, error) {
return nil, nil
}
-func (p *testPage) Param(key interface{}) (interface{}, error) {
+func (p *testPage) Param(key any) (any, error) {
return resource.Param(p, nil, key)
}
@@ -462,11 +462,11 @@ func (p *testPage) ReadingTime() int {
panic("not implemented")
}
-func (p *testPage) Ref(argsm map[string]interface{}) (string, error) {
+func (p *testPage) Ref(argsm map[string]any) (string, error) {
panic("not implemented")
}
-func (p *testPage) RefFrom(argsm map[string]interface{}, source interface{}) (string, error) {
+func (p *testPage) RefFrom(argsm map[string]any, source any) (string, error) {
return "", nil
}
@@ -474,11 +474,11 @@ func (p *testPage) RelPermalink() string {
panic("not implemented")
}
-func (p *testPage) RelRef(argsm map[string]interface{}) (string, error) {
+func (p *testPage) RelRef(argsm map[string]any) (string, error) {
panic("not implemented")
}
-func (p *testPage) RelRefFrom(argsm map[string]interface{}, source interface{}) (string, error) {
+func (p *testPage) RelRefFrom(argsm map[string]any, source any) (string, error) {
return "", nil
}
@@ -486,7 +486,7 @@ func (p *testPage) Render(layout ...string) (template.HTML, error) {
panic("not implemented")
}
-func (p *testPage) RenderString(args ...interface{}) (template.HTML, error) {
+func (p *testPage) RenderString(args ...any) (template.HTML, error) {
panic("not implemented")
}
diff --git a/resources/page/weighted.go b/resources/page/weighted.go
index af8b54446..5ae2636d4 100644
--- a/resources/page/weighted.go
+++ b/resources/page/weighted.go
@@ -65,11 +65,11 @@ func (w WeightedPage) String() string {
// Slice is not meant to be used externally. It's a bridge function
// for the template functions. See collections.Slice.
-func (p WeightedPage) Slice(in interface{}) (interface{}, error) {
+func (p WeightedPage) Slice(in any) (any, error) {
switch items := in.(type) {
case WeightedPages:
return items, nil
- case []interface{}:
+ case []any:
weighted := make(WeightedPages, len(items))
for i, v := range items {
g, ok := v.(WeightedPage)
diff --git a/resources/postpub/fields.go b/resources/postpub/fields.go
index ed3491438..13b2963ce 100644
--- a/resources/postpub/fields.go
+++ b/resources/postpub/fields.go
@@ -21,14 +21,14 @@ const (
FieldNotSupported = "__field_not_supported"
)
-func structToMapWithPlaceholders(root string, in interface{}, createPlaceholder func(s string) string) map[string]interface{} {
+func structToMapWithPlaceholders(root string, in any, createPlaceholder func(s string) string) map[string]any {
m := structToMap(in)
insertFieldPlaceholders(root, m, createPlaceholder)
return m
}
-func structToMap(s interface{}) map[string]interface{} {
- m := make(map[string]interface{})
+func structToMap(s any) map[string]any {
+ m := make(map[string]any)
t := reflect.TypeOf(s)
for i := 0; i < t.NumMethod(); i++ {
@@ -52,7 +52,7 @@ func structToMap(s interface{}) map[string]interface{} {
}
// insert placeholder for the templates. Do it very shallow for now.
-func insertFieldPlaceholders(root string, m map[string]interface{}, createPlaceholder func(s string) string) {
+func insertFieldPlaceholders(root string, m map[string]any, createPlaceholder func(s string) string) {
for k := range m {
m[k] = createPlaceholder(root + "." + k)
}
diff --git a/resources/postpub/fields_test.go b/resources/postpub/fields_test.go
index c408e7791..8e80063f1 100644
--- a/resources/postpub/fields_test.go
+++ b/resources/postpub/fields_test.go
@@ -30,7 +30,7 @@ func TestCreatePlaceholders(t *testing.T) {
return "pre_" + s + "_post"
})
- c.Assert(m, qt.DeepEquals, map[string]interface{}{
+ c.Assert(m, qt.DeepEquals, map[string]any{
"IsZero": "pre_foo.IsZero_post",
"MarshalJSON": "pre_foo.MarshalJSON_post",
"Suffixes": "pre_foo.Suffixes_post",
diff --git a/resources/postpub/postpub.go b/resources/postpub/postpub.go
index f1012b7da..400e00aa4 100644
--- a/resources/postpub/postpub.go
+++ b/resources/postpub/postpub.go
@@ -35,7 +35,7 @@ type PostPublishedResource interface {
resource.ResourceDataProvider
resource.OriginProvider
- MediaType() map[string]interface{}
+ MediaType() map[string]any
}
const (
@@ -109,13 +109,13 @@ func (r *PostPublishResource) GetFieldString(pattern string) (string, bool) {
case strings.HasPrefix(fieldAccessor, "MediaType"):
return r.fieldToString(d.MediaType(), fieldAccessor), true
case fieldAccessor == "Data.Integrity":
- return cast.ToString((d.Data().(map[string]interface{})["Integrity"])), true
+ return cast.ToString((d.Data().(map[string]any)["Integrity"])), true
default:
panic(fmt.Sprintf("unknown field accessor %q", fieldAccessor))
}
}
-func (r *PostPublishResource) fieldToString(receiver interface{}, path string) string {
+func (r *PostPublishResource) fieldToString(receiver any, path string) string {
fieldname := strings.Split(path, ".")[1]
receiverv := reflect.ValueOf(receiver)
@@ -143,15 +143,15 @@ func (r *PostPublishResource) fieldToString(receiver interface{}, path string) s
}
}
-func (r *PostPublishResource) Data() interface{} {
- m := map[string]interface{}{
+func (r *PostPublishResource) Data() any {
+ m := map[string]any{
"Integrity": "",
}
insertFieldPlaceholders("Data", m, r.field)
return m
}
-func (r *PostPublishResource) MediaType() map[string]interface{} {
+func (r *PostPublishResource) MediaType() map[string]any {
m := structToMapWithPlaceholders("MediaType", media.Type{}, r.field)
return m
}
@@ -172,7 +172,7 @@ func (r *PostPublishResource) Params() maps.Params {
panic(r.fieldNotSupported("Params"))
}
-func (r *PostPublishResource) Content() (interface{}, error) {
+func (r *PostPublishResource) Content() (any, error) {
return r.field("Content"), nil
}
diff --git a/resources/resource.go b/resources/resource.go
index 4bf35f9ac..dd3a4730a 100644
--- a/resources/resource.go
+++ b/resources/resource.go
@@ -102,7 +102,7 @@ type Transformer interface {
Transform(...ResourceTransformation) (ResourceTransformer, error)
}
-func NewFeatureNotAvailableTransformer(key string, elements ...interface{}) ResourceTransformation {
+func NewFeatureNotAvailableTransformer(key string, elements ...any) ResourceTransformation {
return transformerNotAvailable{
key: internal.NewResourceTransformationKey(key, elements...),
}
@@ -163,11 +163,11 @@ type commonResource struct {
// Slice is not meant to be used externally. It's a bridge function
// for the template functions. See collections.Slice.
-func (commonResource) Slice(in interface{}) (interface{}, error) {
+func (commonResource) Slice(in any) (any, error) {
switch items := in.(type) {
case resource.Resources:
return items, nil
- case []interface{}:
+ case []any:
groups := make(resource.Resources, len(items))
for i, v := range items {
g, ok := v.(resource.Resource)
@@ -214,8 +214,8 @@ type genericResource struct {
title string
name string
- params map[string]interface{}
- data map[string]interface{}
+ params map[string]any
+ data map[string]any
resourceType string
mediaType media.Type
@@ -225,7 +225,7 @@ func (l *genericResource) Clone() resource.Resource {
return l.clone()
}
-func (l *genericResource) Content() (interface{}, error) {
+func (l *genericResource) Content() (any, error) {
if err := l.initContent(); err != nil {
return nil, err
}
@@ -237,7 +237,7 @@ func (r *genericResource) Err() error {
return nil
}
-func (l *genericResource) Data() interface{} {
+func (l *genericResource) Data() any {
return l.data
}
@@ -382,12 +382,12 @@ func (r *genericResource) tryTransformedFileCache(key string, u *transformationU
return f
}
-func (r *genericResource) mergeData(in map[string]interface{}) {
+func (r *genericResource) mergeData(in map[string]any) {
if len(in) == 0 {
return
}
if r.data == nil {
- r.data = make(map[string]interface{})
+ r.data = make(map[string]any)
}
for k, v := range in {
if _, found := r.data[k]; !found {
@@ -539,7 +539,7 @@ func (l *genericResource) relTargetPathsForRel(rel string) []string {
return targetPaths
}
-func (l *genericResource) updateParams(params map[string]interface{}) {
+func (l *genericResource) updateParams(params map[string]any) {
if l.params == nil {
l.params = params
return
diff --git a/resources/resource/params.go b/resources/resource/params.go
index c76eedeab..d88424e9d 100644
--- a/resources/resource/params.go
+++ b/resources/resource/params.go
@@ -19,7 +19,7 @@ import (
"github.com/spf13/cast"
)
-func Param(r ResourceParamsProvider, fallback maps.Params, key interface{}) (interface{}, error) {
+func Param(r ResourceParamsProvider, fallback maps.Params, key any) (any, error) {
keyStr, err := cast.ToStringE(key)
if err != nil {
return nil, err
diff --git a/resources/resource/resource_helpers.go b/resources/resource/resource_helpers.go
index b0830a83c..29f783ce3 100644
--- a/resources/resource/resource_helpers.go
+++ b/resources/resource/resource_helpers.go
@@ -24,17 +24,17 @@ import (
// GetParam will return the param with the given key from the Resource,
// nil if not found.
-func GetParam(r Resource, key string) interface{} {
+func GetParam(r Resource, key string) any {
return getParam(r, key, false)
}
// GetParamToLower is the same as GetParam but it will lower case any string
// result, including string slices.
-func GetParamToLower(r Resource, key string) interface{} {
+func GetParamToLower(r Resource, key string) any {
return getParam(r, key, true)
}
-func getParam(r Resource, key string, stringToLower bool) interface{} {
+func getParam(r Resource, key string, stringToLower bool) any {
v := r.Params()[strings.ToLower(key)]
if v == nil {
@@ -60,9 +60,9 @@ func getParam(r Resource, key string, stringToLower bool) interface{} {
return helpers.SliceToLower(val)
}
return v
- case map[string]interface{}: // JSON and TOML
+ case map[string]any:
return v
- case map[interface{}]interface{}: // YAML
+ case map[any]any:
return v
}
diff --git a/resources/resource/resources.go b/resources/resource/resources.go
index ac5dd0b2b..aaa747194 100644
--- a/resources/resource/resources.go
+++ b/resources/resource/resources.go
@@ -108,7 +108,7 @@ func (r Resources) MergeByLanguage(r2 Resources) Resources {
// MergeByLanguageInterface is the generic version of MergeByLanguage. It
// is here just so it can be called from the tpl package.
-func (r Resources) MergeByLanguageInterface(in interface{}) (interface{}, error) {
+func (r Resources) MergeByLanguageInterface(in any) (any, error) {
r2, ok := in.(Resources)
if !ok {
return nil, fmt.Errorf("%T cannot be merged by language", in)
diff --git a/resources/resource/resourcetypes.go b/resources/resource/resourcetypes.go
index 987c230a8..259706e2d 100644
--- a/resources/resource/resourcetypes.go
+++ b/resources/resource/resourcetypes.go
@@ -66,7 +66,7 @@ type ImageOps interface {
Fill(spec string) (Image, error)
Fit(spec string) (Image, error)
Resize(spec string) (Image, error)
- Filter(filters ...interface{}) (Image, error)
+ Filter(filters ...any) (Image, error)
Exif() *exif.Exif
// Internal
@@ -119,7 +119,7 @@ type ResourceParamsProvider interface {
type ResourceDataProvider interface {
// Resource specific data set by Hugo.
// One example would be.Data.Digest for fingerprinted resources.
- Data() interface{}
+ Data() any
}
// ResourcesLanguageMerger describes an interface for merging resources from a
@@ -127,7 +127,7 @@ type ResourceDataProvider interface {
type ResourcesLanguageMerger interface {
MergeByLanguage(other Resources) Resources
// Needed for integration with the tpl package.
- MergeByLanguageInterface(other interface{}) (interface{}, error)
+ MergeByLanguageInterface(other any) (any, error)
}
// Identifier identifies a resource.
@@ -152,7 +152,7 @@ type ContentProvider interface {
// * Page: template.HTML
// * JSON: String
// * Etc.
- Content() (interface{}, error)
+ Content() (any, error)
}
// OpenReadSeekCloser allows setting some other way (than reading from a filesystem)
diff --git a/resources/resource_cache.go b/resources/resource_cache.go
index f498bb0c0..52a48871e 100644
--- a/resources/resource_cache.go
+++ b/resources/resource_cache.go
@@ -44,7 +44,7 @@ type ResourceCache struct {
sync.RWMutex
// Either resource.Resource or resource.Resources.
- cache map[string]interface{}
+ cache map[string]any
fileCache *filecache.Cache
@@ -128,7 +128,7 @@ func newResourceCache(rs *Spec) *ResourceCache {
return &ResourceCache{
rs: rs,
fileCache: rs.FileCaches.AssetsCache(),
- cache: make(map[string]interface{}),
+ cache: make(map[string]any),
nlocker: locker.NewLocker(),
}
}
@@ -137,7 +137,7 @@ func (c *ResourceCache) clear() {
c.Lock()
defer c.Unlock()
- c.cache = make(map[string]interface{})
+ c.cache = make(map[string]any)
c.nlocker = locker.NewLocker()
}
@@ -151,7 +151,7 @@ func (c *ResourceCache) cleanKey(key string) string {
return strings.TrimPrefix(path.Clean(strings.ToLower(key)), "/")
}
-func (c *ResourceCache) get(key string) (interface{}, bool) {
+func (c *ResourceCache) get(key string) (any, bool) {
c.RLock()
defer c.RUnlock()
r, found := c.cache[key]
@@ -159,7 +159,7 @@ func (c *ResourceCache) get(key string) (interface{}, bool) {
}
func (c *ResourceCache) GetOrCreate(key string, f func() (resource.Resource, error)) (resource.Resource, error) {
- r, err := c.getOrCreate(key, func() (interface{}, error) { return f() })
+ r, err := c.getOrCreate(key, func() (any, error) { return f() })
if r == nil || err != nil {
return nil, err
}
@@ -167,14 +167,14 @@ func (c *ResourceCache) GetOrCreate(key string, f func() (resource.Resource, err
}
func (c *ResourceCache) GetOrCreateResources(key string, f func() (resource.Resources, error)) (resource.Resources, error) {
- r, err := c.getOrCreate(key, func() (interface{}, error) { return f() })
+ r, err := c.getOrCreate(key, func() (any, error) { return f() })
if r == nil || err != nil {
return nil, err
}
return r.(resource.Resources), nil
}
-func (c *ResourceCache) getOrCreate(key string, f func() (interface{}, error)) (interface{}, error) {
+func (c *ResourceCache) getOrCreate(key string, f func() (any, error)) (any, error) {
key = c.cleanKey(key)
// First check in-memory cache.
r, found := c.get(key)
@@ -254,7 +254,7 @@ func (c *ResourceCache) writeMeta(key string, meta transformedResourceMetadata)
return fi, fc, err
}
-func (c *ResourceCache) set(key string, r interface{}) {
+func (c *ResourceCache) set(key string, r any) {
c.Lock()
defer c.Unlock()
c.cache[key] = r
diff --git a/resources/resource_factories/create/remote.go b/resources/resource_factories/create/remote.go
index f127f8edc..0ca2be834 100644
--- a/resources/resource_factories/create/remote.go
+++ b/resources/resource_factories/create/remote.go
@@ -38,7 +38,7 @@ import (
// FromRemote expects one or n-parts of a URL to a resource
// If you provide multiple parts they will be joined together to the final URL.
-func (c *Client) FromRemote(uri string, optionsm map[string]interface{}) (resource.Resource, error) {
+func (c *Client) FromRemote(uri string, optionsm map[string]any) (resource.Resource, error) {
rURL, err := url.Parse(uri)
if err != nil {
return nil, errors.Wrapf(err, "failed to parse URL for resource %s", uri)
@@ -174,7 +174,7 @@ func addDefaultHeaders(req *http.Request, accepts ...string) {
}
}
-func addUserProvidedHeaders(headers map[string]interface{}, req *http.Request) {
+func addUserProvidedHeaders(headers map[string]any, req *http.Request) {
if headers == nil {
return
}
@@ -209,7 +209,7 @@ func hasHeaderKey(m http.Header, key string) bool {
type fromRemoteOptions struct {
Method string
- Headers map[string]interface{}
+ Headers map[string]any
Body []byte
}
@@ -220,7 +220,7 @@ func (o fromRemoteOptions) BodyReader() io.Reader {
return bytes.NewBuffer(o.Body)
}
-func decodeRemoteOptions(optionsm map[string]interface{}) (fromRemoteOptions, error) {
+func decodeRemoteOptions(optionsm map[string]any) (fromRemoteOptions, error) {
options := fromRemoteOptions{
Method: "GET",
}
diff --git a/resources/resource_factories/create/remote_test.go b/resources/resource_factories/create/remote_test.go
index 42e3fc890..cfd18269f 100644
--- a/resources/resource_factories/create/remote_test.go
+++ b/resources/resource_factories/create/remote_test.go
@@ -24,21 +24,21 @@ func TestDecodeRemoteOptions(t *testing.T) {
for _, test := range []struct {
name string
- args map[string]interface{}
+ args map[string]any
want fromRemoteOptions
wantErr bool
}{
{
"POST",
- map[string]interface{}{
+ map[string]any{
"meThod": "PoST",
- "headers": map[string]interface{}{
+ "headers": map[string]any{
"foo": "bar",
},
},
fromRemoteOptions{
Method: "POST",
- Headers: map[string]interface{}{
+ Headers: map[string]any{
"foo": "bar",
},
},
@@ -46,7 +46,7 @@ func TestDecodeRemoteOptions(t *testing.T) {
},
{
"Body",
- map[string]interface{}{
+ map[string]any{
"meThod": "POST",
"body": []byte("foo"),
},
@@ -58,7 +58,7 @@ func TestDecodeRemoteOptions(t *testing.T) {
},
{
"Body, string",
- map[string]interface{}{
+ map[string]any{
"meThod": "POST",
"body": "foo",
},
diff --git a/resources/resource_metadata.go b/resources/resource_metadata.go
index 0dd0945e3..6c979b4bf 100644
--- a/resources/resource_metadata.go
+++ b/resources/resource_metadata.go
@@ -43,7 +43,7 @@ type metaAssigner interface {
setTitle(title string)
setName(name string)
setMediaType(mediaType media.Type)
- updateParams(params map[string]interface{})
+ updateParams(params map[string]any)
}
const counterPlaceHolder = ":counter"
@@ -53,7 +53,7 @@ const counterPlaceHolder = ":counter"
// This assignment is additive, but the most specific match needs to be first.
// The `name` and `title` metadata field support shell-matched collection it got a match in.
// See https://golang.org/pkg/path/#Match
-func AssignMetadata(metadata []map[string]interface{}, resources ...resource.Resource) error {
+func AssignMetadata(metadata []map[string]any, resources ...resource.Resource) error {
counters := make(map[string]int)
for _, r := range resources {
diff --git a/resources/resource_metadata_test.go b/resources/resource_metadata_test.go
index 87a537f74..fa9659162 100644
--- a/resources/resource_metadata_test.go
+++ b/resources/resource_metadata_test.go
@@ -30,10 +30,10 @@ func TestAssignMetadata(t *testing.T) {
var resources resource.Resources
for _, this := range []struct {
- metaData []map[string]interface{}
+ metaData []map[string]any
assertFunc func(err error)
}{
- {[]map[string]interface{}{
+ {[]map[string]any{
{
"title": "My Resource",
"name": "My Name",
@@ -44,7 +44,7 @@ func TestAssignMetadata(t *testing.T) {
c.Assert(logo1.Name(), qt.Equals, "My Name")
c.Assert(foo2.Name(), qt.Equals, "My Name")
}},
- {[]map[string]interface{}{
+ {[]map[string]any{
{
"title": "My Logo",
"src": "*loGo*",
@@ -62,11 +62,11 @@ func TestAssignMetadata(t *testing.T) {
c.Assert(foo3.Name(), qt.Equals, "My Name")
c.Assert(foo3.Title(), qt.Equals, "My Resource")
}},
- {[]map[string]interface{}{
+ {[]map[string]any{
{
"title": "My Logo",
"src": "*loGo*",
- "params": map[string]interface{}{
+ "params": map[string]any{
"Param1": true,
"icon": "logo",
},
@@ -74,7 +74,7 @@ func TestAssignMetadata(t *testing.T) {
{
"title": "My Resource",
"src": "*",
- "params": map[string]interface{}{
+ "params": map[string]any{
"Param2": true,
"icon": "resource",
},
@@ -101,7 +101,7 @@ func TestAssignMetadata(t *testing.T) {
c.Assert(icon1, qt.Equals, "logo")
c.Assert(icon2, qt.Equals, "resource")
}},
- {[]map[string]interface{}{
+ {[]map[string]any{
{
"name": "Logo Name #:counter",
"src": "*logo*",
@@ -124,7 +124,7 @@ func TestAssignMetadata(t *testing.T) {
c.Assert(resources.GetMatch("logo name #1*"), qt.Equals, logo2)
}},
- {[]map[string]interface{}{
+ {[]map[string]any{
{
"title": "Third Logo #:counter",
"src": "logo3.png",
@@ -143,7 +143,7 @@ func TestAssignMetadata(t *testing.T) {
c.Assert(logo1.Title(), qt.Equals, "Other Logo #2")
c.Assert(logo1.Name(), qt.Equals, "Name #2")
}},
- {[]map[string]interface{}{
+ {[]map[string]any{
{
"title": "Third Logo",
"src": "logo3.png",
@@ -162,7 +162,7 @@ func TestAssignMetadata(t *testing.T) {
c.Assert(logo1.Title(), qt.Equals, "Other Logo #2")
c.Assert(logo1.Name(), qt.Equals, "Name #2")
}},
- {[]map[string]interface{}{
+ {[]map[string]any{
{
"name": "third-logo",
"src": "logo3.png",
@@ -181,7 +181,7 @@ func TestAssignMetadata(t *testing.T) {
c.Assert(logo1.Title(), qt.Equals, "Logo #2")
c.Assert(logo1.Name(), qt.Equals, "Name #2")
}},
- {[]map[string]interface{}{
+ {[]map[string]any{
{
"title": "Third Logo #:counter",
},
@@ -189,7 +189,7 @@ func TestAssignMetadata(t *testing.T) {
// Missing src
c.Assert(err, qt.Not(qt.IsNil))
}},
- {[]map[string]interface{}{
+ {[]map[string]any{
{
"title": "Title",
"src": "[]",
diff --git a/resources/resource_spec.go b/resources/resource_spec.go
index cd1e5010d..fd9653012 100644
--- a/resources/resource_spec.go
+++ b/resources/resource_spec.go
@@ -240,7 +240,7 @@ func (r *Spec) newGenericResourceWithBase(
mediaType: mediaType,
resourceType: resourceType,
spec: r,
- params: make(map[string]interface{}),
+ params: make(map[string]any),
name: baseFilename,
title: baseFilename,
resourceContent: &resourceContent{},
diff --git a/resources/resource_test.go b/resources/resource_test.go
index 9823c064d..031c7b3c6 100644
--- a/resources/resource_test.go
+++ b/resources/resource_test.go
@@ -244,7 +244,7 @@ func BenchmarkAssignMetadata(b *testing.B) {
for i := 0; i < b.N; i++ {
b.StopTimer()
var resources resource.Resources
- meta := []map[string]interface{}{
+ meta := []map[string]any{
{
"title": "Foo #:counter",
"name": "Foo Name #:counter",
diff --git a/resources/resource_transformers/babel/babel.go b/resources/resource_transformers/babel/babel.go
index c20a131f6..a4744961e 100644
--- a/resources/resource_transformers/babel/babel.go
+++ b/resources/resource_transformers/babel/babel.go
@@ -50,7 +50,7 @@ type Options struct {
}
// DecodeOptions decodes options to and generates command flags
-func DecodeOptions(m map[string]interface{}) (opts Options, err error) {
+func DecodeOptions(m map[string]any) (opts Options, err error) {
if m == nil {
return
}
@@ -58,8 +58,8 @@ func DecodeOptions(m map[string]interface{}) (opts Options, err error) {
return
}
-func (opts Options) toArgs() []interface{} {
- var args []interface{}
+func (opts Options) toArgs() []any {
+ var args []any
// external is not a known constant on the babel command line
// .sourceMaps must be a boolean, "inline", "both", or undefined
@@ -147,11 +147,11 @@ func (t *babelTransformation) Transform(ctx *resources.ResourceTransformationCtx
ctx.ReplaceOutPathExtension(".js")
- var cmdArgs []interface{}
+ var cmdArgs []any
if configFile != "" {
logger.Infoln("babel: use config file", configFile)
- cmdArgs = []interface{}{"--config-file", configFile}
+ cmdArgs = []any{"--config-file", configFile}
}
if optArgs := t.options.toArgs(); len(optArgs) > 0 {
diff --git a/resources/resource_transformers/htesting/testhelpers.go b/resources/resource_transformers/htesting/testhelpers.go
index 674101f03..147e5b89c 100644
--- a/resources/resource_transformers/htesting/testhelpers.go
+++ b/resources/resource_transformers/htesting/testhelpers.go
@@ -31,7 +31,7 @@ func NewTestResourceSpec() (*resources.Spec, error) {
cfg.Set("baseURL", "https://example.org")
cfg.Set("publishDir", "public")
- imagingCfg := map[string]interface{}{
+ imagingCfg := map[string]any{
"resampleFilter": "linear",
"quality": 68,
"anchor": "left",
diff --git a/resources/resource_transformers/integrity/integrity_test.go b/resources/resource_transformers/integrity/integrity_test.go
index 8a17fef7a..cba993d1e 100644
--- a/resources/resource_transformers/integrity/integrity_test.go
+++ b/resources/resource_transformers/integrity/integrity_test.go
@@ -62,7 +62,7 @@ func TestTransform(t *testing.T) {
c.Assert(err, qt.IsNil)
c.Assert(transformed.RelPermalink(), qt.Equals, "/hugo.a5ad1c6961214a55de53c1ce6e60d27b6b761f54851fa65e33066460dfa6a0db.txt")
- c.Assert(transformed.Data(), qt.DeepEquals, map[string]interface{}{"Integrity": template.HTMLAttr("sha256-pa0caWEhSlXeU8HObmDSe2t2H1SFH6ZeMwZkYN+moNs=")})
+ c.Assert(transformed.Data(), qt.DeepEquals, map[string]any{"Integrity": template.HTMLAttr("sha256-pa0caWEhSlXeU8HObmDSe2t2H1SFH6ZeMwZkYN+moNs=")})
content, err := transformed.(resource.ContentProvider).Content()
c.Assert(err, qt.IsNil)
c.Assert(content, qt.Equals, "Hugo Rocks!")
diff --git a/resources/resource_transformers/js/build.go b/resources/resource_transformers/js/build.go
index 12d0dd410..3c6f24fc0 100644
--- a/resources/resource_transformers/js/build.go
+++ b/resources/resource_transformers/js/build.go
@@ -54,7 +54,7 @@ func New(fs *filesystems.SourceFilesystem, rs *resources.Spec) *Client {
}
type buildTransformation struct {
- optsm map[string]interface{}
+ optsm map[string]any
c *Client
}
@@ -205,7 +205,7 @@ func (t *buildTransformation) Transform(ctx *resources.ResourceTransformationCtx
}
// Process process esbuild transform
-func (c *Client) Process(res resources.ResourceTransformer, opts map[string]interface{}) (resource.Resource, error) {
+func (c *Client) Process(res resources.ResourceTransformer, opts map[string]any) (resource.Resource, error) {
return res.Transform(
&buildTransformation{c: c, optsm: opts},
)
diff --git a/resources/resource_transformers/js/options.go b/resources/resource_transformers/js/options.go
index 9d2bb2e70..675e40d43 100644
--- a/resources/resource_transformers/js/options.go
+++ b/resources/resource_transformers/js/options.go
@@ -71,14 +71,14 @@ type Options struct {
Inject []string
// User defined symbols.
- Defines map[string]interface{}
+ Defines map[string]any
// Maps a component import to another.
Shims map[string]string
// User defined params. Will be marshaled to JSON and available as "@params", e.g.
// import * as params from '@params';
- Params interface{}
+ Params any
// What to use instead of React.createElement.
JSXFactory string
@@ -106,7 +106,7 @@ type Options struct {
tsConfig string
}
-func decodeOptions(m map[string]interface{}) (Options, error) {
+func decodeOptions(m map[string]any) (Options, error) {
var opts Options
if err := mapstructure.WeakDecode(m, &opts); err != nil {
@@ -269,7 +269,7 @@ func createBuildPlugins(c *Client, opts Options) ([]api.Plugin, error) {
params := opts.Params
if params == nil {
// This way @params will always resolve to something.
- params = make(map[string]interface{})
+ params = make(map[string]any)
}
b, err := json.Marshal(params)
diff --git a/resources/resource_transformers/js/options_test.go b/resources/resource_transformers/js/options_test.go
index e5b04e355..7596f357e 100644
--- a/resources/resource_transformers/js/options_test.go
+++ b/resources/resource_transformers/js/options_test.go
@@ -33,7 +33,7 @@ import (
func TestOptionKey(t *testing.T) {
c := qt.New(t)
- opts := map[string]interface{}{
+ opts := map[string]any{
"TargetPath": "foo",
"Target": "es2018",
}
diff --git a/resources/resource_transformers/postcss/postcss.go b/resources/resource_transformers/postcss/postcss.go
index 56cbea156..61209fb23 100644
--- a/resources/resource_transformers/postcss/postcss.go
+++ b/resources/resource_transformers/postcss/postcss.go
@@ -57,7 +57,7 @@ func New(rs *resources.Spec) *Client {
return &Client{rs: rs}
}
-func DecodeOptions(m map[string]interface{}) (opts Options, err error) {
+func DecodeOptions(m map[string]any) (opts Options, err error) {
if m == nil {
return
}
@@ -165,11 +165,11 @@ func (t *postcssTransformation) Transform(ctx *resources.ResourceTransformationC
}
}
- var cmdArgs []interface{}
+ var cmdArgs []any
if configFile != "" {
logger.Infoln("postcss: use config file", configFile)
- cmdArgs = []interface{}{"--config", configFile}
+ cmdArgs = []any{"--config", configFile}
}
if optArgs := t.options.toArgs(); len(optArgs) > 0 {
diff --git a/resources/resource_transformers/postcss/postcss_test.go b/resources/resource_transformers/postcss/postcss_test.go
index c5f855445..4548bca98 100644
--- a/resources/resource_transformers/postcss/postcss_test.go
+++ b/resources/resource_transformers/postcss/postcss_test.go
@@ -31,14 +31,14 @@ import (
// Issue 6166
func TestDecodeOptions(t *testing.T) {
c := qt.New(t)
- opts1, err := DecodeOptions(map[string]interface{}{
+ opts1, err := DecodeOptions(map[string]any{
"no-map": true,
})
c.Assert(err, qt.IsNil)
c.Assert(opts1.NoMap, qt.Equals, true)
- opts2, err := DecodeOptions(map[string]interface{}{
+ opts2, err := DecodeOptions(map[string]any{
"noMap": true,
})
diff --git a/resources/resource_transformers/templates/execute_as_template.go b/resources/resource_transformers/templates/execute_as_template.go
index 115b3d047..5c2033ff9 100644
--- a/resources/resource_transformers/templates/execute_as_template.go
+++ b/resources/resource_transformers/templates/execute_as_template.go
@@ -44,7 +44,7 @@ type executeAsTemplateTransform struct {
rs *resources.Spec
t tpl.TemplatesProvider
targetPath string
- data interface{}
+ data any
}
func (t *executeAsTemplateTransform) Key() internal.ResourceTransformationKey {
@@ -63,7 +63,7 @@ func (t *executeAsTemplateTransform) Transform(ctx *resources.ResourceTransforma
return t.t.Tmpl().Execute(templ, ctx.To, t.data)
}
-func (c *Client) ExecuteAsTemplate(res resources.ResourceTransformer, targetPath string, data interface{}) (resource.Resource, error) {
+func (c *Client) ExecuteAsTemplate(res resources.ResourceTransformer, targetPath string, data any) (resource.Resource, error) {
return res.Transform(&executeAsTemplateTransform{
rs: c.rs,
targetPath: helpers.ToSlashTrimLeading(targetPath),
diff --git a/resources/resource_transformers/tocss/dartsass/client.go b/resources/resource_transformers/tocss/dartsass/client.go
index 647cf86aa..fb794f4e8 100644
--- a/resources/resource_transformers/tocss/dartsass/client.go
+++ b/resources/resource_transformers/tocss/dartsass/client.go
@@ -69,7 +69,7 @@ type Client struct {
transpiler *godartsass.Transpiler
}
-func (c *Client) ToCSS(res resources.ResourceTransformer, args map[string]interface{}) (resource.Resource, error) {
+func (c *Client) ToCSS(res resources.ResourceTransformer, args map[string]any) (resource.Resource, error) {
if c.dartSassNotAvailable {
return res.Transform(resources.NewFeatureNotAvailableTransformer(transformationName, args))
}
@@ -123,7 +123,7 @@ type Options struct {
EnableSourceMap bool
}
-func decodeOptions(m map[string]interface{}) (opts Options, err error) {
+func decodeOptions(m map[string]any) (opts Options, err error) {
if m == nil {
return
}
diff --git a/resources/resource_transformers/tocss/dartsass/transform.go b/resources/resource_transformers/tocss/dartsass/transform.go
index aaf9d4bf8..79c32fcfd 100644
--- a/resources/resource_transformers/tocss/dartsass/transform.go
+++ b/resources/resource_transformers/tocss/dartsass/transform.go
@@ -53,7 +53,7 @@ func Supports() bool {
}
type transform struct {
- optsm map[string]interface{}
+ optsm map[string]any
c *Client
}
diff --git a/resources/resource_transformers/tocss/scss/client.go b/resources/resource_transformers/tocss/scss/client.go
index f3fe7921b..ecaceaa6c 100644
--- a/resources/resource_transformers/tocss/scss/client.go
+++ b/resources/resource_transformers/tocss/scss/client.go
@@ -62,7 +62,7 @@ type Options struct {
EnableSourceMap bool
}
-func DecodeOptions(m map[string]interface{}) (opts Options, err error) {
+func DecodeOptions(m map[string]any) (opts Options, err error) {
if m == nil {
return
}
diff --git a/resources/resource_transformers/tocss/scss/client_extended.go b/resources/resource_transformers/tocss/scss/client_extended.go
index 2265e455e..c9b347c4c 100644
--- a/resources/resource_transformers/tocss/scss/client_extended.go
+++ b/resources/resource_transformers/tocss/scss/client_extended.go
@@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+//go:build extended
// +build extended
package scss
diff --git a/resources/resource_transformers/tocss/scss/client_notavailable.go b/resources/resource_transformers/tocss/scss/client_notavailable.go
index a73280ccc..efd79109b 100644
--- a/resources/resource_transformers/tocss/scss/client_notavailable.go
+++ b/resources/resource_transformers/tocss/scss/client_notavailable.go
@@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+//go:build !extended
// +build !extended
package scss
diff --git a/resources/resource_transformers/tocss/scss/tocss.go b/resources/resource_transformers/tocss/scss/tocss.go
index de33b663e..802798e59 100644
--- a/resources/resource_transformers/tocss/scss/tocss.go
+++ b/resources/resource_transformers/tocss/scss/tocss.go
@@ -11,6 +11,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+//go:build extended
// +build extended
package scss
diff --git a/resources/testhelpers_test.go b/resources/testhelpers_test.go
index 14d431644..9941e12cf 100644
--- a/resources/testhelpers_test.go
+++ b/resources/testhelpers_test.go
@@ -70,7 +70,7 @@ func newTestResourceSpec(desc specDescriptor) *Spec {
cfg := createTestCfg()
cfg.Set("baseURL", baseURL)
- imagingCfg := map[string]interface{}{
+ imagingCfg := map[string]any{
"resampleFilter": "linear",
"quality": 68,
"anchor": "left",
diff --git a/resources/transform.go b/resources/transform.go
index 67f5c1461..cbf77363c 100644
--- a/resources/transform.go
+++ b/resources/transform.go
@@ -108,7 +108,7 @@ type ResourceTransformationCtx struct {
// Data data can be set on the transformed Resource. Not that this need
// to be simple types, as it needs to be serialized to JSON and back.
- Data map[string]interface{}
+ Data map[string]any
// This is used to publish additional artifacts, e.g. source maps.
// We may improve this.
@@ -159,7 +159,7 @@ type resourceAdapter struct {
*resourceAdapterInner
}
-func (r *resourceAdapter) Content() (interface{}, error) {
+func (r *resourceAdapter) Content() (any, error) {
r.init(false, true)
if r.transformationsErr != nil {
return nil, r.transformationsErr
@@ -171,7 +171,7 @@ func (r *resourceAdapter) Err() error {
return nil
}
-func (r *resourceAdapter) Data() interface{} {
+func (r *resourceAdapter) Data() any {
r.init(false, false)
return r.target.Data()
}
@@ -188,7 +188,7 @@ func (r *resourceAdapter) Fit(spec string) (resource.Image, error) {
return r.getImageOps().Fit(spec)
}
-func (r *resourceAdapter) Filter(filters ...interface{}) (resource.Image, error) {
+func (r *resourceAdapter) Filter(filters ...any) (resource.Image, error) {
return r.getImageOps().Filter(filters...)
}
@@ -355,7 +355,7 @@ func (r *resourceAdapter) transform(publish, setContent bool) error {
defer bp.PutBuffer(b2)
tctx := &ResourceTransformationCtx{
- Data: make(map[string]interface{}),
+ Data: make(map[string]any),
OpenResourcePublisher: r.target.openPublishFileForWriting,
}
@@ -605,7 +605,7 @@ type transformationUpdate struct {
sourceFs afero.Fs
targetPath string
mediaType media.Type
- data map[string]interface{}
+ data map[string]any
startCtx ResourceTransformationCtx
}
@@ -631,9 +631,9 @@ func (u *transformationUpdate) updateFromCtx(ctx *ResourceTransformationCtx) {
// We will persist this information to disk.
type transformedResourceMetadata struct {
- Target string `json:"Target"`
- MediaTypeV string `json:"MediaType"`
- MetaData map[string]interface{} `json:"Data"`
+ Target string `json:"Target"`
+ MediaTypeV string `json:"MediaType"`
+ MetaData map[string]any `json:"Data"`
}
// contentReadSeekerCloser returns a ReadSeekerCloser if possible for a given Resource.
diff --git a/resources/transform_test.go b/resources/transform_test.go
index 30de6caa4..cfc004224 100644
--- a/resources/transform_test.go
+++ b/resources/transform_test.go
@@ -118,7 +118,7 @@ func TestTransform(t *testing.T) {
c.Assert(tr.RelPermalink(), qt.Equals, "/f1.csv")
assertShouldExist(c, spec, "public/f1.csv", true)
- data := tr.Data().(map[string]interface{})
+ data := tr.Data().(map[string]any)
c.Assert(data["mydata"], qt.Equals, "Hugo Rocks!")
assertNoDuplicateWrites(c, spec)
@@ -211,7 +211,7 @@ func TestTransform(t *testing.T) {
in = strings.Replace(in, "blue", "green", 1)
ctx.AddOutPathIdentifier("." + "cached")
ctx.OutMediaType = media.CSVType
- ctx.Data = map[string]interface{}{
+ ctx.Data = map[string]any{
"Hugo": "Rocks!",
}
fmt.Fprint(ctx.To, in)
@@ -236,7 +236,7 @@ func TestTransform(t *testing.T) {
c.Assert(err, qt.IsNil)
c.Assert(content, qt.Equals, "color is green", msg)
c.Assert(tr.MediaType(), eq, media.CSVType)
- c.Assert(tr.Data(), qt.DeepEquals, map[string]interface{}{
+ c.Assert(tr.Data(), qt.DeepEquals, map[string]any{
"Hugo": "Rocks!",
})