From d5c0dc9beeb7dfb3d9c1158be150c2ec19ed5574 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sat, 6 Aug 2022 15:19:01 +0100 Subject: [PATCH 1/2] Go 1.19 in CI --- .github/workflows/ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b41e4336..7915026d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: steps: - uses: actions/setup-go@v3 with: - go-version: 1.18 + go-version: 1.19 - uses: actions/checkout@v3 - name: golangci-lint uses: golangci/golangci-lint-action@v3 @@ -51,7 +51,7 @@ jobs: strategy: fail-fast: false matrix: - goversion: ["1.17", "1.18"] + goversion: ["1.17", "1.18", "1.19"] name: Build & Test (Linux, Go ${{ matrix.goversion }}) needs: [lint] @@ -75,7 +75,7 @@ jobs: strategy: fail-fast: false matrix: - goversion: ["1.17", "1.18"] + goversion: ["1.17", "1.18", "1.19"] name: Build & Test (Windows, Go ${{ matrix.goversion }}) needs: [lint] @@ -99,7 +99,7 @@ jobs: strategy: fail-fast: false matrix: - goversion: ["1.17", "1.18"] + goversion: ["1.17", "1.18", "1.19"] name: Build & Test (macOS, Go ${{ matrix.goversion }}) needs: [lint] @@ -148,7 +148,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18 + go-version: 1.19 - name: Build package env: @@ -180,7 +180,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18 + go-version: 1.19 - name: Build package env: @@ -212,7 +212,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18 + go-version: 1.19 - name: Build package run: sh contrib/msi/build-msi.sh ${{ matrix.pkgarch }} @@ -248,7 +248,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v3 with: - go-version: 1.18 + go-version: 1.19 - name: Build package env: From 16b81490525392bb87cc81e80f0118e1e5cf6184 Mon Sep 17 00:00:00 2001 From: Neil Alexander Date: Sat, 6 Aug 2022 15:21:21 +0100 Subject: [PATCH 2/2] No longer use `ioutil` which is deprecated --- cmd/yggdrasil/main.go | 6 +++--- cmd/yggdrasilctl/cmd_line_env.go | 3 +-- src/core/core.go | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/yggdrasil/main.go b/cmd/yggdrasil/main.go index 58b8230d..30cdd5e5 100644 --- a/cmd/yggdrasil/main.go +++ b/cmd/yggdrasil/main.go @@ -8,7 +8,7 @@ import ( "encoding/json" "flag" "fmt" - "io/ioutil" + "io" "net" "os" "os/signal" @@ -51,10 +51,10 @@ func readConfig(log *log.Logger, useconf bool, useconffile string, normaliseconf var err error if useconffile != "" { // Read the file from the filesystem - conf, err = ioutil.ReadFile(useconffile) + conf, err = os.ReadFile(useconffile) } else { // Read the file from stdin. - conf, err = ioutil.ReadAll(os.Stdin) + conf, err = io.ReadAll(os.Stdin) } if err != nil { panic(err) diff --git a/cmd/yggdrasilctl/cmd_line_env.go b/cmd/yggdrasilctl/cmd_line_env.go index bd6df8fc..c1acacd6 100644 --- a/cmd/yggdrasilctl/cmd_line_env.go +++ b/cmd/yggdrasilctl/cmd_line_env.go @@ -4,7 +4,6 @@ import ( "bytes" "flag" "fmt" - "io/ioutil" "log" "os" @@ -61,7 +60,7 @@ func (cmdLineEnv *CmdLineEnv) parseFlagsAndArgs() { func (cmdLineEnv *CmdLineEnv) setEndpoint(logger *log.Logger) { if cmdLineEnv.server == cmdLineEnv.endpoint { - if config, err := ioutil.ReadFile(defaults.GetDefaults().DefaultConfigFile); err == nil { + if config, err := os.ReadFile(defaults.GetDefaults().DefaultConfigFile); err == nil { if bytes.Equal(config[0:2], []byte{0xFF, 0xFE}) || bytes.Equal(config[0:2], []byte{0xFE, 0xFF}) { utf := unicode.UTF16(unicode.BigEndian, unicode.UseBOM) diff --git a/src/core/core.go b/src/core/core.go index 0332980b..f77648b2 100644 --- a/src/core/core.go +++ b/src/core/core.go @@ -6,7 +6,7 @@ import ( "encoding/hex" "errors" "fmt" - "io/ioutil" + "io" "net" "net/url" "time" @@ -48,7 +48,7 @@ func (c *Core) _init() error { c.config.RLock() defer c.config.RUnlock() if c.log == nil { - c.log = log.New(ioutil.Discard, "", 0) + c.log = log.New(io.Discard, "", 0) } sigPriv, err := hex.DecodeString(c.config.PrivateKey)