We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No description provided.
The text was updated successfully, but these errors were encountered:
Hi @paracha3. Could you please give more context about how you want to use such a feature?
Sorry, something went wrong.
type Config struct { Status enum.Status `yaml:"status" decoder:"Dec"` } func(*Config) Dec() {}
🤔
@vlaabra I need to think about it. Probably some decoder like json.Unmarshaler would be the better approach, but I still don't know about the usage.
json.Unmarshaler
Are there any examples of popular decoders, which could be used like this?
import "encoding/hex" import "go.mongodb.org/mongo-driver/bson/primitive" type Config struct { Decimal primitive.Decimal128 `yaml:"decimal" decoder:"StringToDecimal"` // 12345 Hex []byte `yaml:"hex" decoder:"StringToHex"` // 1234FF } func (c *Config) StringToDecimal(s interface{}) (err error) { c.Decimal, err = primitive.ParseDecimal128(fmt.Sprint(s)) return } func (c *Config) StringToHex(s interface{}) (err error) { c.Hex, err = hex.DecodeString(fmt.Sprint(s)) return }
i need`t, just suggestion
unlike yaml, json calls UnmarshalText and UnmarshalJSON methods if they implementing its interface
Okay, looks good, we'll add this
ilyakaznacheev
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: