Upgrade to golangci-lint v2 (#1008)

This commit is contained in:
Nathan Baulch
2026-01-05 01:54:29 +11:00
committed by GitHub
parent 9702fae9b8
commit a675c6b3e2
45 changed files with 568 additions and 649 deletions
+21 -18
View File
@@ -18,6 +18,7 @@ import (
"strings"
"text/template"
"time"
"unicode"
)
type invalid struct {
@@ -28,7 +29,7 @@ type invalid struct {
type valid struct {
Name string
Input string
JsonRef string
JSONRef string
}
type testsCollection struct {
@@ -39,12 +40,11 @@ type testsCollection struct {
Count int
}
const srcTemplate = "// Generated by tomltestgen for toml-test ref {{.Ref}} on {{.Timestamp}}\n" +
const srcTemplate = "// Code generated by tomltestgen for toml-test ref {{.Ref}} on {{.Timestamp}}. DO NOT EDIT.\n" +
"package toml_test\n" +
" import (\n" +
" \"testing\"\n" +
")\n" +
"{{range .Invalid}}\n" +
"func TestTOMLTest_Invalid_{{.Name}}(t *testing.T) {\n" +
" input := {{.Input|gostr}}\n" +
@@ -55,28 +55,31 @@ const srcTemplate = "// Generated by tomltestgen for toml-test ref {{.Ref}} on {
"{{range .Valid}}\n" +
"func TestTOMLTest_Valid_{{.Name}}(t *testing.T) {\n" +
" input := {{.Input|gostr}}\n" +
" jsonRef := {{.JsonRef|gostr}}\n" +
" jsonRef := {{.JSONRef|gostr}}\n" +
" testgenValid(t, input, jsonRef)\n" +
"}\n" +
"{{end}}\n"
func kebabToCamel(kebab string) string {
camel := ""
var buf strings.Builder
nextUpper := true
for _, c := range kebab {
if nextUpper {
camel += strings.ToUpper(string(c))
buf.WriteRune(unicode.ToUpper(c))
nextUpper = false
} else if c == '-' {
nextUpper = true
} else if c == '/' {
nextUpper = true
camel += "_"
} else {
camel += string(c)
switch c {
case '-':
nextUpper = true
case '/':
nextUpper = true
buf.WriteByte('_')
default:
buf.WriteRune(c)
}
}
}
return camel
return buf.String()
}
func templateGoStr(input string) string {
@@ -110,7 +113,7 @@ func main() {
log.Printf("> [%s] %s\n", "invalid", name)
tomlContent, err := os.ReadFile(f)
tomlContent, err := os.ReadFile(f) // #nosec G304
if err != nil {
fmt.Printf("failed to read test file: %s\n", err)
os.Exit(1)
@@ -131,14 +134,14 @@ func main() {
log.Printf("> [%s] %s\n", "valid", name)
tomlContent, err := os.ReadFile(f)
tomlContent, err := os.ReadFile(f) // #nosec G304
if err != nil {
fmt.Printf("failed reading test file: %s\n", err)
os.Exit(1)
}
filename = strings.TrimSuffix(f, ".toml")
jsonContent, err := os.ReadFile(filename + ".json")
jsonContent, err := os.ReadFile(filename + ".json") // #nosec G304
if err != nil {
fmt.Printf("failed reading validation json: %s\n", err)
os.Exit(1)
@@ -147,7 +150,7 @@ func main() {
collection.Valid = append(collection.Valid, valid{
Name: name,
Input: string(tomlContent),
JsonRef: string(jsonContent),
JSONRef: string(jsonContent),
})
collection.Count++
}
@@ -173,7 +176,7 @@ func main() {
return
}
err = os.WriteFile(*out, outputBytes, 0o644)
err = os.WriteFile(*out, outputBytes, 0o600)
if err != nil {
panic(err)
}