Update go version (#603)

Removed ioctl code and remove exception from lint action
This commit is contained in:
Maycon Santos 2022-12-04 13:22:21 +01:00 committed by GitHub
parent d029136d3d
commit d2d5d4b4b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 22 additions and 30 deletions

View File

@ -13,7 +13,7 @@ jobs:
- name: Install Go - name: Install Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.18.x go-version: 1.19.x
- name: Checkout code - name: Checkout code
uses: actions/checkout@v2 uses: actions/checkout@v2

View File

@ -16,7 +16,7 @@ jobs:
- name: Install Go - name: Install Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.18.x go-version: 1.19.x
- name: Cache Go modules - name: Cache Go modules
@ -45,7 +45,7 @@ jobs:
- name: Install Go - name: Install Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.18.x go-version: 1.19.x
- name: Cache Go modules - name: Cache Go modules

View File

@ -31,7 +31,7 @@ jobs:
- name: Install Go - name: Install Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.18.x go-version: 1.19.x
- uses: actions/cache@v2 - uses: actions/cache@v2
with: with:

View File

@ -9,13 +9,10 @@ jobs:
- name: Install Go - name: Install Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.18.x go-version: 1.19.x
- name: Install dependencies - name: Install dependencies
run: sudo apt update && sudo apt install -y -q libgtk-3-dev libappindicator3-dev libayatana-appindicator3-dev libgl1-mesa-dev xorg-dev run: sudo apt update && sudo apt install -y -q libgtk-3-dev libappindicator3-dev libayatana-appindicator3-dev libgl1-mesa-dev xorg-dev
- name: golangci-lint - name: golangci-lint
uses: golangci/golangci-lint-action@v2 uses: golangci/golangci-lint-action@v2
with: with:
# SA1019: "io/ioutil" has been deprecated since Go 1.16 args: --timeout=6m
args: --timeout=6m -e SA1019

View File

@ -29,7 +29,7 @@ jobs:
name: Set up Go name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.18 go-version: 1.19
- -
name: Cache Go modules name: Cache Go modules
uses: actions/cache@v1 uses: actions/cache@v1
@ -88,7 +88,7 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.18 go-version: 1.19
- name: Cache Go modules - name: Cache Go modules
uses: actions/cache@v1 uses: actions/cache@v1
with: with:
@ -138,7 +138,7 @@ jobs:
name: Set up Go name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.18 go-version: 1.19
- -
name: Cache Go modules name: Cache Go modules
uses: actions/cache@v1 uses: actions/cache@v1

View File

@ -19,7 +19,7 @@ jobs:
- name: Install Go - name: Install Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.18.x go-version: 1.19.x
- name: Cache Go modules - name: Cache Go modules
uses: actions/cache@v2 uses: actions/cache@v2

View File

@ -6,7 +6,6 @@ import (
"fmt" "fmt"
"io" "io"
"io/fs" "io/fs"
"io/ioutil"
"os" "os"
"os/signal" "os/signal"
"path" "path"
@ -236,7 +235,7 @@ func copySymLink(source, dest string) error {
func cpDir(src string, dst string) error { func cpDir(src string, dst string) error {
var err error var err error
var fds []os.FileInfo var fds []os.DirEntry
var srcinfo os.FileInfo var srcinfo os.FileInfo
if srcinfo, err = os.Stat(src); err != nil { if srcinfo, err = os.Stat(src); err != nil {
@ -247,7 +246,7 @@ func cpDir(src string, dst string) error {
return err return err
} }
if fds, err = ioutil.ReadDir(src); err != nil { if fds, err = os.ReadDir(src); err != nil {
return err return err
} }
for _, fd := range fds { for _, fd := range fds {

View File

@ -18,7 +18,6 @@ func (unimplementedFirewall) RemoveRoutingRules(pair routerPair) error {
} }
func (unimplementedFirewall) CleanRoutingRules() { func (unimplementedFirewall) CleanRoutingRules() {
return
} }
// NewFirewall returns an unimplemented Firewall manager // NewFirewall returns an unimplemented Firewall manager

View File

@ -2,9 +2,9 @@ package routemanager
import ( import (
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
"io/ioutil"
"net" "net"
"net/netip" "net/netip"
"os"
) )
const ipv4ForwardingPath = "/proc/sys/net/ipv4/ip_forward" const ipv4ForwardingPath = "/proc/sys/net/ipv4/ip_forward"
@ -59,12 +59,12 @@ func removeFromRouteTable(prefix netip.Prefix) error {
} }
func enableIPForwarding() error { func enableIPForwarding() error {
err := ioutil.WriteFile(ipv4ForwardingPath, []byte("1"), 0644) err := os.WriteFile(ipv4ForwardingPath, []byte("1"), 0644)
return err return err
} }
func isNetForwardHistoryEnabled() bool { func isNetForwardHistoryEnabled() bool {
out, err := ioutil.ReadFile(ipv4ForwardingPath) out, err := os.ReadFile(ipv4ForwardingPath)
if err != nil { if err != nil {
// todo // todo
panic(err) panic(err)

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/netbirdio/netbird module github.com/netbirdio/netbird
go 1.18 go 1.19
require ( require (
github.com/cenkalti/backoff/v4 v4.1.3 github.com/cenkalti/backoff/v4 v4.1.3

View File

@ -8,8 +8,8 @@ import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/vishvananda/netlink" "github.com/vishvananda/netlink"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
"io"
"io/fs" "io/fs"
"io/ioutil"
"math" "math"
"os" "os"
"path/filepath" "path/filepath"
@ -295,7 +295,7 @@ func loadModule(name, path string) error {
// first try finit_module(2), then init_module(2) // first try finit_module(2), then init_module(2)
err = unix.FinitModule(int(f.Fd()), "", 0) err = unix.FinitModule(int(f.Fd()), "", 0)
if errors.Is(err, unix.ENOSYS) { if errors.Is(err, unix.ENOSYS) {
buf, err := ioutil.ReadAll(f) buf, err := io.ReadAll(f)
if err != nil { if err != nil {
return err return err
} }

View File

@ -6,7 +6,6 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
"io" "io"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -133,7 +132,7 @@ func resetGlobals() {
func createFiles(t *testing.T) (string, []module) { func createFiles(t *testing.T) (string, []module) {
writeFile := func(path, text string) { writeFile := func(path, text string) {
if err := ioutil.WriteFile(path, []byte(text), 0644); err != nil { if err := os.WriteFile(path, []byte(text), 0644); err != nil {
t.Fatal(err) t.Fatal(err)
} }
} }

View File

@ -7,7 +7,6 @@ import (
"golang.org/x/crypto/acme/autocert" "golang.org/x/crypto/acme/autocert"
"io" "io"
"io/fs" "io/fs"
"io/ioutil"
"net" "net"
"net/http" "net/http"
"os" "os"
@ -231,7 +230,7 @@ func copySymLink(source, dest string) error {
func cpDir(src string, dst string) error { func cpDir(src string, dst string) error {
var err error var err error
var fds []os.FileInfo var fds []os.DirEntry
var srcinfo os.FileInfo var srcinfo os.FileInfo
if srcinfo, err = os.Stat(src); err != nil { if srcinfo, err = os.Stat(src); err != nil {
@ -242,7 +241,7 @@ func cpDir(src string, dst string) error {
return err return err
} }
if fds, err = ioutil.ReadDir(src); err != nil { if fds, err = os.ReadDir(src); err != nil {
return err return err
} }
for _, fd := range fds { for _, fd := range fds {

View File

@ -7,7 +7,6 @@ import (
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"io" "io"
"io/ioutil"
"os" "os"
) )
@ -25,7 +24,7 @@ var _ = Describe("Client", func() {
BeforeEach(func() { BeforeEach(func() {
var err error var err error
tmpDir, err = ioutil.TempDir("", "wiretrustee_util_test_tmp_*") tmpDir, err = os.MkdirTemp("", "wiretrustee_util_test_tmp_*")
Expect(err).NotTo(HaveOccurred()) Expect(err).NotTo(HaveOccurred())
}) })