a few code simplifications

ran gosimple over the code and made suggested adjustments
This commit is contained in:
John Eikenberry 2018-02-15 11:17:19 -08:00
parent 9649a986f0
commit 161bbaf9a8
4 changed files with 4 additions and 4 deletions

View File

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

View File

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

View File

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

View File

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