all: Run modernize -fix ./...

This commit is contained in:
Bjørn Erik Pedersen
2025-02-26 10:15:04 +01:00
parent b7ae24b9c2
commit 521911a576
141 changed files with 302 additions and 354 deletions

View File

@@ -109,10 +109,7 @@ func ExtractTOC(content []byte) (newcontent []byte, toc []byte) {
startOfTOC := bytes.Index(content, first)
peekEnd := len(content)
if peekEnd > 70+startOfTOC {
peekEnd = 70 + startOfTOC
}
peekEnd := min(len(content), 70+startOfTOC)
if startOfTOC < 0 {
return stripEmptyNav(content), toc

View File

@@ -43,11 +43,7 @@ func Emojify(source []byte) []byte {
j := start + k
upper := j + emojiMaxSize
if upper > len(source) {
upper = len(source)
}
upper := min(j+emojiMaxSize, len(source))
endEmoji := bytes.Index(source[j+1:upper], emojiDelim)
nextWordDelim := bytes.Index(source[j:upper], emojiWordDelim)

View File

@@ -63,7 +63,7 @@ func UniqueStrings(s []string) []string {
unique := make([]string, 0, len(s))
for i, val := range s {
var seen bool
for j := 0; j < i; j++ {
for j := range i {
if s[j] == val {
seen = true
break
@@ -83,7 +83,7 @@ func UniqueStringsReuse(s []string) []string {
for i, val := range s {
var seen bool
for j := 0; j < i; j++ {
for j := range i {
if s[j] == val {
seen = true
break

View File

@@ -89,7 +89,7 @@ func ProcessingStatsTable(w io.Writer, stats ...*ProcessingStats) {
var data [][]string
for i := 0; i < len(stats); i++ {
for i := range stats {
stat := stats[i]
names[i+1] = stat.Name

View File

@@ -101,10 +101,10 @@ func doTestAbsURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool,
v := config.New()
if multilingual {
v.Set("languages", map[string]any{
"fr": map[string]interface{}{
"fr": map[string]any{
"weight": 20,
},
"en": map[string]interface{}{
"en": map[string]any{
"weight": 10,
},
})
@@ -112,7 +112,7 @@ func doTestAbsURL(t *testing.T, defaultInSubDir, addLanguage, multilingual bool,
} else {
v.Set("defaultContentLanguage", lang)
v.Set("languages", map[string]any{
lang: map[string]interface{}{
lang: map[string]any{
"weight": 10,
},
})
@@ -167,10 +167,10 @@ func doTestRelURL(t testing.TB, defaultInSubDir, addLanguage, multilingual bool,
v := config.New()
if multilingual {
v.Set("languages", map[string]any{
"fr": map[string]interface{}{
"fr": map[string]any{
"weight": 20,
},
"en": map[string]interface{}{
"en": map[string]any{
"weight": 10,
},
})
@@ -178,7 +178,7 @@ func doTestRelURL(t testing.TB, defaultInSubDir, addLanguage, multilingual bool,
} else {
v.Set("defaultContentLanguage", lang)
v.Set("languages", map[string]any{
lang: map[string]interface{}{
lang: map[string]any{
"weight": 10,
},
})