One way

buf := make([]byte, hdr.Size)
// read file content into buffer
fReader := bufio.NewReader(file)
fReader.Read(buf)

A better way?

buf, err := ioutil.ReadAll(file)
if err != nil {
    log.WithError(err).Error("reading file")
    http.Error(w, "Error reading file.", http.StatusInternalServerError)
    return
}
Feedback

Powered by Vanilla PHP feedback form