()
| 11 | ) |
| 12 | |
| 13 | func main() { |
| 14 | port := 8080 |
| 15 | if strValue, ok := os.LookupEnv("PORT"); ok { |
| 16 | if intValue, err := strconv.Atoi(strValue); err == nil { |
| 17 | port = intValue |
| 18 | } |
| 19 | } |
| 20 | |
| 21 | http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { |
| 22 | fmt.Fprintf(w, "Hello, World! I am using %s by the way.", runtime.Version()) |
| 23 | }) |
| 24 | |
| 25 | http.ListenAndServe(fmt.Sprintf(":%d", port), nil) |
| 26 | } |