Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions benchmarks/golang/micro.go
Original file line number Diff line number Diff line change
@@ -1,28 +1,22 @@
package main

import (
"io"
"net/http"
)
import "net/http"

func hello(response http.ResponseWriter, request *http.Request) {
header := response.Header()
header["Date"] = nil
var (
helloResp = []byte("Hello world!")
notFoundResp = []byte("Not Found")
)

var text string
var status int
if request.URL.Path == "/" {
status = 200
text = "Hello world!"
} else {
status = 404
text = "Not Found"
}
response.WriteHeader(status)
io.WriteString(response, text)
func hello(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
w.WriteHeader(http.StatusNotFound)
w.Write(notFoundResp)
return
}
w.Write(helloResp)
}

func main() {
http.HandleFunc("/", hello)
http.ListenAndServe("0.0.0.0:8080", nil)
http.HandleFunc("/", hello)
http.ListenAndServe("0.0.0.0:8080", nil)
}