From 8729cdc4c9dc77ce13393a740611eb4140f92613 Mon Sep 17 00:00:00 2001 From: "CTFang@WireLab" Date: Tue, 23 Apr 2024 06:58:39 +0000 Subject: [PATCH 1/2] chore: bump go version and CI adjustment --- .github/workflows/commit-msg-check.yml | 15 +++++++++++++++ .github/workflows/go.yml | 6 +++--- .github/workflows/golangci-lint.yml | 10 +++++----- go.mod | 2 +- go.sum | 7 +++++++ 5 files changed, 31 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/commit-msg-check.yml diff --git a/.github/workflows/commit-msg-check.yml b/.github/workflows/commit-msg-check.yml new file mode 100644 index 00000000..fd6835de --- /dev/null +++ b/.github/workflows/commit-msg-check.yml @@ -0,0 +1,15 @@ +name: 'Commit Message Check' + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + name: Conventional Commits + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: webiny/action-conventional-commits@v1.3.0 \ No newline at end of file diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 90d4ab61..b190c0fb 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -11,12 +11,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: [ '1.18', '1.21' ] + go: [ '1.21' ] steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 1169dd43..4fdc07a5 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -14,18 +14,18 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: [ '1.18' ] + go: [ '1.21' ] steps: - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v5 with: go-version: ${{ matrix.go }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Run golangci-lint - uses: golangci/golangci-lint-action@v3 + uses: golangci/golangci-lint-action@v4 with: # Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version - version: v1.45.2 + version: v1.57.2 # Optional: working directory, useful for monorepos # working-directory: somedir diff --git a/go.mod b/go.mod index 75a3ad09..60355fe5 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/free5gc/webconsole -go 1.17 +go 1.21 require ( github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 diff --git a/go.sum b/go.sum index bb65bb1f..ea7befca 100644 --- a/go.sum +++ b/go.sum @@ -37,6 +37,7 @@ cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2Aawl cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/longrunning v0.4.1 h1:v+yFJOfKC3yZdY6ZUI933pIYdhyhV8S3NpWrXWmg7jM= +cloud.google.com/go/longrunning v0.4.1/go.mod h1:4iWDqhBZ70CvZ6BfETbvam3T8FMvLK+eFj0E6AaRQTo= cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= @@ -178,6 +179,7 @@ github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2 github.com/go-kit/kit v0.11.0/go.mod h1:73/6Ixaufkvb5Osvkls8C79vuQ49Ba1rUEUYNSf+FUw= github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= +github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= @@ -187,6 +189,7 @@ github.com/go-mail/mail v2.3.1+incompatible h1:UzNOn0k5lpfVtO31cK3hn6I4VEVGhe3lX github.com/go-mail/mail v2.3.1+incompatible/go.mod h1:VPWjmmNyRsWXQZHVHT3g0YbIINUkSmuKOiLIDkWbL6M= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= @@ -260,6 +263,7 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -470,6 +474,7 @@ github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/secsy/goftp v0.0.0-20200609142545-aa2de14babf4 h1:PT+ElG/UUFMfqy5HrxJxNzj3QBOf7dZwupeVC+mG1Lo= +github.com/secsy/goftp v0.0.0-20200609142545-aa2de14babf4/go.mod h1:MnkX001NG75g3p8bhFycnyIjeQoOjGL6CEIsdE/nKSY= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -771,6 +776,7 @@ golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9sn golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.18.0 h1:FcHjZXDMxI8mM3nwhX9HlKop4C0YQvCVCdwYl2wOtE8= +golang.org/x/term v0.18.0/go.mod h1:ILwASektA3OnRv7amZ1xhE/KTR+u50pbXfZ03+6Nx58= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -992,6 +998,7 @@ gopkg.in/gcfg.v1 v1.2.3/go.mod h1:yesOnuUOFQAhST5vPY4nbZsb/huCgGGXlipJsBn0b3o= gopkg.in/h2non/gock.v1 v1.1.2 h1:jBbHXgGBK/AoPVfJh5x4r/WxIrElvbLel8TCZkkZJoY= gopkg.in/h2non/gock.v1 v1.1.2/go.mod h1:n7UGz/ckNChHiK05rDoiC4MYSunEC/lyaUm2WWaDva0= gopkg.in/mail.v2 v2.3.1 h1:WYFn/oANrAGP2C0dcV6/pbkPzv8yGzqTjPmTeO7qoXk= +gopkg.in/mail.v2 v2.3.1/go.mod h1:htwXN1Qh09vZJ1NVKxQqHPBaCBbzKhp5GzuJEA4VJWw= gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 01623fb2a926218e5b08e24d7a2b6eeb46c67b60 Mon Sep 17 00:00:00 2001 From: "CTFang@WireLab" Date: Tue, 23 Apr 2024 07:03:31 +0000 Subject: [PATCH 2/2] fix: fix linter error --- backend/billing/client.go | 4 ++-- backend/billing/server.go | 3 +-- backend/factory/factory.go | 4 ++-- backend/webui_service/webui_init.go | 6 +++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/backend/billing/client.go b/backend/billing/client.go index 09c829aa..e042e215 100644 --- a/backend/billing/client.go +++ b/backend/billing/client.go @@ -1,7 +1,7 @@ package billing import ( - "io/ioutil" + "io" "strconv" "time" @@ -52,7 +52,7 @@ func PullCDRFile(c *ftp.ServerConn, fileName string) ([]byte, error) { return nil, err } - cdr, err1 := ioutil.ReadAll(r) + cdr, err1 := io.ReadAll(r) return cdr, err1 } diff --git a/backend/billing/server.go b/backend/billing/server.go index a7d9a82a..f2ef0460 100644 --- a/backend/billing/server.go +++ b/backend/billing/server.go @@ -3,7 +3,6 @@ package billing import ( "encoding/json" - "io/ioutil" "os" "strconv" "sync" @@ -79,7 +78,7 @@ func OpenServer(wg *sync.WaitGroup) *BillingDomain { return nil } - if err := ioutil.WriteFile(confFile, file, 0o600); err != nil { //nolint: gomnd + if err := os.WriteFile(confFile, file, 0o600); err != nil { //nolint: gomnd logger.BillingLog.Errorf("Couldn't create conf file %v", confFile) return nil } diff --git a/backend/factory/factory.go b/backend/factory/factory.go index 57726b37..fa4e23ea 100644 --- a/backend/factory/factory.go +++ b/backend/factory/factory.go @@ -6,7 +6,7 @@ package factory import ( "fmt" - "io/ioutil" + "os" "github.com/asaskevich/govalidator" "gopkg.in/yaml.v2" @@ -22,7 +22,7 @@ func InitConfigFactory(f string, cfg *Config) error { // Use default config path f = WebuiDefaultConfigPath } - if content, err := ioutil.ReadFile(f); err != nil { + if content, err := os.ReadFile(f); err != nil { return fmt.Errorf("[Factory] %+v", err) } else { logger.CfgLog.Infof("Read config from [%s]", f) diff --git a/backend/webui_service/webui_init.go b/backend/webui_service/webui_init.go index f08d6851..2b9c9014 100644 --- a/backend/webui_service/webui_init.go +++ b/backend/webui_service/webui_init.go @@ -1,7 +1,7 @@ package webui_service import ( - "io/ioutil" + "io" "os" "os/signal" "runtime/debug" @@ -39,14 +39,14 @@ func (a *WebuiApp) SetLogEnable(enable bool) { logger.MainLog.Infof("Log enable is set to [%v]", enable) if enable && logger.Log.Out == os.Stderr { return - } else if !enable && logger.Log.Out == ioutil.Discard { + } else if !enable && logger.Log.Out == io.Discard { return } a.cfg.SetLogEnable(enable) if enable { logger.Log.SetOutput(os.Stderr) } else { - logger.Log.SetOutput(ioutil.Discard) + logger.Log.SetOutput(io.Discard) } }