Created
February 6, 2018 01:22
-
-
Save nictuku/47297939ba47ac1c84d9f4b502edf654 to your computer and use it in GitHub Desktop.
Example Golang HTTP Server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
) | |
type helloWorldHandler struct{} | |
func (h helloWorldHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprintf(w, "Hello, World") | |
} | |
func main() { | |
err := http.ListenAndServe(":8080", helloWorldHandler{}) | |
log.Fatal("HelloWorld ListenAndServe error", err) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment