- Build the Dockerfile
docker build -t go-test .
- Run the docker image
docker run -v ${PWD}:/go/src/app go-test
| FROM golang:1.11.5-alpine3.8 | |
| WORKDIR /go/src/app | |
| VOLUME WORKDIR | |
| CMD ["go", "test"] |
| package main | |
| func add(x int, y int) int { | |
| return x + y | |
| } |
| package main | |
| import( | |
| "testing" | |
| ) | |
| func TestAddShouldReturnTheSum(t *testing.T) { | |
| want := 4 | |
| got := add(2,2) | |
| if want != got { | |
| t.Errorf("%d is not %d", want, got) | |
| } | |
| } |