Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go mod: migrating from dep to go modules #949

Merged
merged 1 commit into from
Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ go:
sudo: false

install:
- go get -u github.com/golang/dep/cmd/dep
&& dep ensure -vendor-only -v
- make vendor

script:
- make check
33 changes: 6 additions & 27 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,17 @@ This section describes how to build Contour from source.

1. *Install Go*

Contour requires [Go 1.9][1] or later.
Contour requires [Go 1.12][1] or later.
We also assume that you're familiar with Go's [`GOPATH` workspace][3] convention, and have the appropriate environment variables set.

2. *Install `dep`*

Contour uses [`dep`][2] for dependency management.
`dep` is a fast moving project so even if you have installed it previously, it's a good idea to update to the latest version using the `go get -u` flag.

```
go get -u github.com/golang/dep/cmd/dep
```
### Fetch the source

Contour uses [`dep`][2] for dependency management, but to reduce the size of the repository, does not include a copy of its dependencies.
This might change in the future, but for now use the following command to fetch the source for Contour and its dependencies.
Contour uses [`go modules`][2] for dependency management, but to reduce the size of the repository, does not include a copy of its dependencies.

```
go get -d github.com/heptio/contour
cd $GOPATH/src/github.com/heptio/contour
dep ensure -vendor-only
go mod vendor
```

Go is very particular when it comes to the location of the source code in your `$GOPATH`.
Expand All @@ -53,16 +43,10 @@ The remainder of this document assumes your terminal's working directory is `$GO
To build Contour, run:

```
go build ./cmd/contour
go build -mod=vendor ./cmd/contour
```

This assumes your working directory is set to `$GOPATH/src/github.com/heptio/contour`.
If you're somewhere else in the file system you can instead run:
```
go build github.com/heptio/contour/cmd/contour
```
This produces a `contour` binary in your current working directory.

_TIP_: You may prefer to use `go install` rather than `go build` to cache build artifacts and reduce future compile times.
Expand All @@ -73,15 +57,10 @@ In this case the binary is placed in `$GOPATH/bin/contour`.
Once you have Contour building, you can run all the unit tests for the project:

```
go test ./...
go test -mod=vendor ./...
```

This assumes your working directory is set to `$GOPATH/src/github.com/heptio/contour`.
If you're working from a different directory, you can instead run:
```
go test github.com/heptio/contour/...
```

To run the tests for a single package, change to package directory and run:

Expand Down Expand Up @@ -182,7 +161,7 @@ By making a contribution to this project, I certify that:
```

[1]: https://golang.org/dl/
[2]: https://github.com/golang/dep
[2]: https://github.com/golang/go/wiki/Modules
[3]: https://golang.org/doc/code.html
[4]: https://golang.org/pkg/testing/
[5]: https://developercertificate.org/
Expand Down
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
FROM golang:1.12.1 AS build
WORKDIR /go/src/github.com/heptio/contour

RUN go get github.com/golang/dep/cmd/dep
COPY Gopkg.toml Gopkg.lock ./
RUN dep ensure -v -vendor-only
ENV GO111MODULE on
ENV GOFLAGS -mod=vendor
COPY go.mod go.sum ./

COPY cmd cmd
COPY internal internal
COPY apis apis
RUN go mod vendor
RUN CGO_ENABLED=0 GOOS=linux GOFLAGS=-ldflags=-w go build -o /go/bin/contour -ldflags=-s -v github.com/heptio/contour/cmd/contour

FROM scratch AS final
Expand Down
Loading