cmd: remove redundant nil check (#7083)

From the Go specification:

> "3. If the map is nil, the number of iterations is 0."
https://go.dev/ref/spec#For_range

Therefore, an additional nil check for before the loop is unnecessary.
This commit is contained in:
Eng Zer Jun 2023-09-15 03:46:20 +08:00 committed by GitHub
parent b17123c575
commit fc5cb56837
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 12 deletions

View File

@ -442,12 +442,10 @@ func ValidateJSONConfig(cv *ConfigValidator, in io.Reader) error {
// Initialize the validator and load any custom tags.
validate := validator.New()
if cv.Validators != nil {
for tag, v := range cv.Validators {
err := validate.RegisterValidation(tag, v)
if err != nil {
return err
}
for tag, v := range cv.Validators {
err := validate.RegisterValidation(tag, v)
if err != nil {
return err
}
}
@ -486,12 +484,10 @@ func ValidateYAMLConfig(cv *ConfigValidator, in io.Reader) error {
// Initialize the validator and load any custom tags.
validate := validator.New()
if cv.Validators != nil {
for tag, v := range cv.Validators {
err := validate.RegisterValidation(tag, v)
if err != nil {
return err
}
for tag, v := range cv.Validators {
err := validate.RegisterValidation(tag, v)
if err != nil {
return err
}
}