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

How to loadTag a slice list? #233

Open
liaohongxing opened this issue Apr 10, 2024 · 1 comment
Open

How to loadTag a slice list? #233

liaohongxing opened this issue Apr 10, 2024 · 1 comment
Labels
Question Indicates that an issue, pull request, or discussion needs more information

Comments

@liaohongxing
Copy link

type Person struct {
  Name string `json:"name"`
  Age  int    `json:"age"`
  
  Field1 carbon.Carbon `json:"field1" carbon:"type:date" tz:"PRC"`
  Field2 carbon.Carbon `json:"field2" carbon:"type:time" tz:"PRC"`
  Field3 carbon.Carbon `json:"field3" carbon:"type:dateTime" tz:"PRC"`
}

list := make([]models.Person, 0)
if err := carbon.LoadTag(&list); err != nil {
	return nil, nil, err
}

将切片传入报错 reflect: call of reflect.Value.NumField on slice Value

@liaohongxing liaohongxing added the Question Indicates that an issue, pull request, or discussion needs more information label Apr 10, 2024
@Issues-translate-bot Issues-translate-bot changed the title 切片列表怎么loadTag How to loadTag a slice list? Apr 10, 2024
@gouguoyin
Copy link
Member

v2.3.12 has been released, temporarily use the following instead

type Person struct {
  Name string `json:"name"`
  Age  int    `json:"age"`
  
  Field1 carbon.Date `json:"field1"`
  Field2 carbon.Time `json:"field2"`
  Field3 carbon.DateTime `json:"field3"`
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Indicates that an issue, pull request, or discussion needs more information
Development

No branches or pull requests

2 participants