From 99fd80a5856099c3610a4fdecce515e8c8ec686a Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Wed, 26 Feb 2020 20:29:36 +0100 Subject: [PATCH] Remove all workarounds for Go < 1.11 --- build.go | 2 +- doc/020_installation.rst | 11 +-------- internal/backend/rclone/stdio_conn.go | 21 +++++++++++++++++ internal/backend/rclone/stdio_conn_go110.go | 25 --------------------- internal/backend/rclone/stdio_conn_other.go | 22 ------------------ internal/test/helper.go | 2 -- internal/test/helper_go18.go | 19 ---------------- 7 files changed, 23 insertions(+), 79 deletions(-) delete mode 100644 internal/backend/rclone/stdio_conn_go110.go delete mode 100644 internal/backend/rclone/stdio_conn_other.go delete mode 100644 internal/test/helper_go18.go diff --git a/build.go b/build.go index 0b3a6a61a..aa5ae21ef 100644 --- a/build.go +++ b/build.go @@ -65,7 +65,7 @@ var config = Config{ Main: "./cmd/restic", // package name for the main package DefaultBuildTags: []string{"selfupdate"}, // specify build tags which are always used Tests: []string{"./..."}, // tests to run - MinVersion: GoVersion{Major: 1, Minor: 10, Patch: 0}, // minimum Go version supported + MinVersion: GoVersion{Major: 1, Minor: 11, Patch: 0}, // minimum Go version supported } // Config configures the build. diff --git a/doc/020_installation.rst b/doc/020_installation.rst index 05acae259..005e44d32 100644 --- a/doc/020_installation.rst +++ b/doc/020_installation.rst @@ -245,7 +245,7 @@ From Source *********** restic is written in the Go programming language and you need at least -Go version 1.9. Building restic may also work with older versions of Go, +Go version 1.11. Building restic may also work with older versions of Go, but that's not supported. See the `Getting started `__ guide of the Go project for instructions how to install Go. @@ -261,13 +261,6 @@ In order to build restic from source, execute the following steps: $ go run -mod=vendor build.go -For Go versions < 1.11, the option ``-mod=vendor`` needs to be removed, like -this: - -.. code-block:: console - - $ go run build.go - You can easily cross-compile restic for all supported platforms, just supply the target OS and platform via the command-line options like this (for Windows and FreeBSD respectively): @@ -280,8 +273,6 @@ supply the target OS and platform via the command-line options like this $ go run -mod=vendor build.go --goos linux --goarch arm --goarm 6 -Again, for Go < 1.11 ``-mod=vendor`` needs to be removed. - The resulting binary is statically linked and does not require any libraries. diff --git a/internal/backend/rclone/stdio_conn.go b/internal/backend/rclone/stdio_conn.go index 4abbb7c9a..a44e6aa5c 100644 --- a/internal/backend/rclone/stdio_conn.go +++ b/internal/backend/rclone/stdio_conn.go @@ -5,6 +5,7 @@ import ( "os" "os/exec" "sync" + "time" "github.com/restic/restic/internal/debug" ) @@ -58,6 +59,26 @@ func (s *StdioConn) RemoteAddr() net.Addr { return Addr{} } +// SetDeadline sets the read/write deadline. +func (s *StdioConn) SetDeadline(t time.Time) error { + err1 := s.stdin.SetReadDeadline(t) + err2 := s.stdout.SetWriteDeadline(t) + if err1 != nil { + return err1 + } + return err2 +} + +// SetReadDeadline sets the read/write deadline. +func (s *StdioConn) SetReadDeadline(t time.Time) error { + return s.stdin.SetReadDeadline(t) +} + +// SetWriteDeadline sets the read/write deadline. +func (s *StdioConn) SetWriteDeadline(t time.Time) error { + return s.stdout.SetWriteDeadline(t) +} + // make sure StdioConn implements net.Conn var _ net.Conn = &StdioConn{} diff --git a/internal/backend/rclone/stdio_conn_go110.go b/internal/backend/rclone/stdio_conn_go110.go deleted file mode 100644 index b21f65f04..000000000 --- a/internal/backend/rclone/stdio_conn_go110.go +++ /dev/null @@ -1,25 +0,0 @@ -// +build go1.10 - -package rclone - -import "time" - -// SetDeadline sets the read/write deadline. -func (s *StdioConn) SetDeadline(t time.Time) error { - err1 := s.stdin.SetReadDeadline(t) - err2 := s.stdout.SetWriteDeadline(t) - if err1 != nil { - return err1 - } - return err2 -} - -// SetReadDeadline sets the read/write deadline. -func (s *StdioConn) SetReadDeadline(t time.Time) error { - return s.stdin.SetReadDeadline(t) -} - -// SetWriteDeadline sets the read/write deadline. -func (s *StdioConn) SetWriteDeadline(t time.Time) error { - return s.stdout.SetWriteDeadline(t) -} diff --git a/internal/backend/rclone/stdio_conn_other.go b/internal/backend/rclone/stdio_conn_other.go deleted file mode 100644 index 07f85961b..000000000 --- a/internal/backend/rclone/stdio_conn_other.go +++ /dev/null @@ -1,22 +0,0 @@ -// +build !go1.10 - -package rclone - -import "time" - -// On Go < 1.10, it's not possible to set read/write deadlines on files, so we just ignore that. - -// SetDeadline sets the read/write deadline. -func (s *StdioConn) SetDeadline(t time.Time) error { - return nil -} - -// SetReadDeadline sets the read/write deadline. -func (s *StdioConn) SetReadDeadline(t time.Time) error { - return nil -} - -// SetWriteDeadline sets the read/write deadline. -func (s *StdioConn) SetWriteDeadline(t time.Time) error { - return nil -} diff --git a/internal/test/helper.go b/internal/test/helper.go index f0fc1f61b..c5fe3188c 100644 --- a/internal/test/helper.go +++ b/internal/test/helper.go @@ -1,5 +1,3 @@ -// +build go1.9 - package test import "testing" diff --git a/internal/test/helper_go18.go b/internal/test/helper_go18.go deleted file mode 100644 index d4f8b8de6..000000000 --- a/internal/test/helper_go18.go +++ /dev/null @@ -1,19 +0,0 @@ -// +build !go1.9 - -package test - -import "testing" - -// Helperer marks the current function as a test helper. -type Helperer interface { - Helper() -} - -type fakeHelper struct{} - -func (fakeHelper) Helper() {} - -// Helper returns a function that marks the current function as a helper function. -func Helper(t testing.TB) Helperer { - return fakeHelper{} -}