Gofmt the project

This commit is contained in:
Michail Kargakis 2020-04-10 23:50:34 +02:00
parent d66a0674ca
commit 90f4ffe95f
No known key found for this signature in database
GPG Key ID: BC06866FDEE7F397
6 changed files with 52 additions and 53 deletions

View File

@ -96,10 +96,10 @@ func TestNestedBasePaths(t *testing.T) {
Dir1, Dir2, Dir3 string Dir1, Dir2, Dir3 string
} }
dirSpecs := []dirSpec{ dirSpecs := []dirSpec{
dirSpec{Dir1: "/", Dir2: "/", Dir3: "/"}, {Dir1: "/", Dir2: "/", Dir3: "/"},
dirSpec{Dir1: "/", Dir2: "/path2", Dir3: "/"}, {Dir1: "/", Dir2: "/path2", Dir3: "/"},
dirSpec{Dir1: "/path1/dir", Dir2: "/path2/dir/", Dir3: "/path3/dir"}, {Dir1: "/path1/dir", Dir2: "/path2/dir/", Dir3: "/path3/dir"},
dirSpec{Dir1: "C:/path1", Dir2: "path2/dir", Dir3: "/path3/dir/"}, {Dir1: "C:/path1", Dir2: "path2/dir", Dir3: "/path3/dir/"},
} }
for _, ds := range dirSpecs { for _, ds := range dirSpecs {
@ -113,9 +113,9 @@ func TestNestedBasePaths(t *testing.T) {
FileName string FileName string
} }
specs := []spec{ specs := []spec{
spec{BaseFs: level3Fs, FileName: "f.txt"}, {BaseFs: level3Fs, FileName: "f.txt"},
spec{BaseFs: level2Fs, FileName: "f.txt"}, {BaseFs: level2Fs, FileName: "f.txt"},
spec{BaseFs: level1Fs, FileName: "f.txt"}, {BaseFs: level1Fs, FileName: "f.txt"},
} }
for _, s := range specs { for _, s := range specs {

View File

@ -172,7 +172,6 @@ func TestGlobSymlink(t *testing.T) {
} }
} }
func TestGlobError(t *testing.T) { func TestGlobError(t *testing.T) {
for _, fs := range Fss { for _, fs := range Fss {
_, err := Glob(fs, "[7]") _, err := Glob(fs, "[7]")

View File

@ -269,7 +269,7 @@ func (m *MemMapFs) RemoveAll(path string) error {
m.mu.RLock() m.mu.RLock()
defer m.mu.RUnlock() defer m.mu.RUnlock()
for p, _ := range m.getData() { for p := range m.getData() {
if strings.HasPrefix(p, path) { if strings.HasPrefix(p, path) {
m.mu.RUnlock() m.mu.RUnlock()
m.mu.Lock() m.mu.Lock()

View File

@ -14,21 +14,21 @@
package sftpfs package sftpfs
import ( import (
"testing"
"os"
"log"
"fmt"
"net"
"flag"
"time"
"io/ioutil"
"crypto/rsa"
_rand "crypto/rand" _rand "crypto/rand"
"encoding/pem" "crypto/rsa"
"crypto/x509" "crypto/x509"
"encoding/pem"
"flag"
"fmt"
"io/ioutil"
"log"
"net"
"os"
"testing"
"time"
"golang.org/x/crypto/ssh"
"github.com/pkg/sftp" "github.com/pkg/sftp"
"golang.org/x/crypto/ssh"
) )
type SftpFsContext struct { type SftpFsContext struct {
@ -40,25 +40,25 @@ type SftpFsContext struct {
// TODO we only connect with hardcoded user+pass for now // TODO we only connect with hardcoded user+pass for now
// it should be possible to use $HOME/.ssh/id_rsa to login into the stub sftp server // it should be possible to use $HOME/.ssh/id_rsa to login into the stub sftp server
func SftpConnect(user, password, host string) (*SftpFsContext, error) { func SftpConnect(user, password, host string) (*SftpFsContext, error) {
/* /*
pemBytes, err := ioutil.ReadFile(os.Getenv("HOME") + "/.ssh/id_rsa") pemBytes, err := ioutil.ReadFile(os.Getenv("HOME") + "/.ssh/id_rsa")
if err != nil { if err != nil {
return nil,err return nil,err
} }
signer, err := ssh.ParsePrivateKey(pemBytes) signer, err := ssh.ParsePrivateKey(pemBytes)
if err != nil { if err != nil {
return nil,err return nil,err
} }
sshcfg := &ssh.ClientConfig{ sshcfg := &ssh.ClientConfig{
User: user, User: user,
Auth: []ssh.AuthMethod{ Auth: []ssh.AuthMethod{
ssh.Password(password), ssh.Password(password),
ssh.PublicKeys(signer), ssh.PublicKeys(signer),
}, },
} }
*/ */
sshcfg := &ssh.ClientConfig{ sshcfg := &ssh.ClientConfig{
User: user, User: user,
@ -70,21 +70,21 @@ func SftpConnect(user, password, host string) (*SftpFsContext, error) {
sshc, err := ssh.Dial("tcp", host, sshcfg) sshc, err := ssh.Dial("tcp", host, sshcfg)
if err != nil { if err != nil {
return nil,err return nil, err
} }
sftpc, err := sftp.NewClient(sshc) sftpc, err := sftp.NewClient(sshc)
if err != nil { if err != nil {
return nil,err return nil, err
} }
ctx := &SftpFsContext{ ctx := &SftpFsContext{
sshc: sshc, sshc: sshc,
sshcfg: sshcfg, sshcfg: sshcfg,
sftpc: sftpc, sftpc: sftpc,
} }
return ctx,nil return ctx, nil
} }
func (ctx *SftpFsContext) Disconnect() error { func (ctx *SftpFsContext) Disconnect() error {

View File

@ -415,10 +415,10 @@ func TestFullBaseFsPath(t *testing.T) {
Dir1, Dir2, Dir3 string Dir1, Dir2, Dir3 string
} }
dirSpecs := []dirSpec{ dirSpecs := []dirSpec{
dirSpec{Dir1: "/", Dir2: "/", Dir3: "/"}, {Dir1: "/", Dir2: "/", Dir3: "/"},
dirSpec{Dir1: "/", Dir2: "/path2", Dir3: "/"}, {Dir1: "/", Dir2: "/path2", Dir3: "/"},
dirSpec{Dir1: "/path1/dir", Dir2: "/path2/dir/", Dir3: "/path3/dir"}, {Dir1: "/path1/dir", Dir2: "/path2/dir/", Dir3: "/path3/dir"},
dirSpec{Dir1: "C:/path1", Dir2: "path2/dir", Dir3: "/path3/dir/"}, {Dir1: "C:/path1", Dir2: "path2/dir", Dir3: "/path3/dir/"},
} }
for _, ds := range dirSpecs { for _, ds := range dirSpecs {
@ -433,12 +433,12 @@ func TestFullBaseFsPath(t *testing.T) {
ExpectedPath string ExpectedPath string
} }
specs := []spec{ specs := []spec{
spec{BaseFs: level3Fs, FileName: "f.txt", ExpectedPath: filepath.Join(ds.Dir1, ds.Dir2, ds.Dir3, "f.txt")}, {BaseFs: level3Fs, FileName: "f.txt", ExpectedPath: filepath.Join(ds.Dir1, ds.Dir2, ds.Dir3, "f.txt")},
spec{BaseFs: level3Fs, FileName: "", ExpectedPath: filepath.Join(ds.Dir1, ds.Dir2, ds.Dir3, "")}, {BaseFs: level3Fs, FileName: "", ExpectedPath: filepath.Join(ds.Dir1, ds.Dir2, ds.Dir3, "")},
spec{BaseFs: level2Fs, FileName: "f.txt", ExpectedPath: filepath.Join(ds.Dir1, ds.Dir2, "f.txt")}, {BaseFs: level2Fs, FileName: "f.txt", ExpectedPath: filepath.Join(ds.Dir1, ds.Dir2, "f.txt")},
spec{BaseFs: level2Fs, FileName: "", ExpectedPath: filepath.Join(ds.Dir1, ds.Dir2, "")}, {BaseFs: level2Fs, FileName: "", ExpectedPath: filepath.Join(ds.Dir1, ds.Dir2, "")},
spec{BaseFs: level1Fs, FileName: "f.txt", ExpectedPath: filepath.Join(ds.Dir1, "f.txt")}, {BaseFs: level1Fs, FileName: "f.txt", ExpectedPath: filepath.Join(ds.Dir1, "f.txt")},
spec{BaseFs: level1Fs, FileName: "", ExpectedPath: filepath.Join(ds.Dir1, "")}, {BaseFs: level1Fs, FileName: "", ExpectedPath: filepath.Join(ds.Dir1, "")},
} }
for _, s := range specs { for _, s := range specs {

View File

@ -142,7 +142,7 @@ func (f *File) Readdirnames(count int) (names []string, err error) {
if err != nil { if err != nil {
return nil, err return nil, err
} }
for filename, _ := range zipfiles { for filename := range zipfiles {
names = append(names, filename) names = append(names, filename)
if count >= 0 && len(names) >= count { if count >= 0 && len(names) >= count {
break break