Skip to content

Instantly share code, notes, and snippets.

@jspooner
Created December 8, 2017 21:54
Show Gist options
  • Save jspooner/68302d1ed6a633d7226d2867a8e76092 to your computer and use it in GitHub Desktop.
Save jspooner/68302d1ed6a633d7226d2867a8e76092 to your computer and use it in GitHub Desktop.
GoLang Docker Example

GoLang Docker Example

docker build -t go-example .
docker run -it go-example
FROM golang:latest
RUN mkdir /app
ADD . /app/
WORKDIR /app
RUN go build -o main .
CMD ["/app/main"]
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
)
func main() {
fmt.Println("vim-go")
resp, err := http.Get("https://jonathanspooner.com")
check(err)
body, err := ioutil.ReadAll(resp.Body)
check(err)
fmt.Println(len(body))
}
func check(err error) {
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment