Skip to content

Commit cb982b9

Browse files
committed
go: modernize
1 parent 02c48f1 commit cb982b9

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎internal/config/accounts.go‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ func ValidateConfig(config *Config, inputMap map[string]any) error {
161161
for key := range inputMap {
162162
logging.DebugBool(verboseMode, "ValidateConfig - checking key '%s'", key)
163163
found := false
164-
for i := 0; i < configType.NumField(); i++ {
165-
field := configType.Field(i)
164+
for field := range configType.Fields() {
165+
field := field
166166
yamlTag := field.Tag.Get("yaml")
167167
logging.DebugBool(verboseMode, "ValidateConfig - comparing key '%s' with field '%s' (YAML tag: '%s')", key, field.Name, yamlTag)
168168
// Handle inline YAML tags
@@ -184,8 +184,8 @@ func ValidateConfig(config *Config, inputMap map[string]any) error {
184184
for key := range userMap {
185185
logging.DebugBool(verboseMode, "ValidateConfig - checking key '%s' in 'user' section", key)
186186
found := false
187-
for i := 0; i < userType.NumField(); i++ {
188-
field := userType.Field(i)
187+
for field := range userType.Fields() {
188+
field := field
189189
yamlTag := field.Tag.Get("yaml")
190190
logging.DebugBool(verboseMode, "ValidateConfig - comparing key '%s' with user field '%s' (YAML tag: '%s')", key, field.Name, yamlTag)
191191
if yamlTag == key || (strings.Contains(yamlTag, ",") && strings.Split(yamlTag, ",")[0] == key) {
@@ -220,8 +220,8 @@ func ValidateConfig(config *Config, inputMap map[string]any) error {
220220
for key := range cfMap {
221221
logging.DebugBool(verboseMode, "ValidateConfig - checking key '%s' in 'cloudflare' section", key)
222222
found := false
223-
for i := 0; i < cfType.NumField(); i++ {
224-
field := cfType.Field(i)
223+
for field := range cfType.Fields() {
224+
field := field
225225
yamlTag := field.Tag.Get("yaml")
226226
logging.DebugBool(verboseMode, "ValidateConfig - comparing key '%s' with cloudflare field '%s' (YAML tag: '%s')", key, field.Name, yamlTag)
227227
if yamlTag == key || (strings.Contains(yamlTag, ",") && strings.Split(yamlTag, ",")[0] == key) {
@@ -242,8 +242,8 @@ func ValidateConfig(config *Config, inputMap map[string]any) error {
242242
for key := range dhMap {
243243
logging.DebugBool(verboseMode, "ValidateConfig - checking key '%s' in 'dockerhub' section", key)
244244
found := false
245-
for i := 0; i < dhType.NumField(); i++ {
246-
field := dhType.Field(i)
245+
for field := range dhType.Fields() {
246+
field := field
247247
yamlTag := field.Tag.Get("yaml")
248248
logging.DebugBool(verboseMode, "ValidateConfig - comparing key '%s' with dockerhub field '%s' (YAML tag: '%s')", key, field.Name, yamlTag)
249249
if yamlTag == key || (strings.Contains(yamlTag, ",") && strings.Split(yamlTag, ",")[0] == key) {

‎internal/config/generic.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,8 @@ func checkExtraFieldsInternal(inputMap map[string]any, config any, context strin
110110
for key := range inputMap {
111111
logging.DebugBool(verboseMode, "Checking for extra field: %s", key)
112112
found := false
113-
for i := 0; i < configType.NumField(); i++ {
114-
field := configType.Field(i)
113+
for field := range configType.Fields() {
114+
field := field
115115
yamlTag := field.Tag.Get("yaml")
116116
yamlKey := strings.Split(yamlTag, ",")[0]
117117
if yamlKey == key {

0 commit comments

Comments
 (0)