From 4bea36255f9a98a5fb2863c9e9bc84f432bbf602 Mon Sep 17 00:00:00 2001 From: Chuanjian Wang Date: Thu, 7 Nov 2024 15:18:52 +0800 Subject: [PATCH 1/8] fix --- .github/workflows/go-code-quality.yml | 2 +- .gitignore | 1 + api/users.go | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/go-code-quality.yml b/.github/workflows/go-code-quality.yml index c987af4..20b9658 100644 --- a/.github/workflows/go-code-quality.yml +++ b/.github/workflows/go-code-quality.yml @@ -17,7 +17,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v2 with: - go-version: '1.16' # 指定Go的版本 + go-version: '1.21' # 指定Go的版本 - name: Lint with golangci-lint uses: golangci/golangci-lint-action@v2 diff --git a/.gitignore b/.gitignore index ced6160..2ff78bf 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,4 @@ _cgo_export.* .vscode/* .DS_Store Thumbs.db +.history diff --git a/api/users.go b/api/users.go index 2a3f174..db6d991 100644 --- a/api/users.go +++ b/api/users.go @@ -5,7 +5,6 @@ import ( "github.com/gin-gonic/gin" ) -// usersRouters ... func usersRouters(gr *gin.RouterGroup) { gr.GET("", users.ListUsers) gr.POST("", users.CreateUser) From e3a47e66e20ae95982f95763aedeeb6ad3947163 Mon Sep 17 00:00:00 2001 From: Chuanjian Wang Date: Thu, 7 Nov 2024 15:19:51 +0800 Subject: [PATCH 2/8] fix --- .github/workflows/go-code-quality.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/go-code-quality.yml b/.github/workflows/go-code-quality.yml index 20b9658..08e8d9b 100644 --- a/.github/workflows/go-code-quality.yml +++ b/.github/workflows/go-code-quality.yml @@ -4,6 +4,7 @@ on: pull_request: branches: - main # 或者你的默认分支 + - master jobs: build: From df74439a73a89b7a757116773e855827170f1e6f Mon Sep 17 00:00:00 2001 From: Chuanjian Wang Date: Mon, 11 Nov 2024 10:28:49 +0800 Subject: [PATCH 3/8] fix --- .github/workflows/go-code-quality.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/go-code-quality.yml b/.github/workflows/go-code-quality.yml index 08e8d9b..ce0adff 100644 --- a/.github/workflows/go-code-quality.yml +++ b/.github/workflows/go-code-quality.yml @@ -21,8 +21,10 @@ jobs: go-version: '1.21' # 指定Go的版本 - name: Lint with golangci-lint - uses: golangci/golangci-lint-action@v2 + uses: golangci/golangci-lint-action@v6 with: version: latest + github-token: ${{ secrets.GITHUB_TOKEN }} + only-new-issues: true args: --issues-exit-code=0 --out-format=github-actions From 32fa41d993a7e9dd84d92dee8e07b990b0db2275 Mon Sep 17 00:00:00 2001 From: Chuanjian Wang Date: Mon, 11 Nov 2024 11:07:50 +0800 Subject: [PATCH 4/8] fix --- api/api.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/api/api.go b/api/api.go index a2934aa..7da5b08 100644 --- a/api/api.go +++ b/api/api.go @@ -18,6 +18,8 @@ const ( PrefixRelease = "release" // PrefixWebhook webhook PrefixWebhook = "webhook" + + PrefixAPITest = "test" ) // Serve start http server. @@ -61,3 +63,7 @@ func getVersion(ctx *gin.Context) { func decodeBody(ctx *gin.Context, v interface{}) error { return json.NewDecoder(ctx.Request.Body).Decode(v) } + +func EncodeJSON(ctx *gin.Context, v interface{}) error { + return json.NewEncoder(ctx.Writer).Encode(v) +} From 5e7f124052dfb9ecda90abf6027c1a1407fbd2f5 Mon Sep 17 00:00:00 2001 From: Chuanjian Wang Date: Mon, 11 Nov 2024 11:10:29 +0800 Subject: [PATCH 5/8] fix --- api/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/api.go b/api/api.go index 7da5b08..724111f 100644 --- a/api/api.go +++ b/api/api.go @@ -19,7 +19,7 @@ const ( // PrefixWebhook webhook PrefixWebhook = "webhook" - PrefixAPITest = "test" + Prefix_Api_Test = "test" ) // Serve start http server. From 8b84ea3b80418af525e8a8241a60ef309c6e184a Mon Sep 17 00:00:00 2001 From: Chuanjian Wang Date: Mon, 11 Nov 2024 11:55:37 +0800 Subject: [PATCH 6/8] fix' --- api/api.go | 3 +-- api/view/view.go | 51 ------------------------------------------------ 2 files changed, 1 insertion(+), 53 deletions(-) delete mode 100644 api/view/view.go diff --git a/api/api.go b/api/api.go index 724111f..6b7af68 100644 --- a/api/api.go +++ b/api/api.go @@ -5,7 +5,6 @@ import ( "net" "net/http" - "github.com/ckeyer/diego/api/view" "github.com/ckeyer/diego/pkgs/apis/ginmd" "github.com/ckeyer/diego/version" "github.com/gin-gonic/gin" @@ -31,7 +30,7 @@ func Serve(addr string) error { gs := gin.New() gs.Use(ginmd.MDCors()) - gs.NoRoute(view.UI()) + // gs.NoRoute(view.UI()) gs.Use(ginmd.MDRecovery(), ginmd.MDLogger()) apiRoute(gs.Group(PrefixAPI)) diff --git a/api/view/view.go b/api/view/view.go deleted file mode 100644 index 4671fc8..0000000 --- a/api/view/view.go +++ /dev/null @@ -1,51 +0,0 @@ -package view - -import ( - "net/http" - "strings" - - "github.com/gin-gonic/gin" - "github.com/sirupsen/logrus" -) - -var ( - Index, _ = Asset("index.html") -) - -func UI() gin.HandlerFunc { - return func(ctx *gin.Context) { - path := strings.TrimPrefix(ctx.Request.URL.Path, "/") - if path == "" { - path = "index.html" - } - - var ( - code = http.StatusOK - contentType = "text/html" - ) - // ctx.Writer.Header().Add("Content-Encoding", "gzip") - - switch { - case strings.HasSuffix(path, ".html"): - contentType = "text/html" - case strings.HasSuffix(path, ".js"): - contentType = "application/x-javascript" - case strings.HasSuffix(path, ".css"): - contentType = "text/css" - case strings.HasSuffix(path, ".svg"): - contentType = "text/xml" - case strings.HasSuffix(path, ".jpg"), strings.HasSuffix(path, ".jepg"): - contentType = "image/jpeg" - } - - body, err := Asset(path) - if err != nil { - logrus.Debugf("get path %s failed, use index.", path) - body = Index - } else { - logrus.Debugf("get path %s and return.", path) - } - - ctx.Data(code, contentType, body) - } -} From c438415981f57f552556efc76a71b1368e94de23 Mon Sep 17 00:00:00 2001 From: Chuanjian Wang Date: Mon, 11 Nov 2024 12:06:17 +0800 Subject: [PATCH 7/8] fix' --- .github/workflows/go-code-quality.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/go-code-quality.yml b/.github/workflows/go-code-quality.yml index ce0adff..8bfbc8b 100644 --- a/.github/workflows/go-code-quality.yml +++ b/.github/workflows/go-code-quality.yml @@ -24,7 +24,7 @@ jobs: uses: golangci/golangci-lint-action@v6 with: version: latest - github-token: ${{ secrets.GITHUB_TOKEN }} - only-new-issues: true + # github-token: ${{ secrets.GITHUB_TOKEN }} + # only-new-issues: true args: --issues-exit-code=0 --out-format=github-actions - + From 8286c715cd8ef24a0c9393c511a4eb7fdedcf59c Mon Sep 17 00:00:00 2001 From: Chuanjian Wang Date: Mon, 11 Nov 2024 12:07:36 +0800 Subject: [PATCH 8/8] fix --- .github/workflows/go-code-quality.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go-code-quality.yml b/.github/workflows/go-code-quality.yml index 8bfbc8b..9269ab3 100644 --- a/.github/workflows/go-code-quality.yml +++ b/.github/workflows/go-code-quality.yml @@ -24,7 +24,7 @@ jobs: uses: golangci/golangci-lint-action@v6 with: version: latest - # github-token: ${{ secrets.GITHUB_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} # only-new-issues: true args: --issues-exit-code=0 --out-format=github-actions