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

conf.FillDefault() Merge existing values #3741

Closed
yangjinheng opened this issue Nov 24, 2023 · 2 comments
Closed

conf.FillDefault() Merge existing values #3741

yangjinheng opened this issue Nov 24, 2023 · 2 comments
Labels
area/config Categorizes issue or PR as related to configuration .

Comments

@yangjinheng
Copy link
Contributor

	c := rest.RestConf{
		ServiceConf: service.ServiceConf{
			Name: "foo",
			Log: logx.LogConf{
				Encoding: "plain",
			},
		},
		Host: "127.0.0.1",
		Port: 443,
	}

	err := conf.FillDefault(&c)
	fmt.Println(err)
	fmt.Println(c.Name)
	fmt.Println(c.Host)
	fmt.Println(c.Port)
	fmt.Println(c.Mode)
	fmt.Println(c.Log.Encoding)
	fmt.Println(c.Log.Mode)

output

set the default value, "Name" must be zero
foo
127.0.0.1
443

plain

Merge existing ones instead of throwing an exception

”set the default value, "Name" must be zero“

@kevwan kevwan added the area/config Categorizes issue or PR as related to configuration . label Nov 24, 2023
@kevwan
Copy link
Contributor

kevwan commented Nov 24, 2023

FillDefault first, then set the specific values.

@yangjinheng
Copy link
Contributor Author

ok!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config Categorizes issue or PR as related to configuration .
Projects
None yet
Development

No branches or pull requests

2 participants