diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c7d9293d..feb17b30 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,7 +14,8 @@ on: - go.sum jobs: - golangci: + # https://github.com/golangci/golangci-lint-action/issues/23 + lint: name: lint runs-on: ubuntu-latest steps: @@ -24,7 +25,24 @@ jobs: - name: Install Go uses: actions/setup-go@v3 with: - go-version: 1.21 + go-version-file: './go.mod' + + - name: golangci-lint + uses: golangci/golangci-lint-action@v3.3.0 + with: + version: v1.55.2 + + fmt: + name: fmt + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Install Go + uses: actions/setup-go@v3 + with: + go-version-file: './go.mod' - name: Restore Go modules cache uses: actions/cache@v3 @@ -49,9 +67,3 @@ jobs: assert-nothing-changed go fmt ./... assert-nothing-changed go mod tidy exit $STATUS - - - - name: golangci-lint - uses: golangci/golangci-lint-action@v3.3.0 - with: - version: v1.52.2 diff --git a/Makefile b/Makefile index eada2738..bd7214e9 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -GOLANGCI_VERSION=v1.52.2 +GOLANGCI_VERSION=v1.55.2 COVERAGE=coverage.out .PHONY: deps diff --git a/pkg/tidbcloud/pingchat/models/pingchat_chat_info.go b/pkg/tidbcloud/pingchat/models/pingchat_chat_info.go index 8083e7bc..f3b97ccc 100644 --- a/pkg/tidbcloud/pingchat/models/pingchat_chat_info.go +++ b/pkg/tidbcloud/pingchat/models/pingchat_chat_info.go @@ -12,6 +12,7 @@ import ( "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" "github.com/go-openapi/swag" + "github.com/go-openapi/validate" ) // PingchatChatInfo pingchat chat info @@ -19,7 +20,8 @@ import ( // swagger:model pingchat.ChatInfo type PingchatChatInfo struct { - // messages + // https://pkg.go.dev/gopkg.in/bluesuncorp/validator.v9#hdr-Dive + // Required: true Messages []*PingchatChatMessage `json:"messages"` } @@ -38,8 +40,9 @@ func (m *PingchatChatInfo) Validate(formats strfmt.Registry) error { } func (m *PingchatChatInfo) validateMessages(formats strfmt.Registry) error { - if swag.IsZero(m.Messages) { // not required - return nil + + if err := validate.Required("messages", "body", m.Messages); err != nil { + return err } for i := 0; i < len(m.Messages); i++ { diff --git a/pkg/tidbcloud/pingchat/models/pingchat_chat_message.go b/pkg/tidbcloud/pingchat/models/pingchat_chat_message.go index b8f95884..28acf2df 100644 --- a/pkg/tidbcloud/pingchat/models/pingchat_chat_message.go +++ b/pkg/tidbcloud/pingchat/models/pingchat_chat_message.go @@ -20,11 +20,11 @@ import ( // swagger:model pingchat.ChatMessage type PingchatChatMessage struct { - // content + // Dialogue content // Required: true Content *string `json:"content"` - // role + // User's input as "user", AI assistant's reply as "assistant" // Required: true // Enum: [user assistant] Role *string `json:"role"` diff --git a/pkg/tidbcloud/pingchat/models/pingchat_chat_response.go b/pkg/tidbcloud/pingchat/models/pingchat_chat_response.go index fb888358..7eac357e 100644 --- a/pkg/tidbcloud/pingchat/models/pingchat_chat_response.go +++ b/pkg/tidbcloud/pingchat/models/pingchat_chat_response.go @@ -22,7 +22,7 @@ type PingchatChatResponse struct { // content Content string `json:"content,omitempty"` - // links + // Reference Document Links Links []*PingchatLink `json:"links"` }