Skip to content

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

Open
@ivfzhou

Description

@ivfzhou

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions