From be54fd8f70b9c3f4fd55d519b7358ae2c03b3cec Mon Sep 17 00:00:00 2001
From: Nick Craig-Wood <nick@craig-wood.com>
Date: Fri, 6 Apr 2018 20:33:51 +0100
Subject: [PATCH] Remove builds conditional on go1.7 since that is now
 guaranteed #2154

Old fallback code was deleted and the go1.7 style code inlined where
appropriate.
---
 backend/azureblob/azureblob.go             |  3 --
 backend/azureblob/azureblob_test.go        |  3 --
 backend/azureblob/azureblob_unsupported.go |  6 ----
 backend/cache/cache.go                     |  2 +-
 backend/cache/cache_internal_test.go       |  2 +-
 backend/cache/cache_mount_unix_test.go     |  2 +-
 backend/cache/cache_mount_windows_test.go  |  2 +-
 backend/cache/cache_test.go                |  2 +-
 backend/cache/cache_unsupported.go         |  2 +-
 backend/cache/directory.go                 |  2 +-
 backend/cache/handle.go                    |  2 +-
 backend/cache/object.go                    |  2 +-
 backend/cache/plex.go                      |  2 +-
 backend/cache/storage_memory.go            |  2 +-
 backend/cache/storage_persistent.go        |  2 +-
 backend/dropbox/dropbox.go                 |  3 --
 backend/dropbox/dropbox_test.go            |  3 --
 backend/dropbox/dropbox_unsupported.go     |  6 ----
 backend/http/http.go                       |  3 --
 backend/http/http_unsupported.go           |  6 ----
 backend/qingstor/qingstor.go               |  2 +-
 backend/qingstor/qingstor_test.go          |  2 +-
 backend/qingstor/qingstor_unsupported.go   |  2 +-
 backend/qingstor/upload.go                 |  2 +-
 cmd/cachestats/cachestats.go               |  2 +-
 cmd/cachestats/cachestats_unsupported.go   |  2 +-
 cmd/serve/restic/restic_appendonly_test.go |  2 --
 fs/fshttp/http.go                          | 22 ++++++++++-----
 fs/fshttp/http_new.go                      | 33 ----------------------
 fs/fshttp/http_old.go                      | 29 -------------------
 fs/fshttp/http_test.go                     |  2 --
 fs/rc/rc.go                                |  8 ++++++
 fs/rc/rc_new.go                            | 15 ----------
 fs/rc/rc_old.go                            | 14 ---------
 fstest/fstests/gen_tests.go                |  8 +++---
 35 files changed, 45 insertions(+), 157 deletions(-)
 delete mode 100644 backend/azureblob/azureblob_unsupported.go
 delete mode 100644 backend/dropbox/dropbox_unsupported.go
 delete mode 100644 backend/http/http_unsupported.go
 delete mode 100644 fs/fshttp/http_new.go
 delete mode 100644 fs/fshttp/http_old.go
 delete mode 100644 fs/rc/rc_new.go
 delete mode 100644 fs/rc/rc_old.go

diff --git a/backend/azureblob/azureblob.go b/backend/azureblob/azureblob.go
index 6b4f6b8e8..96db542b7 100644
--- a/backend/azureblob/azureblob.go
+++ b/backend/azureblob/azureblob.go
@@ -1,7 +1,4 @@
 // Package azureblob provides an interface to the Microsoft Azure blob object storage system
