write directly to the writer, don't pass through Sprintf
This commit is contained in:
parent
352ec35890
commit
cb3282304b
8
main.go
8
main.go
@ -74,7 +74,7 @@ func (w *response) WriteStatus(code int, meta string) (int, error) {
|
|||||||
w.status = code
|
w.status = code
|
||||||
w.meta = meta
|
w.meta = meta
|
||||||
w.statusSent = true
|
w.statusSent = true
|
||||||
return w.connection.Write([]byte(fmt.Sprintf("%d %s\r\n", code, meta)))
|
return fmt.Fprintf(w.connection, "%d %s\r\n", code, meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *response) Write(b []byte) (int, error) {
|
func (w *response) Write(b []byte) (int, error) {
|
||||||
@ -110,9 +110,11 @@ func genIndex(folder, rel string) ([]byte, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return []byte{}, err
|
return []byte{}, err
|
||||||
}
|
}
|
||||||
ret := bytes.NewBuffer([]byte(fmt.Sprintf("# %s\r\n\r\n", rel)))
|
ret := bytes.NewBuffer([]byte{})
|
||||||
|
|
||||||
|
fmt.Fprintf(ret, "# %s\r\n\r\n", rel)
|
||||||
for _, file := range files {
|
for _, file := range files {
|
||||||
ret.Write([]byte(fmt.Sprintf("=> %s %s\r\n", filepath.Join(rel, file.Name()), file.Name())))
|
fmt.Fprintf(ret, "=> %s %s\r\n", filepath.Join(rel, file.Name()), file.Name())
|
||||||
}
|
}
|
||||||
return ret.Bytes(), nil
|
return ret.Bytes(), nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user