all: Run go fix ./...
This commit is contained in:
+1
-3
@@ -103,9 +103,7 @@ func (c *Inspector) MethodsFromTypes(include []reflect.Type, exclude []reflect.T
|
||||
}
|
||||
|
||||
for _, t := range include {
|
||||
for i := range t.NumMethod() {
|
||||
|
||||
m := t.Method(i)
|
||||
for m := range t.Methods() {
|
||||
if excludes[m.Name] || seen[m.Name] {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -134,11 +134,6 @@ func (l LowHigh[S]) Value(source S) S {
|
||||
// This is only used for debugging purposes.
|
||||
var InvocationCounter atomic.Int64
|
||||
|
||||
// NewTrue returns a pointer to b.
|
||||
func NewBool(b bool) *bool {
|
||||
return &b
|
||||
}
|
||||
|
||||
// WeightProvider provides a weight.
|
||||
type WeightProvider interface {
|
||||
Weight() int
|
||||
|
||||
@@ -200,8 +200,8 @@ func structTypes(v reflect.Value, m map[reflect.Type]struct{}) {
|
||||
}
|
||||
case reflect.Struct:
|
||||
m[v.Type()] = struct{}{}
|
||||
for i := range v.NumField() {
|
||||
structTypes(v.Field(i), m)
|
||||
for _, field := range v.Fields() {
|
||||
structTypes(field, m)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2034,16 +2034,17 @@ func BenchmarkIsTranslatedOneLanguage(b *testing.B) {
|
||||
// Set it reasonably high to get a balance between cached and uncached calls to IsTranslated.
|
||||
const numPages = 3000
|
||||
|
||||
files := `
|
||||
var files strings.Builder
|
||||
files.WriteString(`
|
||||
-- hugo.toml --
|
||||
disableKinds = ["taxonomy", "term"]
|
||||
`
|
||||
`)
|
||||
for i := range numPages {
|
||||
files += fmt.Sprintf(`
|
||||
-- content/sect/p%d.md --`, i)
|
||||
files.WriteString(fmt.Sprintf(`
|
||||
-- content/sect/p%d.md --`, i))
|
||||
}
|
||||
|
||||
bb := Test(b, files, TestOptSkipRender())
|
||||
bb := Test(b, files.String(), TestOptSkipRender())
|
||||
p := bb.H.Sites[0].RegularPages()
|
||||
|
||||
b.ResetTimer()
|
||||
|
||||
@@ -16,6 +16,7 @@ package esbuild
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"maps"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
@@ -301,9 +302,7 @@ OUTER:
|
||||
loaders = make(map[string]api.Loader)
|
||||
// Add default CSS file loaders.
|
||||
// May be overridden by opts.Loaders.
|
||||
for ext, loader := range extensionToLoaderMapCSS {
|
||||
loaders[ext] = loader
|
||||
}
|
||||
maps.Copy(loaders, extensionToLoaderMapCSS)
|
||||
}
|
||||
if opts.Loaders != nil {
|
||||
if loaders == nil {
|
||||
|
||||
@@ -159,7 +159,7 @@ func (d *AvifCodec) Decode(r io.Reader) (image.Image, error) {
|
||||
return nil, fmt.Errorf("decoded AVIF frame count %d does not match frame durations %d", frameCount, len(out.Data.Params.FrameDurations))
|
||||
}
|
||||
frames := make([]image.Image, frameCount)
|
||||
for i := 0; i < len(frames); i++ {
|
||||
for i := range frames {
|
||||
frameBytes := destination.Bytes()[i*frameSize : (i+1)*frameSize]
|
||||
if isHDR {
|
||||
// NRGBA64 for HDR - libavif returns non-premultiplied alpha.
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/gohugoio/hugo/common/hashing"
|
||||
@@ -255,23 +256,23 @@ func ensureWorkspaceRef(fsys afero.Fs, workspacePath string) error {
|
||||
wsVal, hasWS := pkg["workspaces"]
|
||||
|
||||
switch v := wsVal.(type) {
|
||||
case []interface{}:
|
||||
case []any:
|
||||
// Array form: ["pkg-a", "pkg-b", ...]
|
||||
if containsString(toStringSlice(v), workspacePath) {
|
||||
if slices.Contains(toStringSlice(v), workspacePath) {
|
||||
if runtime.GOOS == "windows" {
|
||||
return afero.WriteFile(fsys, packageJSONName, data, 0o666)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// Fall through to byte-based insertion into the existing array below.
|
||||
case map[string]interface{}:
|
||||
case map[string]any:
|
||||
// Object form: { "workspaces": { "packages": [...] } }
|
||||
packagesVal, ok := v["packages"]
|
||||
if !ok {
|
||||
return fmt.Errorf("npm pack: unsupported workspaces object; missing \"packages\" field")
|
||||
}
|
||||
packagesSlice := toStringSlice(packagesVal)
|
||||
if containsString(packagesSlice, workspacePath) {
|
||||
if slices.Contains(packagesSlice, workspacePath) {
|
||||
if runtime.GOOS == "windows" {
|
||||
return afero.WriteFile(fsys, packageJSONName, data, 0o666)
|
||||
}
|
||||
@@ -279,7 +280,7 @@ func ensureWorkspaceRef(fsys afero.Fs, workspacePath string) error {
|
||||
}
|
||||
|
||||
// Append the new workspace path to the packages slice.
|
||||
newPkgs := make([]interface{}, 0, len(packagesSlice)+1)
|
||||
newPkgs := make([]any, 0, len(packagesSlice)+1)
|
||||
for _, s := range packagesSlice {
|
||||
newPkgs = append(newPkgs, s)
|
||||
}
|
||||
@@ -349,7 +350,7 @@ func ensureWorkspaceRef(fsys afero.Fs, workspacePath string) error {
|
||||
}
|
||||
|
||||
func detectIndent(data []byte) string {
|
||||
for _, line := range bytes.Split(data, []byte("\n")) {
|
||||
for line := range bytes.SplitSeq(data, []byte("\n")) {
|
||||
trimmed := bytes.TrimLeft(line, " \t")
|
||||
if len(trimmed) < len(line) && len(trimmed) > 0 && trimmed[0] == '"' {
|
||||
return string(line[:len(line)-len(trimmed)])
|
||||
@@ -385,15 +386,6 @@ func toStringSlice(v any) []string {
|
||||
return nil
|
||||
}
|
||||
|
||||
func containsString(ss []string, s string) bool {
|
||||
for _, v := range ss {
|
||||
if v == s {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// resolveProjectWorkspaces resolves workspace patterns from the project's
|
||||
// package source, skipping the hugoautogen workspace.
|
||||
func resolveProjectWorkspaces(sourceFs afero.Fs, workspacesSource map[string]any, skipPath string) []string {
|
||||
|
||||
@@ -156,17 +156,18 @@ Len related: {{ site.RegularPages.Related . | len }}
|
||||
`)
|
||||
|
||||
createContent := func(n int) string {
|
||||
base := `---
|
||||
var base strings.Builder
|
||||
base.WriteString(`---
|
||||
title: "Page %d"
|
||||
keywords: ['k%d']
|
||||
---
|
||||
`
|
||||
`)
|
||||
|
||||
for range 32 {
|
||||
base += fmt.Sprintf("\n## Title %d", rand.Intn(100))
|
||||
base.WriteString(fmt.Sprintf("\n## Title %d", rand.Intn(100)))
|
||||
}
|
||||
|
||||
return fmt.Sprintf(base, n, rand.Intn(32))
|
||||
return fmt.Sprintf(base.String(), n, rand.Intn(32))
|
||||
}
|
||||
|
||||
for i := 1; i < 100; i++ {
|
||||
|
||||
@@ -31,8 +31,8 @@ func structToMap(s any) map[string]any {
|
||||
m := make(map[string]any)
|
||||
t := reflect.TypeOf(s)
|
||||
|
||||
for i := range t.NumMethod() {
|
||||
method := t.Method(i)
|
||||
for method := range t.Methods() {
|
||||
|
||||
if method.PkgPath != "" {
|
||||
continue
|
||||
}
|
||||
@@ -41,8 +41,7 @@ func structToMap(s any) map[string]any {
|
||||
}
|
||||
}
|
||||
|
||||
for i := range t.NumField() {
|
||||
field := t.Field(i)
|
||||
for field := range t.Fields() {
|
||||
if field.PkgPath != "" {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -214,8 +214,8 @@ func (t *TemplateFuncsNamespace) toJSON(ctx context.Context) ([]byte, error) {
|
||||
return nil, nil
|
||||
}
|
||||
ctxType := reflect.TypeOf(tctx)
|
||||
for i := range ctxType.NumMethod() {
|
||||
method := ctxType.Method(i)
|
||||
for method := range ctxType.Methods() {
|
||||
method := method
|
||||
if ignoreFuncs[method.Name] {
|
||||
continue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user