diff --git a/main.go b/main.go index 6e0cab4..4b6ccb6 100644 --- a/main.go +++ b/main.go @@ -74,7 +74,7 @@ func (w *response) WriteStatus(code int, meta string) (int, error) { w.status = code w.meta = meta 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) { @@ -110,9 +110,11 @@ func genIndex(folder, rel string) ([]byte, error) { if err != nil { 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 { - 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 }