Http: superfluous response.WriteHeader call

Calling w.Write requires http status code to be set before otherwise it sets default StatusOK. Setting status code multiple times throws superfluous log.
. You may better look for chunked transfer-encoding with http.Flusher.

package main

import (
	"io/ioutil"
	"log"
	"net/http"
	"path"
)

func main() {
	http.HandleFunc("/files", streamFiles)
	err := http.ListenAndServe(":8090", nil)
	if err != nil {
		log.Fatal(err)
	}
}
func streamFiles(w http.ResponseWriter, r *http.Request) {
	files, err := ioutil.ReadDir("./files")
	if err != nil {
		log.Fatal(err)
	}
	flusher, ok := w.(http.Flusher)
	if !ok {
		http.NotFound(w, r)
		return
	}

	w.Header().Set("Transfer-Encoding", "chunked")
	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(http.StatusOK)

	for _, f := range files {
		buf, err := ioutil.ReadFile(path.Join("./files", f.Name()))
		if err != nil {
			log.Fatal(err)
		}
		w.Write(buf)
		flusher.Flush()
	}
}

https://play.golang.org/p/H2si4NdtmWa