Skip to content

Instantly share code, notes, and snippets.

@khannedy
Created April 24, 2022 21:43
Show Gist options
  • Save khannedy/e8574fdd9bebfb433a256e7e89f1d5ca to your computer and use it in GitHub Desktop.
Save khannedy/e8574fdd9bebfb433a256e7e89f1d5ca to your computer and use it in GitHub Desktop.
Simple Go-Lang Web with Port
package main
import (
"fmt"
"net/http"
"os"
)
func main() {
port := os.Getenv("APP_PORT")
fmt.Println("Run app in port : " + port)
http.HandleFunc("/", HelloServer)
http.ListenAndServe(":" + port, nil)
}
func HelloServer(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, World!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment