Skip to content

Commit

Permalink
Merge pull request #101 from ming-hsien/refator/sbi-logic
Browse files Browse the repository at this point in the history
chore: bump go to 1.21
  • Loading branch information
ianchen0119 authored Apr 13, 2024
2 parents ed222d6 + 3231ad6 commit 5575470
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 77 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: [ '1.18', '1.21' ]
go: [ '1.21' ]
name: Go ${{ matrix.go }} sample
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 }}

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func main() {
Usage: "Output NF log to `FILE`",
},
}
rand.Seed(time.Now().UnixNano())
rand.New(rand.NewSource(time.Now().UnixNano()))

if err := app.Run(os.Args); err != nil {
logger.MainLog.Errorf("SMF Run error: %v\n", err)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/free5gc/smf

go 1.17
go 1.21

require (
github.com/antihax/optional v1.0.0
Expand Down
57 changes: 0 additions & 57 deletions go.sum

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions internal/context/ngap_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func HandlePDUSessionResourceSetupResponseTransfer(b []byte, ctx *SMContext) (er
resourceSetupResponseTransfer := ngapType.PDUSessionResourceSetupResponseTransfer{}

err = aper.UnmarshalWithParams(b, &resourceSetupResponseTransfer, "valueExt")

if err != nil {
return err
}
Expand Down Expand Up @@ -109,7 +108,6 @@ func HandlePDUSessionResourceSetupUnsuccessfulTransfer(b []byte, ctx *SMContext)
resourceSetupUnsuccessfulTransfer := ngapType.PDUSessionResourceSetupUnsuccessfulTransfer{}

err = aper.UnmarshalWithParams(b, &resourceSetupUnsuccessfulTransfer, "valueExt")

if err != nil {
return err
}
Expand Down Expand Up @@ -196,7 +194,6 @@ func HandlePathSwitchRequestSetupFailedTransfer(b []byte, ctx *SMContext) (err e
pathSwitchRequestSetupFailedTransfer := ngapType.PathSwitchRequestSetupFailedTransfer{}

err = aper.UnmarshalWithParams(b, &pathSwitchRequestSetupFailedTransfer, "valueExt")

if err != nil {
return err
}
Expand Down Expand Up @@ -229,7 +226,6 @@ func HandleHandoverRequestAcknowledgeTransfer(b []byte, ctx *SMContext) (err err
handoverRequestAcknowledgeTransfer := ngapType.HandoverRequestAcknowledgeTransfer{}

err = aper.UnmarshalWithParams(b, &handoverRequestAcknowledgeTransfer, "valueExt")

if err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/factory/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package factory

import (
"fmt"
"io/ioutil"
"os"

"github.com/asaskevich/govalidator"
"gopkg.in/yaml.v2"
Expand All @@ -26,7 +26,7 @@ func InitConfigFactory(f string, cfg *Config) error {
f = SmfDefaultConfigPath
}

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)
Expand All @@ -43,7 +43,7 @@ func InitRoutingConfigFactory(f string, cfg *RoutingConfig) error {
// Use default config path
f = SmfDefaultUERoutingPath
}
if content, err := ioutil.ReadFile(f); err != nil {
if content, err := os.ReadFile(f); err != nil {
return err
} else {
logger.CfgLog.Infof("Read config from [%s]", f)
Expand Down
6 changes: 3 additions & 3 deletions pkg/service/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package service
import (
"context"
"fmt"
"io/ioutil"
"io"
"os"
"os/signal"
"runtime/debug"
Expand Down Expand Up @@ -49,15 +49,15 @@ func (a *SmfApp) 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)
}
}

Expand Down

0 comments on commit 5575470

Please sign in to comment.