A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/go-playground/validator/issues/134 below:

validate.Struct() always return error · Issue #134 · go-playground/validator · GitHub

hi, i am new in golang, maybe that problem about me.

when i use validator.Struct() in a function that return named error, the err var always not nil

func ValidateStruct(v interface{}) (err error) {
    err = validate.Struct(v)
    return
}

but when i use it like this, it works

func ValidateStruct(v interface{}) (err error) {
    errs := validate.Struct(v)
    if errs != nil {
        err = errs
        return
    }
    return nil
}

so what the problem ?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4