Skip to content
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

cant not unmarshal name contain underline. #1612

Closed
3 tasks done
hhniao opened this issue Aug 24, 2023 · 2 comments
Closed
3 tasks done

cant not unmarshal name contain underline. #1612

hhniao opened this issue Aug 24, 2023 · 2 comments
Labels
resolution/invalid This doesn't seem right

Comments

@hhniao
Copy link

hhniao commented Aug 24, 2023

Preflight Checklist

  • I have searched the issue tracker for an issue that matches the one I want to file, without success.
  • I am not looking for support or already pursued the available support channels without success.
  • I have checked the troubleshooting guide for my problem, without success.

Viper Version

latest

Go Version

latest

Config Source

Files

Format

YAML

Repl.it link

No response

Code reproducing the issue

type disk struct {
	Abc           string `yaml:"abc" json:"abc"`
	AbcTest       string `yaml:"abc_test" json:"abc_test"`
	AbcString     string `yaml:"abc_string" json:"abc_string"`
	AbcInt        string `yaml:"abc_int" json:"abc_int"`
	AbcBool       string `yaml:"abc_bool" json:"abc_bool"`
	Cba           string `yaml:"cba" json:"cba"`
	TestUnderLine string `yaml:"test_under_line" json:"test_under_line"`
	TestCamel     string `yaml:"TestCamel" json:"TestCamel"`
	TestCamel1    string `yaml:"testCamel1" json:"testCamel1"`
}
var ddd disk
loadfile
...
...
viper.Unmarshal(&ddd) # cant unmarshal
sss := viper.AllSettings() # it is no problem, i can see abc,abctest

Abc = {string} "abc"
AbcTest = {string} ""
AbcString = {string} ""
AbcInt = {string} ""
AbcBool = {string} ""
Cba = {string} "cba"
TestUnderLine = {string} ""
TestCamel = {string} "TestCamel"
TestCamel1 = {string} "testCamel1"

Expected Behavior

as the viper.AllSettings() can be read all

Actual Behavior

disk.Abc not problem.
disk.AbcTest it is empty value, empty string, whaterve your type in struct

Steps To Reproduce

No response

Additional Information

No response

@hhniao hhniao added the kind/bug Something isn't working label Aug 24, 2023
@github-actions
Copy link

👋 Thanks for reporting!

A maintainer will take a look at your issue shortly. 👀

In the meantime: We are working on Viper v2 and we would love to hear your thoughts about what you like or don't like about Viper, so we can improve or fix those issues.

⏰ If you have a couple minutes, please take some time and share your thoughts: https://forms.gle/R6faU74qPRPAzchZ9

📣 If you've already given us your feedback, you can still help by spreading the news,
either by sharing the above link or telling people about this on Twitter:

https://twitter.com/sagikazarmark/status/1306904078967074816

Thank you! ❤️

@sagikazarmark
Copy link
Collaborator

@sagikazarmark sagikazarmark added resolution/invalid This doesn't seem right and removed kind/bug Something isn't working labels Sep 7, 2023
@sagikazarmark sagikazarmark closed this as not planned Won't fix, can't repro, duplicate, stale Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
resolution/invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

2 participants