Skip to content

Instantly share code, notes, and snippets.

@deepakshrma
Last active January 6, 2020 17:03
Show Gist options
  • Save deepakshrma/869f9c848c625760b4f17ccf5b886429 to your computer and use it in GitHub Desktop.
Save deepakshrma/869f9c848c625760b4f17ccf5b886429 to your computer and use it in GitHub Desktop.
package main
import (
"io"
"net/http"
"os"
)
func check(e error) {
if e != nil {
panic(e)
}
}
func main() {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
// t := time.Now()
f, err := os.Open("./test1.txt")
check(err)
defer f.Close()
// w.Write([]byte("Tets"))
_, err = io.Copy(w, f)
// fmt.Printf("Time: %d", time.Since(t).Milliseconds())
check(err)
})
http.ListenAndServe(":8081", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment