Skip to content

Instantly share code, notes, and snippets.

@percybolmer
Last active September 18, 2021 05:57
Show Gist options
  • Select an option

  • Save percybolmer/982082277f0ee36b93f909a1370eafc8 to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

There is a missing " at line 17

@lukipedio

Copy link
Copy Markdown

Missing import "log" ?

@percybolmer

Copy link
Copy Markdown
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