diff main.go server.go --- main.go +++ server.go @@ -1,11 +1,22 @@ package main -import "fmt" - +import ( + "fmt" + "net/http" + "os" +) + +// sayHello greets whoever is passed in as an argument. func sayHello(to string) string { return "hello " + to + "!" } func main() { + if os.Getenv("DEBUG") == "1" { fmt.Println(sayHello("world")) + } + http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { + w.Write([]byte(sayHello("internet"))) + }) + panic(http.ListenAndServe(":8080", nil)) }