docker build -t go-example .
docker run -it go-example
Created
December 8, 2017 21:54
-
-
Save jspooner/68302d1ed6a633d7226d2867a8e76092 to your computer and use it in GitHub Desktop.
GoLang Docker Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM golang:latest | |
RUN mkdir /app | |
ADD . /app/ | |
WORKDIR /app | |
RUN go build -o main . | |
CMD ["/app/main"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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