feat: add import info from alr-repo.toml
All checks were successful
Pre-commit / pre-commit (pull_request) Successful in 5m5s
Update alr-git / changelog (push) Successful in 24s

This commit is contained in:
2025-07-07 17:45:20 +03:00
parent 1cc408ad7d
commit f42be105ad
19 changed files with 403 additions and 82 deletions

View File

@ -27,6 +27,7 @@ import (
"os"
"strings"
"text/template"
"unicode"
"golang.org/x/text/cases"
"golang.org/x/text/language"
@ -252,6 +253,8 @@ func argsGen(buf *bytes.Buffer, methods []MethodInfo) {
return strings.ToLower(s[:1]) + s[1:]
},
"zeroValue": func(typeName string) string {
typeName = strings.TrimSpace(typeName)
switch typeName {
case "string":
return "\"\""
@ -263,9 +266,32 @@ func argsGen(buf *bytes.Buffer, methods []MethodInfo) {
return "0.0"
case "bool":
return "false"
default:
}
if strings.HasPrefix(typeName, "*") {
return "nil"
}
if strings.HasPrefix(typeName, "[]") ||
strings.HasPrefix(typeName, "map[") ||
strings.HasPrefix(typeName, "chan ") {
return "nil"
}
if typeName == "interface{}" {
return "nil"
}
// If external type: pkg.Type
if strings.Contains(typeName, ".") {
return typeName + "{}"
}
// If starts with uppercase — likely struct
if len(typeName) > 0 && unicode.IsUpper(rune(typeName[0])) {
return typeName + "{}"
}
return "nil"
},
}