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.
This commit is contained in:
Nick Craig-Wood 2018-04-06 20:33:51 +01:00
parent e5be471ce0
commit be54fd8f70
35 changed files with 45 additions and 157 deletions

View file

@ -1,7 +1,4 @@
// Package azureblob provides an interface to the Microsoft Azure blob object storage system
// +build go1.7
package azureblob
import (

View file

@ -2,9 +2,6 @@
//
// Automatically generated - DO NOT EDIT
// Regenerate with: make gen_tests
// +build go1.7
package azureblob_test
import (

View file

@ -1,6 +0,0 @@
// Build for unsupported platforms to stop go complaining
// about "no buildable Go source files "
// +build !go1.7
package azureblob

View file

@ -1,4 +1,4 @@
// +build !plan9,go1.7
// +build !plan9
package cache

View file

@ -1,4 +1,4 @@
// +build !plan9,go1.7
// +build !plan9
package cache_test

View file

@ -1,4 +1,4 @@
// +build !plan9,!windows,go1.7
// +build !plan9,!windows
package cache_test

View file

@ -1,4 +1,4 @@
// +build windows,go1.7
// +build windows
package cache_test

View file

@ -3,7 +3,7 @@
// Automatically generated - DO NOT EDIT
// Regenerate with: make gen_tests
// +build !plan9,go1.7
// +build !plan9
package cache_test

View file

@ -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

View file

@ -1,4 +1,4 @@
// +build !plan9,go1.7
// +build !plan9
package cache

View file

@ -1,4 +1,4 @@
// +build !plan9,go1.7
// +build !plan9
package cache

View file

@ -1,4 +1,4 @@
// +build !plan9,go1.7
// +build !plan9
package cache

View file

@ -1,4 +1,4 @@
// +build !plan9,go1.7
// +build !plan9
package cache

View file

@ -1,4 +1,4 @@
// +build !plan9,go1.7
// +build !plan9
package cache

View file

@ -1,4 +1,4 @@
// +build !plan9,go1.7
// +build !plan9
package cache

View file

@ -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

View file

@ -2,9 +2,6 @@
//
// Automatically generated - DO NOT EDIT
// Regenerate with: make gen_tests
// +build go1.7
package dropbox_test
import (

View file

@ -1,6 +0,0 @@
// Build for unsupported platforms to stop go complaining about "no
// buildable Go source files "
// +build !go1.7
package dropbox

View file

@ -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 (

View file

@ -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

View file

@ -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

View file

@ -3,7 +3,7 @@
// Automatically generated - DO NOT EDIT
// Regenerate with: make gen_tests
// +build !plan9,go1.7
// +build !plan9
package qingstor_test

View file

@ -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

View file

@ -1,6 +1,6 @@
// Upload object to QingStor
// +build !plan9,go1.7
// +build !plan9
package qingstor

View file

@ -1,4 +1,4 @@
// +build !plan9,go1.7
// +build !plan9
package cachestats

View file

@ -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

View file

@ -1,5 +1,3 @@
// +build go1.7
package restic
import (

View file

@ -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)
})

View file

@ -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
}

View file

@ -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)
}
}

View file

@ -1,5 +1,3 @@
//+build go1.7
package fshttp
import (

View file

@ -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, "/")

View file

@ -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)
}

View file

@ -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)
}

View file

@ -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")
}