From 74687c25f55a68583e0f8bf6d9c97a4b9c6f5c2f Mon Sep 17 00:00:00 2001 From: Nick Craig-Wood Date: Mon, 7 Aug 2017 14:50:31 +0100 Subject: [PATCH] sftp: fixup formatting and golint warnings --- sftp/sftp.go | 9 ++++++--- sftp/sftp_internal_test.go | 5 +++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/sftp/sftp.go b/sftp/sftp.go index 966db9b12..d67948c4e 100644 --- a/sftp/sftp.go +++ b/sftp/sftp.go @@ -9,6 +9,8 @@ import ( "io/ioutil" "os" "path" + "regexp" + "strings" "time" "github.com/ncw/rclone/fs" @@ -16,8 +18,6 @@ import ( "github.com/pkg/sftp" "github.com/xanzy/ssh-agent" "golang.org/x/crypto/ssh" - "strings" - "regexp" ) func init() { @@ -437,6 +437,7 @@ func (f *Fs) DirMove(src fs.Fs, srcRemote, dstRemote string) error { return nil } +// Hashes returns the supported hash types of the filesystem func (f *Fs) Hashes() fs.HashSet { if f.cachedHashes != nil { return *f.cachedHashes @@ -461,7 +462,7 @@ func (f *Fs) Hashes() fs.HashSet { sha1Works := parseHash(sha1Output) == expectedSha1 md5Works := parseHash(md5Output) == expectedMd5 - var set fs.HashSet = fs.NewHashSet() + set := fs.NewHashSet() if !sha1Works && !md5Works { set.Add(fs.HashNone) } @@ -495,6 +496,8 @@ func (o *Object) Remote() string { return o.remote } +// Hash returns the selected checksum of the file +// If no checksum is available it returns "" func (o *Object) Hash(r fs.HashType) (string, error) { if r == fs.HashMD5 && o.md5sum != nil { return *o.md5sum, nil diff --git a/sftp/sftp_internal_test.go b/sftp/sftp_internal_test.go index 820c4e02f..5b5f6feb3 100644 --- a/sftp/sftp_internal_test.go +++ b/sftp/sftp_internal_test.go @@ -1,9 +1,10 @@ package sftp import ( - "testing" - "github.com/stretchr/testify/assert" "fmt" + "testing" + + "github.com/stretchr/testify/assert" ) func TestShellEscape(t *testing.T) {