mirror of https://github.com/pkg/sftp.git
a few code simplifications
ran gosimple over the code and made suggested adjustments
This commit is contained in:
parent
9649a986f0
commit
161bbaf9a8
2
attrs.go
2
attrs.go
|
@ -118,7 +118,7 @@ func getFileStat(flags uint32, b []byte) (*FileStat, []byte) {
|
|||
if flags&ssh_FILEXFER_ATTR_EXTENDED == ssh_FILEXFER_ATTR_EXTENDED {
|
||||
var count uint32
|
||||
count, b = unmarshalUint32(b)
|
||||
ext := make([]StatExtended, count, count)
|
||||
ext := make([]StatExtended, count)
|
||||
for i := uint32(0); i < count; i++ {
|
||||
var typ string
|
||||
var data string
|
||||
|
|
|
@ -62,7 +62,7 @@ func newDelayedWriter(w io.WriteCloser, delay time.Duration) io.WriteCloser {
|
|||
closed := make(chan struct{})
|
||||
go func() {
|
||||
for writeMsg := range ch {
|
||||
time.Sleep(writeMsg.t.Add(delay).Sub(time.Now()))
|
||||
time.Sleep(time.Until(writeMsg.t.Add(delay)))
|
||||
n, err := w.Write(writeMsg.b)
|
||||
if err != nil {
|
||||
panic("write error")
|
||||
|
|
|
@ -139,7 +139,7 @@ func (fs *root) Filelist(r *Request) (ListerAt, error) {
|
|||
ordered_names = append(ordered_names, fn)
|
||||
}
|
||||
}
|
||||
sort.Sort(sort.StringSlice(ordered_names))
|
||||
sort.Strings(ordered_names)
|
||||
list := make([]os.FileInfo, len(ordered_names))
|
||||
for i, fn := range ordered_names {
|
||||
list[i] = fs.files[fn]
|
||||
|
|
|
@ -426,7 +426,7 @@ func runSftpClient(t *testing.T, script string, path string, host string, port i
|
|||
return "", err
|
||||
}
|
||||
err = cmd.Wait()
|
||||
return string(stdout.Bytes()), err
|
||||
return stdout.String(), err
|
||||
}
|
||||
|
||||
func TestServerCompareSubsystems(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue