File tree Expand file tree Collapse file tree 1 file changed +7
-19
lines changed Expand file tree Collapse file tree 1 file changed +7
-19
lines changed Original file line number Diff line number Diff line change @@ -2,39 +2,27 @@ package main
22
33import (
44 "io"
5+ "log"
56 "net/http"
67 "os"
78)
89
10+ const Hello = "Hello, YOLO!"
11+
912func hello (w http.ResponseWriter , _ * http.Request ) {
1013
11- var _ , err = io .WriteString (w , " Hello, YOLO!" )
14+ if _ , err : = io .WriteString (w , Hello ); err != nil {
1215
13- if err != nil {
14- print ("hello" , err .Error ())
16+ log .Printf ("main.go:hello(): %+v" , err )
1517 }
1618}
1719
1820func main () {
1921
2022 http .HandleFunc ("/" , hello )
2123
22- var err = http .ListenAndServe (":" + getPort (), nil )
23-
24- if err != nil {
25- print ("main" , err .Error ())
26- }
27- }
28-
29- func getPort () string {
30-
31- var port = os .Getenv ("PORT" )
24+ if err := http .ListenAndServe (":" + os .Getenv ("PORT" ), nil ); err != nil {
3225
33- print ("(heroku:" + port + ")" )
34-
35- if port == "" {
36- port = "8000"
26+ log .Fatalf ("main.go:main(): %+v" , err )
3727 }
38-
39- return port
4028}
You can’t perform that action at this time.
0 commit comments