-
-// +build go1.7
-
 package azureblob
 
 import (
diff --git a/backend/azureblob/azureblob_test.go b/backend/azureblob/azureblob_test.go
index 5082ab292..8b9a3ef7d 100644
--- a/backend/azureblob/azureblob_test.go
+++ b/backend/azureblob/azureblob_test.go
@@ -2,9 +2,6 @@
 //
 // Automatically generated - DO NOT EDIT
 // Regenerate with: make gen_tests
-
-// +build go1.7
-
 package azureblob_test
 
 import (
diff --git a/backend/azureblob/azureblob_unsupported.go b/backend/azureblob/azureblob_unsupported.go
deleted file mode 100644
index 178345ca3..000000000
--- a/backend/azureblob/azureblob_unsupported.go
+++ /dev/null
@@ -1,6 +0,0 @@
-// Build for unsupported platforms to stop go complaining
-// about "no buildable Go source files "
-
-// +build !go1.7
-
-package azureblob
diff --git a/backend/cache/cache.go b/backend/cache/cache.go
index 06cfcbf75..da180d902 100644
--- a/backend/cache/cache.go
+++ b/backend/cache/cache.go
@@ -1,4 +1,4 @@
-// +build !plan9,go1.7
+// +build !plan9
 
 package cache
 
diff --git a/backend/cache/cache_internal_test.go b/backend/cache/cache_internal_test.go
index 2ff738792..862b24e78 100644
--- a/backend/cache/cache_internal_test.go
+++ b/backend/cache/cache_internal_test.go
@@ -1,4 +1,4 @@
-// +build !plan9,go1.7
+// +build !plan9
 
 package cache_test
 
diff --git a/backend/cache/cache_mount_unix_test.go b/backend/cache/cache_mount_unix_test.go
index dfc478d52..7ebb17a8a 100644
--- a/backend/cache/cache_mount_unix_test.go
+++ b/backend/cache/cache_mount_unix_test.go
@@ -1,4 +1,4 @@
-// +build !plan9,!windows,go1.7
+// +build !plan9,!windows
 
 package cache_test
 
diff --git a/backend/cache/cache_mount_windows_test.go b/backend/cache/cache_mount_windows_test.go
index b0f16e49e..44c619a71 100644
--- a/backend/cache/cache_mount_windows_test.go
+++ b/backend/cache/cache_mount_windows_test.go
@@ -1,4 +1,4 @@
-// +build windows,go1.7
+// +build windows
 
 package cache_test
 
diff --git a/backend/cache/cache_test.go b/backend/cache/cache_test.go
index ba292d7c1..c1d207428 100644
--- a/backend/cache/cache_test.go
+++ b/backend/cache/cache_test.go
@@ -3,7 +3,7 @@
 // Automatically generated - DO NOT EDIT
 // Regenerate with: make gen_tests
 
-// +build !plan9,go1.7
+// +build !plan9
 
 package cache_test
 
diff --git a/backend/cache/cache_unsupported.go b/backend/cache/cache_unsupported.go
index 05dcf992b..05a39fa8b 100644
--- a/backend/cache/cache_unsupported.go
+++ b/backend/cache/cache_unsupported.go
@@ -1,6 +1,6 @@
 // Build for cache for unsupported platforms to stop go complaining
 // about "no buildable Go source files "
 
-// +build plan9 !go1.7
+// +build plan9
 
 package cache
diff --git a/backend/cache/directory.go b/backend/cache/directory.go
index b429ae7a7..658dbda72 100644
--- a/backend/cache/directory.go
+++ b/backend/cache/directory.go
@@ -1,4 +1,4 @@
-// +build !plan9,go1.7
+// +build !plan9
 
 package cache
 
diff --git a/backend/cache/handle.go b/backend/cache/handle.go
index 6152c3826..26f7dc8d5 100644
--- a/backend/cache/handle.go
+++ b/backend/cache/handle.go
@@ -1,4 +1,4 @@
-// +build !plan9,go1.7
+// +build !plan9
 
 package cache
 
diff --git a/backend/cache/object.go b/backend/cache/object.go
index 15157d500..9594333c9 100644
--- a/backend/cache/object.go
+++ b/backend/cache/object.go
@@ -1,4 +1,4 @@
-// +build !plan9,go1.7
+// +build !plan9
 
 package cache
 
diff --git a/backend/cache/plex.go b/backend/cache/plex.go
index e9e83dcfb..f5464dde4 100644
--- a/backend/cache/plex.go
+++ b/backend/cache/plex.go
@@ -1,4 +1,4 @@
-// +build !plan9,go1.7
+// +build !plan9
 
 package cache
 
diff --git a/backend/cache/storage_memory.go b/backend/cache/storage_memory.go
index f66b405e3..2ea0f8c8b 100644
--- a/backend/cache/storage_memory.go
+++ b/backend/cache/storage_memory.go
@@ -1,4 +1,4 @@
-// +build !plan9,go1.7
+// +build !plan9
 
 package cache
 
diff --git a/backend/cache/storage_persistent.go b/backend/cache/storage_persistent.go
index 75f976af5..75464bfb7 100644
--- a/backend/cache/storage_persistent.go
+++ b/backend/cache/storage_persistent.go
@@ -1,4 +1,4 @@
-// +build !plan9,go1.7
+// +build !plan9
 
 package cache
 
diff --git a/backend/dropbox/dropbox.go b/backend/dropbox/dropbox.go
index 0ec60c959..59277a6f9 100644
--- a/backend/dropbox/dropbox.go
+++ b/backend/dropbox/dropbox.go
@@ -1,7 +1,4 @@
 // Package dropbox provides an interface to Dropbox object storage
-
-// +build go1.7
-
 package dropbox
 
 // FIXME dropbox for business would be quite easy to add
diff --git a/backend/dropbox/dropbox_test.go b/backend/dropbox/dropbox_test.go
index 7db74df50..46d298484 100644
--- a/backend/dropbox/dropbox_test.go
+++ b/backend/dropbox/dropbox_test.go
@@ -2,9 +2,6 @@
 //
 // Automatically generated - DO NOT EDIT
 // Regenerate with: make gen_tests
-
-// +build go1.7
-
 package dropbox_test
 
 import (
diff --git a/backend/dropbox/dropbox_unsupported.go b/backend/dropbox/dropbox_unsupported.go
deleted file mode 100644
index 374338773..000000000
--- a/backend/dropbox/dropbox_unsupported.go
+++ /dev/null
@@ -1,6 +0,0 @@
-// Build for unsupported platforms to stop go complaining about "no
-// buildable Go source files "
-
-// +build !go1.7
-
-package dropbox
diff --git a/backend/http/http.go b/backend/http/http.go
index 93cd3e102..f289f6f2d 100644
--- a/backend/http/http.go
+++ b/backend/http/http.go
@@ -2,9 +2,6 @@
 //
 // It treats HTML pages served from the endpoint as directory
 // listings, and includes any links found as files.
-
-// +build go1.7
-
 package http
 
 import (
diff --git a/backend/http/http_unsupported.go b/backend/http/http_unsupported.go
deleted file mode 100644
index 7699b1dcf..000000000
--- a/backend/http/http_unsupported.go
+++ /dev/null
@@ -1,6 +0,0 @@
-// Build for mount for unsupported platforms to stop go complaining
-// about "no buildable Go source files "
-
-// +build !go1.7
-
-package http
diff --git a/backend/qingstor/qingstor.go b/backend/qingstor/qingstor.go
index fa02b4ea0..e8c7cb159 100644
--- a/backend/qingstor/qingstor.go
+++ b/backend/qingstor/qingstor.go
@@ -1,7 +1,7 @@
 // Package qingstor provides an interface to QingStor object storage
 // Home: https://www.qingcloud.com/
 
-// +build !plan9,go1.7
+// +build !plan9
 
 package qingstor
 
diff --git a/backend/qingstor/qingstor_test.go b/backend/qingstor/qingstor_test.go
index 7c0880e13..78d416a20 100644
--- a/backend/qingstor/qingstor_test.go
+++ b/backend/qingstor/qingstor_test.go
@@ -3,7 +3,7 @@
 // Automatically generated - DO NOT EDIT
 // Regenerate with: make gen_tests
 
-// +build !plan9,go1.7
+// +build !plan9
 
 package qingstor_test
 
diff --git a/backend/qingstor/qingstor_unsupported.go b/backend/qingstor/qingstor_unsupported.go
index 93940147e..a2980237a 100644
--- a/backend/qingstor/qingstor_unsupported.go
+++ b/backend/qingstor/qingstor_unsupported.go
@@ -1,6 +1,6 @@
 // Build for unsupported platforms to stop go complaining
 // about "no buildable Go source files "
 
-// +build plan9 !go1.7
+// +build plan9
 
 package qingstor
diff --git a/backend/qingstor/upload.go b/backend/qingstor/upload.go
index c5a9f4ca7..032e4357e 100644
--- a/backend/qingstor/upload.go
+++ b/backend/qingstor/upload.go
@@ -1,6 +1,6 @@
 // Upload object to QingStor
 
-// +build !plan9,go1.7
+// +build !plan9
 
 package qingstor
 
diff --git a/cmd/cachestats/cachestats.go b/cmd/cachestats/cachestats.go
index 617ef1253..faea3e639 100644
--- a/cmd/cachestats/cachestats.go
+++ b/cmd/cachestats/cachestats.go
@@ -1,4 +1,4 @@
-// +build !plan9,go1.7
+// +build !plan9
 
 package cachestats
 
diff --git a/cmd/cachestats/cachestats_unsupported.go b/cmd/cachestats/cachestats_unsupported.go
index 92345203d..aded32895 100644
--- a/cmd/cachestats/cachestats_unsupported.go
+++ b/cmd/cachestats/cachestats_unsupported.go
@@ -1,6 +1,6 @@
 // Build for cache for unsupported platforms to stop go complaining
 // about "no buildable Go source files "
 
-// +build plan9 !go1.7
+// +build plan9
 
 package cachestats
diff --git a/cmd/serve/restic/restic_appendonly_test.go b/cmd/serve/restic/restic_appendonly_test.go
index dc9fa930b..00aa4092d 100644
--- a/cmd/serve/restic/restic_appendonly_test.go
+++ b/cmd/serve/restic/restic_appendonly_test.go
@@ -1,5 +1,3 @@
-// +build go1.7
-
 package restic
 
 import (
diff --git a/fs/fshttp/http.go b/fs/fshttp/http.go
index 516a75165..9566d58f8 100644
--- a/fs/fshttp/http.go
+++ b/fs/fshttp/http.go
@@ -108,6 +108,16 @@ func setDefaults(a, b interface{}) {
 	}
 }
 
+// dial with context and timeouts
+func dialContextTimeout(ctx context.Context, network, address string, ci *fs.ConfigInfo) (net.Conn, error) {
+	dialer := NewDialer(ci)
+	c, err := dialer.DialContext(ctx, network, address)
+	if err != nil {
+		return c, err
+	}
+	return newTimeoutConn(c, ci.Timeout)
+}
+
 // NewTransport returns an http.RoundTripper with the correct timeouts
 func NewTransport(ci *fs.ConfigInfo) http.RoundTripper {
 	noTransport.Do(func() {
@@ -121,13 +131,11 @@ func NewTransport(ci *fs.ConfigInfo) http.RoundTripper {
 		t.ResponseHeaderTimeout = ci.Timeout
 		t.TLSClientConfig = &tls.Config{InsecureSkipVerify: ci.InsecureSkipVerify}
 		t.DisableCompression = ci.NoGzip
-		// Set in http_old.go initTransport
-		//   t.Dial
-		// Set in http_new.go initTransport
-		//   t.DialContext
-		//   t.IdelConnTimeout
-		//   t.ExpectContinueTimeout
-		initTransport(ci, t)
+		t.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
+			return dialContextTimeout(ctx, network, addr, ci)
+		}
+		t.IdleConnTimeout = 60 * time.Second
+		t.ExpectContinueTimeout = ci.ConnectTimeout
 		// Wrap that http.Transport in our own transport
 		transport = newTransport(ci, t)
 	})
diff --git a/fs/fshttp/http_new.go b/fs/fshttp/http_new.go
deleted file mode 100644
index 3726524af..000000000
--- a/fs/fshttp/http_new.go
+++ /dev/null
@@ -1,33 +0,0 @@
-// HTTP parts go1.7+
-
-//+build go1.7
-
-package fshttp
-
-import (
-	"context"
-	"net"
-	"net/http"
-	"time"
-
-	"github.com/ncw/rclone/fs"
-)
-
-// dial with context and timeouts
-func dialContextTimeout(ctx context.Context, network, address string, ci *fs.ConfigInfo) (net.Conn, error) {
-	dialer := NewDialer(ci)
-	c, err := dialer.DialContext(ctx, network, address)
-	if err != nil {
-		return c, err
-	}
-	return newTimeoutConn(c, ci.Timeout)
-}
-
-// Initialise the http.Transport for go1.7+
-func initTransport(ci *fs.ConfigInfo, t *http.Transport) {
-	t.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {
-		return dialContextTimeout(ctx, network, addr, ci)
-	}
-	t.IdleConnTimeout = 60 * time.Second
-	t.ExpectContinueTimeout = ci.ConnectTimeout
-}
diff --git a/fs/fshttp/http_old.go b/fs/fshttp/http_old.go
deleted file mode 100644
index 86ac3616d..000000000
--- a/fs/fshttp/http_old.go
+++ /dev/null
@@ -1,29 +0,0 @@
-// HTTP parts pre go1.7
-
-//+build !go1.7
-
-package fshttp
-
-import (
-	"net"
-	"net/http"
-
-	"github.com/ncw/rclone/fs"
-)
-
-// dial with timeouts
-func dialTimeout(network, address string, ci *fs.ConfigInfo) (net.Conn, error) {
-	dialer := NewDialer(ci)
-	c, err := dialer.Dial(network, address)
-	if err != nil {
-		return c, err
-	}
-	return newTimeoutConn(c, ci.Timeout)
-}
-
-// Initialise the http.Transport for pre go1.7
-func initTransport(ci *fs.ConfigInfo, t *http.Transport) {
-	t.Dial = func(network, addr string) (net.Conn, error) {
-		return dialTimeout(network, addr, ci)
-	}
-}
diff --git a/fs/fshttp/http_test.go b/fs/fshttp/http_test.go
index def673737..724564941 100644
--- a/fs/fshttp/http_test.go
+++ b/fs/fshttp/http_test.go
@@ -1,5 +1,3 @@
-//+build go1.7
-
 package fshttp
 
 import (
diff --git a/fs/rc/rc.go b/fs/rc/rc.go
index 4ca73ff6f..fa73cb45f 100644
--- a/fs/rc/rc.go
+++ b/fs/rc/rc.go
@@ -9,6 +9,7 @@ package rc
 
 import (
 	"encoding/json"
+	"io"
 	"net/http"
 	"strings"
 
@@ -66,6 +67,13 @@ func (s *server) serve() {
 	s.srv.Wait()
 }
 
+// WriteJSON writes JSON in out to w
+func WriteJSON(w io.Writer, out Params) error {
+	enc := json.NewEncoder(w)
+	enc.SetIndent("", "\t")
+	return enc.Encode(out)
+}
+
 // handler reads incoming requests and dispatches them
 func (s *server) handler(w http.ResponseWriter, r *http.Request) {
 	path := strings.Trim(r.URL.Path, "/")
diff --git a/fs/rc/rc_new.go b/fs/rc/rc_new.go
deleted file mode 100644
index 32c988001..000000000
--- a/fs/rc/rc_new.go
+++ /dev/null
@@ -1,15 +0,0 @@
-//+build go1.7
-
-package rc
-
-import (
-	"encoding/json"
-	"io"
-)
-
-// WriteJSON writes JSON in out to w
-func WriteJSON(w io.Writer, out Params) error {
-	enc := json.NewEncoder(w)
-	enc.SetIndent("", "\t")
-	return enc.Encode(out)
-}
diff --git a/fs/rc/rc_old.go b/fs/rc/rc_old.go
deleted file mode 100644
index 1ce9f6184..000000000
--- a/fs/rc/rc_old.go
+++ /dev/null
@@ -1,14 +0,0 @@
-//+build !go1.7
-
-package rc
-
-import (
-	"encoding/json"
-	"io"
-)
-
-// WriteJSON writes JSON in out to w
-func WriteJSON(w io.Writer, out Params) error {
-	enc := json.NewEncoder(w)
-	return enc.Encode(out)
-}
diff --git a/fstest/fstests/gen_tests.go b/fstest/fstests/gen_tests.go
index f1dbc9658..4f4010cda 100644
--- a/fstest/fstests/gen_tests.go
+++ b/fstest/fstests/gen_tests.go
@@ -150,7 +150,7 @@ func main() {
 	generateTestProgram(t, fns, "S3")
 	generateTestProgram(t, fns, "Drive")
 	generateTestProgram(t, fns, "GoogleCloudStorage")
-	generateTestProgram(t, fns, "Dropbox", buildConstraint("go1.7"))
+	generateTestProgram(t, fns, "Dropbox")
 	generateTestProgram(t, fns, "AmazonCloudDrive", buildConstraint("acd"))
 	generateTestProgram(t, fns, "OneDrive")
 	generateTestProgram(t, fns, "Hubic")
@@ -162,10 +162,10 @@ func main() {
 	generateTestProgram(t, fns, "Sftp", buildConstraint("!plan9,go1.8"))
 	generateTestProgram(t, fns, "FTP")
 	generateTestProgram(t, fns, "Box")
-	generateTestProgram(t, fns, "QingStor", buildConstraint("!plan9,go1.7"))
-	generateTestProgram(t, fns, "AzureBlob", buildConstraint("go1.7"))
+	generateTestProgram(t, fns, "QingStor", buildConstraint("!plan9"))
+	generateTestProgram(t, fns, "AzureBlob")
 	generateTestProgram(t, fns, "Pcloud")
 	generateTestProgram(t, fns, "Webdav")
-	generateTestProgram(t, fns, "Cache", buildConstraint("!plan9,go1.7"))
+	generateTestProgram(t, fns, "Cache", buildConstraint("!plan9"))
 	log.Printf("Done")
 }