Skip to content

Commit 24f0ab8

Browse files
committed
reformat code
1 parent bd9a7d5 commit 24f0ab8

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

src/main/main.go

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,27 @@ package main
22

33
import (
44
"io"
5+
"log"
56
"net/http"
67
"os"
78
)
89

10+
const Hello = "Hello, YOLO!"
11+
912
func 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

1820
func 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
}

0 commit comments

Comments
 (0)