Skip to content

Commit

Permalink
Migrate go code to function in go 1.22+ (#873)
Browse files Browse the repository at this point in the history
* Migrate go code to function in go 1.22+

* ci: attempt to bump golang from 1.19 to 1.23 in testing images
  • Loading branch information
consideRatio authored Feb 7, 2025
1 parent 9b8c0fc commit 3fab065
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-publish-python-packages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
go-version: "1.23"
cache-dependency-path: "**/*.sum"
- uses: actions/setup-python@v5
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ jobs:
# that would be fine.
#
- python-version: "3.10"
go-version: "1.20"
go-version: "1.22"
- python-version: "3.11"
go-version: "1.20"
go-version: "1.22"
- python-version: "3.12"
go-version: "1.21"
go-version: "1.23"
- python-version: "3.13"
go-version: "1.21"
go-version: "1.23"

steps:
- uses: actions/checkout@v4
Expand Down
7 changes: 5 additions & 2 deletions continuous_integration/docker/base/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
FROM centos:7

ARG python_version="3.11"
ARG go_version="1.19"
# go_version was 1.19 until it was updated to 1.23.6 (2025-02-07) by adding a
# layer on top of the previous image, as it is no longer able to build and it
# was an easy way to update the golang version.
ARG go_version="1.23.6"

# Set labels based on the Open Containers Initiative (OCI):
# https://github.com/opencontainers/image-spec/blob/main/annotations.md#pre-defined-annotation-keys
Expand Down Expand Up @@ -66,7 +69,7 @@ RUN yum install -y bzip2 \
&& rm -rf /var/cache/yum

# Install go
RUN curl -sL https://dl.google.com/go/go${go_version}.linux-amd64.tar.gz \
RUN curl -sL https://go.dev/dl/go${go_version}.linux-amd64.tar.gz \
| tar --extract --verbose --gzip --directory=/opt/

# Put Python and Go environments on PATH
Expand Down
4 changes: 2 additions & 2 deletions dask-gateway-server/dask-gateway-proxy/go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
module github.com/dask/dask-gateway/dask-gateway-proxy

go 1.21
go 1.22

require github.com/stretchr/testify v1.8.4
require github.com/stretchr/testify v1.10.0

require (
github.com/davecgh/go-spew v1.1.1 // indirect
Expand Down
13 changes: 13 additions & 0 deletions dask-gateway-server/dask-gateway-proxy/pkg/sni/sni.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ import (
"net"
)

// hideWriteTo is a workaround introduced to make the code functional in 1.22+,
// where io.Copy would no longer make use of peekedTCPConn.Read after
// net.TCPConn.WriteTo was added, so the workaround is to hide it again.
//
// The workaround was developed inspecting:
// https://github.com/golang/go/commit/f664031bc17629080332a1c7bede38d67fd32e47
//
type hideWriteTo struct{}
func (hideWriteTo) WriteTo(io.Writer) (int64, error) {
panic("can't happen")
}

type TcpConn interface {
net.Conn
CloseWrite() error
Expand All @@ -16,6 +28,7 @@ type TcpConn interface {

type peekedTCPConn struct {
peeked []byte
hideWriteTo
*net.TCPConn
}

Expand Down

0 comments on commit 3fab065

Please sign in to comment.