From f9f13f0f2a52185b4c9b3e6242cd931e5a6239e3 Mon Sep 17 00:00:00 2001
From: Arran Walker <ajwalker@gitlab.com>
Date: Tue, 26 Sep 2023 23:30:42 +0100
Subject: [PATCH] Upgrade Go to 1.21.1

---
 CONTRIBUTING.md                                    |  3 ---
 Dockerfile                                         | 10 ++--------
 appveyor.yml                                       |  2 +-
 commands/scp_unix.go                               |  1 +
 drivers/virtualbox/vtx_intel.go                    |  1 +
 drivers/virtualbox/vtx_other.go                    |  1 +
 drivers/vmwarefusion/fusion.go                     |  1 +
 libmachine/drivers/plugin/localbinary/plugin.go    |  6 ++++--
 libmachine/provision/provisiontest/sshcommander.go | 12 ++++++------
 libmachine/shell/shell.go                          |  1 +
 libmachine/shell/shell_unix_test.go                |  1 +
 mk/main.mk                                         |  6 +-----
 mk/validate.mk                                     | 10 ++++++----
 13 files changed, 26 insertions(+), 29 deletions(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 1b5f30ee..55b6e79e 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -72,9 +72,6 @@ to clean-up build results.
 
 ## Tests and validation
 
-We use the usual `go` tools for this, to run those commands you need at least the linter which you can
-install with `go get -u golang.org/x/lint/golint`
-
 To run basic validation (fmt, test-short, lint, vet), and the project unit tests, call:
 
     $ make test
diff --git a/Dockerfile b/Dockerfile
index 935de0e6..f19f53d6 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,20 +1,14 @@
-FROM golang:1.12.9
+FROM golang:1.21.1
 
 RUN apt-get update && apt-get install -y --no-install-recommends \
                 openssh-client \
                 rsync \
-                fuse \
+                fuse3 \
                 sshfs \
         && rm -rf /var/lib/apt/lists/*
 
 ENV GO111MODULE=on
 
-RUN go get golang.org/x/tools@v0.1.12
-RUN go get golang.org/x/lint/golint
-RUN go get golang.org/x/tools/cover
-
-ENV GO111MODULE=off
-
 ENV USER root
 WORKDIR /go/src/github.com/docker/machine
 
diff --git a/appveyor.yml b/appveyor.yml
index a32b5620..3fbdd1ee 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -10,7 +10,7 @@ environment:
 clone_folder: c:\gopath\src\github.com\docker\machine
 
 build_script:
-  - go build -i -o ./bin/docker-machine.exe ./cmd/docker-machine
+  - go build -o ./bin/docker-machine.exe ./cmd/docker-machine
 
 test_script:
   - powershell -Command go test -v ./libmachine/shell
diff --git a/commands/scp_unix.go b/commands/scp_unix.go
index d26cf384..b483449a 100644
--- a/commands/scp_unix.go
+++ b/commands/scp_unix.go
@@ -1,3 +1,4 @@
+//go:build !windows
 // +build !windows
 
 package commands
diff --git a/drivers/virtualbox/vtx_intel.go b/drivers/virtualbox/vtx_intel.go
index 852f451d..2d8088f6 100644
--- a/drivers/virtualbox/vtx_intel.go
+++ b/drivers/virtualbox/vtx_intel.go
@@ -1,3 +1,4 @@
+//go:build 386 || amd64
 // +build 386 amd64
 
 package virtualbox
diff --git a/drivers/virtualbox/vtx_other.go b/drivers/virtualbox/vtx_other.go
index 5dbfd175..f984ac3f 100644
--- a/drivers/virtualbox/vtx_other.go
+++ b/drivers/virtualbox/vtx_other.go
@@ -1,3 +1,4 @@
+//go:build !386 && !amd64
 // +build !386,!amd64
 
 package virtualbox
diff --git a/drivers/vmwarefusion/fusion.go b/drivers/vmwarefusion/fusion.go
index be433e5f..e2d588a2 100644
--- a/drivers/vmwarefusion/fusion.go
+++ b/drivers/vmwarefusion/fusion.go
@@ -1,3 +1,4 @@
+//go:build !darwin
 // +build !darwin
 
 package vmwarefusion
diff --git a/libmachine/drivers/plugin/localbinary/plugin.go b/libmachine/drivers/plugin/localbinary/plugin.go
index c431c7ed..ae32b1e9 100644
--- a/libmachine/drivers/plugin/localbinary/plugin.go
+++ b/libmachine/drivers/plugin/localbinary/plugin.go
@@ -93,9 +93,11 @@ func (e ErrPluginBinaryNotFound) Error() string {
 }
 
 // driverPath finds the path of a driver binary by its name.
-//  + If the driver is a core driver, there is no separate driver binary. We reuse current binary if it's `docker-machine`
+//   - If the driver is a core driver, there is no separate driver binary. We reuse current binary if it's `docker-machine`
+//
 // or we assume `docker-machine` is in the PATH.
-//  + If the driver is NOT a core driver, then the separate binary must be in the PATH and it's name must be
+//   - If the driver is NOT a core driver, then the separate binary must be in the PATH and it's name must be
+//
 // `docker-machine-driver-driverName`
 func driverPath(driverName string) string {
 	for _, coreDriver := range CoreDrivers {
diff --git a/libmachine/provision/provisiontest/sshcommander.go b/libmachine/provision/provisiontest/sshcommander.go
index 3f9f8b71..e826cb68 100644
--- a/libmachine/provision/provisiontest/sshcommander.go
+++ b/libmachine/provision/provisiontest/sshcommander.go
@@ -1,21 +1,21 @@
-//Package provisiontest provides utilities for testing provisioners
+// Package provisiontest provides utilities for testing provisioners
 package provisiontest
 
 import "errors"
 
-//FakeSSHCommanderOptions is intended to create a FakeSSHCommander without actually knowing the underlying sshcommands by passing it to NewSSHCommander
+// FakeSSHCommanderOptions is intended to create a FakeSSHCommander without actually knowing the underlying sshcommands by passing it to NewSSHCommander
 type FakeSSHCommanderOptions struct {
 	//Result of the ssh command to look up the FilesystemType
 	FilesystemType string
 }
 
-//FakeSSHCommander is an implementation of provision.SSHCommander to provide predictable responses set by testing code
-//Extend it when needed
+// FakeSSHCommander is an implementation of provision.SSHCommander to provide predictable responses set by testing code
+// Extend it when needed
 type FakeSSHCommander struct {
 	Responses map[string]string
 }
 
-//NewFakeSSHCommander creates a FakeSSHCommander without actually knowing the underlying sshcommands
+// NewFakeSSHCommander creates a FakeSSHCommander without actually knowing the underlying sshcommands
 func NewFakeSSHCommander(options FakeSSHCommanderOptions) *FakeSSHCommander {
 	if options.FilesystemType == "" {
 		options.FilesystemType = "ext4"
@@ -29,7 +29,7 @@ func NewFakeSSHCommander(options FakeSSHCommanderOptions) *FakeSSHCommander {
 	return sshCmder
 }
 
-//SSHCommand is an implementation of provision.SSHCommander.SSHCommand to provide predictable responses set by testing code
+// SSHCommand is an implementation of provision.SSHCommander.SSHCommand to provide predictable responses set by testing code
 func (sshCmder *FakeSSHCommander) SSHCommand(args string) (string, error) {
 	response, commandRegistered := sshCmder.Responses[args]
 	if !commandRegistered {
diff --git a/libmachine/shell/shell.go b/libmachine/shell/shell.go
index d0a271c9..348b369f 100644
--- a/libmachine/shell/shell.go
+++ b/libmachine/shell/shell.go
@@ -1,3 +1,4 @@
+//go:build !windows
 // +build !windows
 
 package shell
diff --git a/libmachine/shell/shell_unix_test.go b/libmachine/shell/shell_unix_test.go
index b9382071..16a76675 100644
--- a/libmachine/shell/shell_unix_test.go
+++ b/libmachine/shell/shell_unix_test.go
@@ -1,3 +1,4 @@
+//go:build !windows
 // +build !windows
 
 package shell
diff --git a/mk/main.mk b/mk/main.mk
index 5f630360..2e24ee92 100644
--- a/mk/main.mk
+++ b/mk/main.mk
@@ -3,11 +3,7 @@ GO_LDFLAGS := -X `go list ./version`.GitCommit=`git rev-parse --short HEAD 2>/de
 GO_GCFLAGS :=
 
 # Full package list
-PKGS := $(shell go list -tags "$(BUILDTAGS)" ./... | grep -v "/vendor/" | grep -v "/cmd")
-
-# Resolving binary dependencies for specific targets
-GOLINT_BIN := $(GOPATH)/bin/golint
-GOLINT := $(shell [ -x $(GOLINT_BIN) ] && echo $(GOLINT_BIN) || echo '')
+PKGS := $(shell go list -tags "$(BUILDTAGS)" ./... | grep -v "/cmd")
 
 # Honor debug
 ifeq ($(DEBUG),true)
diff --git a/mk/validate.mk b/mk/validate.mk
index 5c05d6f1..b449018e 100644
--- a/mk/validate.mk
+++ b/mk/validate.mk
@@ -1,10 +1,12 @@
 fmt:
-	@test -z "$$(gofmt -s -l . 2>&1 | grep -v vendor/ | tee /dev/stderr)"
+	@go mod download
+	@test -z "$$(gofmt -s -l . 2>&1 | tee /dev/stderr)"
 
 vet:
+	@go mod download
 	@test -z "$$(go vet $(PKGS) 2>&1 | tee /dev/stderr)"
 
 lint:
-	$(if $(GOLINT), , \
-		$(error Please install golint: go get -u golang.org/x/lint/golint))
-	@test -z "$$($(GOLINT) ./... 2>&1 | grep -v vendor/ | grep -v "cli/" | grep -v "amazonec2/" |grep -v "openstack/" |grep -v "softlayer/" | grep -v "should have comment" | tee /dev/stderr)"
+	@go mod download
+	@go install golang.org/x/lint/golint@latest
+	@test -z "$$(golint ./... 2>&1 | grep -v "cli/" | grep -v "amazonec2/" |grep -v "openstack/" |grep -v "softlayer/" | grep -v "should have comment" | tee /dev/stderr)"
-- 
GitLab