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

配置文件中的时间数据不能注入到Golang结构体中的time.Time类型字段 #363

Open
1 task done
ivfzhou opened this issue Jan 4, 2025 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@ivfzhou
Copy link

ivfzhou commented Jan 4, 2025

Version

1.67.0

Describe the bug

ini.Key.Time() 方法能将时间数据按 RFC3339 解析,但直接将整个配置数据注入 Golang 结构体,却不按此行为解析。

To reproduce

func ParseTime() {
	var cfg struct {
		Time time.Time `ini:"time"`
	}
	err := ini.MapTo(&cfg, []byte(`time=2025-01-04T16:25:00+08:00"`))
	if err != nil {
		panic(err)
	}
	fmt.Println(cfg.Time)
	fmt.Println(time.Parse(time.RFC3339, "2025-01-04T16:25:00+08:00"))
}

Expected behavior

能将时间数据按 RFC3339 格式注入结构体字段中。

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@ivfzhou ivfzhou added the bug Something isn't working label Jan 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant