You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. What version of Go and system type/arch are you using?
go version go1.21.3 darwin/arm64
2. What version of GoFrame are you using?
2.6.0
3. Can this issue be re-produced with the latest release?
yes
4. What did you do?
func main() {
cfg := &Config{}
gutil.FillStructWithDefault(cfg)
fmt.Println(fmt.Sprintf("%+v", cfg))
}
// Config configuration for whole application
type Config struct {
Name string `json:"name" d:"zhangsan"`
Enable1 bool `json:"enable1" d:"true"`
Enable2 bool `json:"enable2"`
Service Service `json:"service"`
}
// Service configuration for service
type Service struct {
Env string `json:"env"`
AppID string `json:"appID" d:"testApp"`
IsDebug bool `json:"isDebug" d:"true"`
EnableCache bool `json:"enable_cache"`
}
5. What did you expect to see?
When struct Config have a nested struct Service, it can set default value for both Config and Service. &{Name:zhangsan Enable1:true Enable2:false Service:{Env: AppID:testApp IsDebug:true EnableCache:false}}
6. What did you see instead?
It only set the default value for outer Struct Config, ignore the default tag for inner struct Service. &{Name:zhangsan Enable1:true Enable2:false Service:{Env: AppID: IsDebug:false EnableCache:false}}
The text was updated successfully, but these errors were encountered:
Hello @zhangyuyu. We like your proposal/feedback and would appreciate a contribution via a Pull Request by you or another community member. We thank you in advance for your contribution and are looking forward to reviewing it!
你好 @zhangyuyu。我们喜欢您的提案/反馈,并希望您或其他社区成员通过拉取请求做出贡献。我们提前感谢您的贡献,并期待对其进行审查。
1. What version of
Go
and system type/arch are you using?go version go1.21.3 darwin/arm64
2. What version of
GoFrame
are you using?2.6.0
3. Can this issue be re-produced with the latest release?
yes
4. What did you do?
5. What did you expect to see?
When struct
Config
have a nested structService
, it can set default value for bothConfig
andService
.&{Name:zhangsan Enable1:true Enable2:false Service:{Env: AppID:testApp IsDebug:true EnableCache:false}}
6. What did you see instead?
It only set the default value for outer Struct
Config
, ignore the default tag for inner structService
.&{Name:zhangsan Enable1:true Enable2:false Service:{Env: AppID: IsDebug:false EnableCache:false}}
The text was updated successfully, but these errors were encountered: