Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Last active September 18, 2021 05:57
Show Gist options
  • Save percybolmer/982082277f0ee36b93f909a1370eafc8 to your computer and use it in GitHub Desktop.
Save percybolmer/982082277f0ee36b93f909a1370eafc8 to your computer and use it in GitHub Desktop.
An example hello world API
package main
import (
"fmt"
"net/http"
"os"
"log"
)
func main() {
port := fmt.Sprintf(":%s", os.Getenv("PORT"))
http.HandleFunc("/", HelloWorld)
log.Fatal(http.ListenAndServe(port, nil))
}
func HelloWorld(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello from Docker")
}
@lukipedio
Copy link

Missing import "log" ?

@percybolmer
Copy link
Author

Your right, my bad... It's now fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment