Skip to content

Instantly share code, notes, and snippets.

@jessfraz
Last active April 1, 2016 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jessfraz/fabbda1eeff44d5d97aced2fb65a928d to your computer and use it in GitHub Desktop.
Save jessfraz/fabbda1eeff44d5d97aced2fb65a928d to your computer and use it in GitHub Desktop.
simple hello world
Makefile
.git
.gitignore
###Go###
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
*.swo
*.swp
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
###OSX###
.DS_Store
.AppleDouble
.LSOverride
# Icon must ends with two \r.
Icon
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
hello
FROM scratch
COPY hello /hello
CMD ["/hello"]
package main
import (
"fmt"
"log"
"net/http"
"os"
)
const defaultPort = "8080"
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello DCOS!")
}
func main() {
port := os.Getenv("PORT0")
if port == "" {
port = defaultPort
}
http.HandleFunc("/", handler)
log.Println("Starting server on port: ", port)
http.ListenAndServe(":"+port, nil)
}
all: hello
hello:
CGO_ENABLED=0 go build -tags "$(BUILDTAGS) static_build" -ldflags "-w -extldflags -static" -o hello .
docker: hello
docker build --rm --force-rm -t jess/hello .
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment