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

Cannot use v2.2.12 in GoFrame framework #194

Closed
shuqingzai opened this issue Nov 3, 2023 · 2 comments
Closed

Cannot use v2.2.12 in GoFrame framework #194

shuqingzai opened this issue Nov 3, 2023 · 2 comments
Labels
Bug Report a reproducible bug or regression

Comments

@shuqingzai
Copy link

shuqingzai commented Nov 3, 2023

Hello,

I encountered an issue with the following code:

package main

import (
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/net/ghttp"
	"github.com/golang-module/carbon/v2"
)

type DemoReq struct {
	Now *carbon.DateTime `json:"now" v:"required|datetime"`
}

type DemoRes struct {
	Code  int    `json:"code"`
	Error string `json:"error"`
	Data  any    `json:"data"`
}

func main() {
	s := g.Server()
	s.BindHandler("/demo", func(r *ghttp.Request) {
		var req *DemoReq
		if err := r.Parse(&req); err != nil {
			r.Response.WriteJsonExit(DemoRes{
				Code:  1,
				Error: err.Error(),
			})
		}
		// ...
		r.Response.WriteJsonExit(DemoRes{
			Data: req,
		})
	})
	s.SetPort(8899)
	s.Run()
}

POST 访问: http://127.0.0.1:8899/demo
参数:

{
    "now": "2023-11-03 00:00:00"
}

使用 v2.2.12 以下版本没有问题,v2.2.12 报错

exception recovered: time: missing Location in call to Time.In

应该是 https://github.com/golang-module/carbon/blob/d16c40b9c9221f526342ee049dd74b9dd3d0906c/comparer.go#L10 这里的问题

golang version:

# -> % go version
go version go1.21.3 darwin/amd64

carbon version:

v2.2.12

time zone: such as Japan

I expected to get:

2020-08-08 13:14:15

But I actually get:

2020-08-07 13:14:15

Thanks!

@shuqingzai shuqingzai added the Bug Report a reproducible bug or regression label Nov 3, 2023
@Issues-translate-bot Issues-translate-bot changed the title 无法在 GoFrame 框架中使用 v2.2.12 Cannot use v2.2.12 in GoFrame framework Nov 3, 2023
@donseba
Copy link

donseba commented Nov 3, 2023

Can confirm this issue. version v2.2.11 seems to work ok.

@gouguoyin
Copy link
Collaborator

Released and fixed in v2.2.13

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Report a reproducible bug or regression
Projects
None yet
Development

No branches or pull requests

3 participants