Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

gvalid slice enums verification failed : no pkg path found for type "[]t.Status" #3548

Closed
xyqweb opened this issue Apr 26, 2024 · 0 comments · Fixed by #3566
Closed

gvalid slice enums verification failed : no pkg path found for type "[]t.Status" #3548

xyqweb opened this issue Apr 26, 2024 · 0 comments · Fixed by #3566
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.

Comments

@xyqweb
Copy link
Contributor

xyqweb commented Apr 26, 2024

Go version

go version go1.20.14 darwin/arm64

GoFrame version

2.7.0

Can this bug be reproduced with the latest release?

Option Yes

What did you do?

import (
	"context"
	"github.com/gogf/gf/v2/frame/g"
	"github.com/gogf/gf/v2/test/gtest"
	"github.com/gogf/gf/v2/util/gtag"
	"testing"
)

func init() {
	gtag.SetGlobalEnums(`{"shop/testing/t.Status":["Running","Offline"]}`)
}

func TestEnums(t *testing.T) {
	type Status string
	const (
		StatusRunning Status = "Running"
		StatusOffline Status = "Offline"
	)
	type BizReq struct {
		Id     int      `v:"required"`
		Name   string   `v:"required"`
		Status []Status `v:"foreach|enums"`
	}
	var (
		ctx = context.Background()
		req = BizReq{
			Id:     1,
			Name:   "john",
			Status: []Status{"Running", "Offline"},
		}
	)
	gtest.C(t, func(t *gtest.T) {
		err := g.Validator().Data(req).Run(ctx)
		t.AssertNil(err)
	})
}

What did you see happen?

no pkg path found for type "[]t.Status"

  1. shop/testing/t.TestEnums.func1
    /Users/xxxx/workspace/go/src/julunet.com/shop/testing/t/f_test.go:54
  2. shop/testing/t.TestEnums
    /Users/xxxx/workspace/go/src/julunet.com/shop/testing/t/f_test.go:52
    --- FAIL: TestEnums (0.00s)
    FAIL
    exit status 1
    FAIL shop/testing/t 0.355s

What did you expect to see?

verified passed

@xyqweb xyqweb added the bug It is confirmed a bug, but don't worry, we'll handle it. label Apr 26, 2024
@gqcn gqcn closed this as completed in #3566 May 7, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug It is confirmed a bug, but don't worry, we'll handle it.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant