form
form copied to clipboard
Fails to decode struct if field is missing
The library fails to decode a struct if field is missing.
E.g. I do have a struct
type TokenExchange struct {
Type string `form:"grant_type"`
Code string `form:"code"`
}
The input string to parse
grant_type=authorization_code&code=xxx&client_id=xxx
The library fails to decode string with an error
client_id doesn't exist in main.TokenExchange
I would expect that library skips client_id.
If you can set ignoreUnknownKeys to true and you won't have this problem anymore. https://github.com/ajg/form/blob/523a5da1a92f01b01f840b61689c0340a0243532/decode.go#L59