Skip to content

Commit

Permalink
Enable linter and fix the issues pointed out by it
Browse files Browse the repository at this point in the history
Signed-off-by: Yutaro Hayakawa <[email protected]>
  • Loading branch information
YutaroHayakawa committed May 4, 2024
1 parent ed34f6f commit 2794afc
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 18 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: golangci-lint
on:
push:
branches:
- main
pull_request:

permissions:
contents: read

jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod

- name: Lint
uses: golangci/golangci-lint-action@v5
with:
version: latest
args: -D errcheck
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ DEEPCOPY_OPTS=-type Config -type InterfaceConfig -type InterfaceStatus

all:

lint:
docker run -t --rm -v $(PWD):/app -w /app golangci/golangci-lint:v1.58.0 golangci-lint run -v -D errcheck

deepcopy:
deep-copy -pointer-receiver $(DEEPCOPY_OPTS) -o zz_generated_deepcopy.go .

Expand Down
1 change: 0 additions & 1 deletion daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
type Daemon struct {
initialConfig *Config
reloadCh chan *Config
stopCh any
logger *slog.Logger
socketConstructor rAdvSocketCtor

Expand Down
4 changes: 0 additions & 4 deletions fake_socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ func (s *fakeSock) txCh() <-chan fakeRA {
return s.tx
}

func (s *fakeSock) rxCh() chan<- fakeRS {
return s.rx
}

func (s *fakeSock) hardwareAddr() net.HardwareAddr {
return net.HardwareAddr{0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff}
}
Expand Down
8 changes: 4 additions & 4 deletions integration_tests/gobgp_unnumbered_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ func TestGoBGPUnnumbered(t *testing.T) {
sysctlClient, err := sysctl.NewClient(sysctl.DefaultPath)
require.NoError(t, err)

sysctlClient.Set("net.ipv6.conf.go-radv0.forwarding", "1")
err = sysctlClient.Set("net.ipv6.conf.go-radv0.forwarding", "1")
require.NoError(t, err)

sysctlClient.Set("net.ipv6.conf.go-radv0.accept_ra", "2")
err = sysctlClient.Set("net.ipv6.conf.go-radv0.accept_ra", "2")
require.NoError(t, err)

sysctlClient.Set("net.ipv6.conf.go-radv1.forwarding", "1")
err = sysctlClient.Set("net.ipv6.conf.go-radv1.forwarding", "1")
require.NoError(t, err)

sysctlClient.Set("net.ipv6.conf.go-radv1.accept_ra", "2")
err = sysctlClient.Set("net.ipv6.conf.go-radv1.accept_ra", "2")
require.NoError(t, err)

t.Log("Sysctl set. Starting radvd.")
Expand Down
6 changes: 1 addition & 5 deletions ra_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ type raSender struct {
socketCtor rAdvSocketCtor
}

type raSenderStatusReq struct {
ctx context.Context
resCh chan *InterfaceStatus
}

func newRASender(initialConfig *InterfaceConfig, ctor rAdvSocketCtor, logger *slog.Logger) *raSender {
return &raSender{
logger: logger.With(slog.String("interface", initialConfig.Name)),
Expand Down Expand Up @@ -164,6 +159,7 @@ reload:
}
config = newConfig
s.reportReloading()
s.resetStat()
s.setLastUpdate()
continue reload
case <-ctx.Done():
Expand Down
4 changes: 0 additions & 4 deletions socket.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ import (
"golang.org/x/net/ipv6"
)

const (
maxRecvSize = 1500
)

// rAdvSocket is a raw socket for sending RA and receiving RS
type rAdvSocket interface {
hardwareAddr() net.HardwareAddr
Expand Down

0 comments on commit 2794afc

Please sign in to comment.