Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions serving/samples/helloworld-go/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Hello World - Go sample

A simple web app written in Go that you can use for testing.
It reads in an env variable `TARGET` and prints "Hello World: ${TARGET}!". If
TARGET is not specified, it will use "NOT SPECIFIED" as the TARGET.
It reads in an env variable `TARGET` and prints "Hello ${TARGET}!". If
TARGET is not specified, it will use "World" as the TARGET.

## Prerequisites

Expand Down Expand Up @@ -42,11 +42,16 @@ following instructions recreate the source files from this folder.
}

func main() {
flag.Parse()
log.Print("Hello world sample started.")

http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)

port := os.Getenv("PORT")
if port == "" {
port = "8080"
}

log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
}
```

Expand Down
8 changes: 7 additions & 1 deletion serving/samples/helloworld-go/helloworld.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,11 @@ func main() {
log.Print("Hello world sample started.")

http.HandleFunc("/", handler)
http.ListenAndServe(":8080", nil)

port := os.Getenv("PORT")
if port == "" {
port = "8080"
}

log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
}