File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
serving/samples/helloworld-go Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -42,11 +42,16 @@ following instructions recreate the source files from this folder.
4242 }
4343
4444 func main () {
45- flag.Parse ()
4645 log.Print (" Hello world sample started." )
4746
4847 http.HandleFunc (" /" , handler)
49- http.ListenAndServe (" :8080" , nil )
48+
49+ port := os.Getenv (" PORT" )
50+ if port == " " {
51+ port = " 8080"
52+ }
53+
54+ log.Fatal (http.ListenAndServe (fmt.Sprintf (" :%s " , port), nil ))
5055 }
5156 ```
5257
Original file line number Diff line number Diff line change @@ -36,5 +36,11 @@ func main() {
3636 log .Print ("Hello world sample started." )
3737
3838 http .HandleFunc ("/" , handler )
39- http .ListenAndServe (":8080" , nil )
39+
40+ port := os .Getenv ("PORT" )
41+ if port == "" {
42+ port = "8080"
43+ }
44+
45+ log .Fatal (http .ListenAndServe (fmt .Sprintf (":%s" , port ), nil ))
4046}
You can’t perform that action at this time.
0 commit comments