-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
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
[BUG]Wrong parsing of config, when using config.Scan #3439
Comments
I don't quite understand what the specific problem is |
@shenqidebaozi Added an example of yml and toml at: github.com\go-kratos\kratos\[email protected]\config\reader.go:
This is because the intermediate values are stored in a map. Therefore, they are not subject to the example with value
If the source is in a non-json format. If the configuration is but the content will be {
"ServiceName": "helloworld"
} But the So I think it should be more than just Of course, if the configuration with |
you need two step
import (
"github.com/BurntSushi/toml"
"github.com/go-kratos/kratos/v2/encoding"
)
// Name is the name registered for the xml codec.
const Name = "toml"
func init() {
encoding.RegisterCodec(codec{})
}
// codec is a Codec implementation with xml.
type codec struct{}
func (codec) Marshal(v interface{}) ([]byte, error) {
return toml.Marshal(v)
}
func (codec) Unmarshal(data []byte, v interface{}) error {
return toml.Unmarshal(data, v)
}
func (codec) Name() string {
return Name
}
|
@czyt 意思是,我实际需要一个自定义的resolver将输入的配置转换成对的map格式对吧? |
@czyt means, I actually need a custom resolver to convert the input configuration into a map format, right? |
yes,you can try |
What happened:
The default output of toml is configured in UpperCase, which is converted to
map=>json
during transmission.But proto's json supports the format of snake_case.
Eventually the
json=>Config
parsing fails.bootstrap.toml
proto
What you expected to happen:
Converts profiles properly
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Environment:
kratos -v
): kratos version v2.8.0go version
): go version go1.23.2 windows/amd64cat /etc/os-release
): WindowsThe text was updated successfully, but these errors were encountered: