Skip to content

Commit 4a6d9bc

Browse files
authored
fix: use sys/unix instead of syscall (#1953)
## What kind of change does this PR introduce? * Use `syscall.SO_REUSEPORT` instead of hardcoding the syscall to deal with cases where it's not supported * Upgrade go to version 1.23.7
1 parent 18fbbb5 commit 4a6d9bc

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

.github/workflows/test.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
test:
1212
strategy:
1313
matrix:
14-
go-version: [1.22.x]
14+
go-version: [1.23.7]
1515
runs-on: ubuntu-20.04
1616
services:
1717
postgres:
@@ -29,13 +29,11 @@ jobs:
2929
--health-retries 5
3030
steps:
3131
- name: Install Go
32-
uses: actions/setup-go@v2
32+
uses: actions/setup-go@v5
3333
with:
3434
go-version: ${{ matrix.go-version }}
3535
- name: Checkout code
3636
uses: actions/checkout@v2
37-
with:
38-
skip-unshallow: "true"
3937
- name: Check gofmt
4038
run: |
4139
set -x

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22.3-alpine3.20 as build
1+
FROM golang:1.23.7-alpine3.20 as build
22
ENV GO111MODULE=on
33
ENV CGO_ENABLED=0
44
ENV GOOS=linux

Dockerfile.dev

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.22.3-alpine3.20
1+
FROM golang:1.23.7-alpine3.20
22
ENV GO111MODULE=on
33
ENV CGO_ENABLED=0
44
ENV GOOS=linux

cmd/serve_cmd.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"syscall"
99
"time"
1010

11+
"golang.org/x/sys/unix"
12+
1113
"github.com/pkg/errors"
1214
"github.com/sirupsen/logrus"
1315
"github.com/spf13/cobra"
@@ -110,8 +112,7 @@ func serve(ctx context.Context) {
110112
Control: func(network, address string, c syscall.RawConn) error {
111113
var serr error
112114
if err := c.Control(func(fd uintptr) {
113-
// hard-coded syscall.SO_REUSEPORT since it doesn't seem to be defined in different environments
114-
serr = syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, 0x200, 1)
115+
serr = unix.SetsockoptInt(int(fd), unix.SOL_SOCKET, unix.SO_REUSEPORT, 1)
115116
}); err != nil {
116117
return err
117118
}

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ require (
162162
golang.org/x/exp v0.0.0-20230811145659-89c5cff77bcb
163163
golang.org/x/net v0.25.0 // indirect
164164
golang.org/x/sync v0.10.0
165-
golang.org/x/sys v0.28.0 // indirect
165+
golang.org/x/sys v0.28.0
166166
golang.org/x/text v0.21.0 // indirect
167167
golang.org/x/time v0.5.0
168168
google.golang.org/appengine v1.6.8 // indirect
@@ -173,4 +173,4 @@ require (
173173
gopkg.in/yaml.v3 v3.0.1 // indirect
174174
)
175175

176-
go 1.22.3
176+
go 1.23.7

0 commit comments

Comments
 (0)