Skip to content

Commit e8ee0d9

Browse files
committed
Migrate to Go modules
This migrates Dig to Go modules, which has the effect of simplifying the Makefile as well. We use the tools.go pattern to pin to versions of development tooling.
1 parent 4fb70ce commit e8ee0d9

File tree

9 files changed

+116
-68
lines changed

9 files changed

+116
-68
lines changed

.build/test.sh

Lines changed: 0 additions & 13 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/bin
12
/vendor
23
/.bench
34
*.mem

.travis.yml

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@ language: go
22
sudo: false
33
go_import_path: go.uber.org/dig
44

5+
env:
6+
global:
7+
- GO111MODULE=on
8+
59
matrix:
610
include:
7-
- go: "1.11"
811
- go: "1.12"
12+
- go: "1.13"
913
env: LINT=1
1014

11-
cache:
12-
directories:
13-
- vendor
1415
install:
15-
- make dependencies
16+
- go mod download
17+
1618
script:
17-
- test -z "$LINT" && echo "Skipping lint" || make lint
18-
- make ci
19+
- test -z "$LINT" || make lint
20+
- make test
21+
- make bench
22+
23+
after_success:
24+
- make cover
25+
- bash <(curl -s https://codecov.io/bash)

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8-
- No changes yet.
8+
### Changed
9+
- Migrated to Go modules.
910

1011
## [1.7.0] - 2019-01-04
1112
### Added

Makefile

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,57 @@
1+
export GOBIN ?= $(shell pwd)/bin
2+
13
BENCH_FLAGS ?= -cpuprofile=cpu.pprof -memprofile=mem.pprof -benchmem
2-
PKGS ?= $(shell glide novendor | grep -v examples)
3-
PKG_FILES ?= *.go
4-
GO_VERSION := $(shell go version | cut -d " " -f 3)
4+
5+
UPDATE_LICENSE = $(GOBIN)/update-license
6+
GOLINT = $(GOBIN)/golint
7+
8+
GO_FILES := $(shell \
9+
find . '(' -path '*/.*' -o -path './vendor' ')' -prune \
10+
-o -name '*.go' -print | cut -b3-)
511

612
.PHONY: all
7-
all: lint test
8-
9-
.PHONY: dependencies
10-
dependencies:
11-
@echo "Installing Glide and locked dependencies..."
12-
glide --version || go get -u -f github.com/Masterminds/glide
13-
glide install
14-
@echo "Installing uber-license tool..."
15-
command -v update-license >/dev/null || go get -u -f go.uber.org/tools/update-license
16-
@echo "Installing golint..."
17-
command -v golint >/dev/null || go get -u -f golang.org/x/lint/golint
13+
all: build lint test
14+
15+
.PHONY: build
16+
build:
17+
go build ./...
1818

1919
.PHONY: license
20-
license: dependencies
21-
./check_license.sh | tee -a lint.log
20+
license: $(UPDATE_LICENSE)
21+
PATH=$(GOBIN):$$PATH ./check_license.sh | tee -a lint.log
2222

2323
.PHONY: lint
24-
lint:
24+
lint: $(GOLINT) $(UPDATE_LICENSE)
2525
@rm -rf lint.log
2626
@echo "Checking formatting..."
27-
@gofmt -d -s $(PKG_FILES) 2>&1 | tee lint.log
28-
@echo "Installing test dependencies for vet..."
29-
@go test -i $(PKGS)
27+
@gofmt -d -s $(GO_FILES) 2>&1 | tee lint.log
3028
@echo "Checking vet..."
31-
@go vet ./...| tee -a lint.log
29+
@go vet ./... 2>&1 | tee -a lint.log
3230
@echo "Checking lint..."
33-
@$(foreach dir,$(PKGS),golint $(dir) 2>&1 | tee -a lint.log;)
31+
@$(GOLINT) ./... 2>&1 | tee -a lint.log
3432
@echo "Checking for unresolved FIXMEs..."
35-
@git grep -i fixme | grep -v -e vendor -e Makefile | tee -a lint.log
33+
@git grep -i fixme | grep -v -e Makefile | tee -a lint.log
3634
@echo "Checking for license headers..."
37-
@DRY_RUN=1 ./check_license.sh | tee -a lint.log
35+
@PATH=$(GOBIN):$$PATH DRY_RUN=1 ./check_license.sh | tee -a lint.log
3836
@[ ! -s lint.log ]
3937

38+
$(GOLINT):
39+
go install golang.org/x/lint/golint
40+
41+
$(UPDATE_LICENSE):
42+
go install go.uber.org/tools/update-license
43+
44+
4045
.PHONY: test
4146
test:
42-
@.build/test.sh
47+
go test -race ./...
4348

44-
.PHONY: ci
45-
ci: SHELL := /bin/bash
46-
ci: test
47-
bash <(curl -s https://codecov.io/bash)
49+
.PHONY: cover
50+
cover:
51+
go test -race -coverprofile=cover.out -coverpkg=./... ./...
52+
go tool cover -html=cover.out -o cover.html
4853

4954
.PHONY: bench
5055
BENCH ?= .
5156
bench:
52-
@$(foreach pkg,$(PKGS),go test -bench=$(BENCH) -run="^$$" $(BENCH_FLAGS) $(pkg);)
57+
go list ./... | xargs -n1 go test -bench=$(BENCH) -run="^$$" $(BENCH_FLAGS)

glide.lock

Lines changed: 0 additions & 17 deletions
This file was deleted.

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module go.uber.org/dig
2+
3+
go 1.13
4+
5+
require (
6+
github.com/stretchr/testify v1.4.0
7+
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee
8+
golang.org/x/lint v0.0.0-20190930215403-16217165b5de
9+
golang.org/x/tools v0.0.0-20191030062658-86caa796c7ab // indirect
10+
)

go.sum

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
2+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
3+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
5+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
6+
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
7+
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
8+
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee h1:0mgffUl7nfd+FpvXMVz4IDEaUSmT1ysygQC7qYo7sG4=
9+
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
10+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
11+
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
12+
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
13+
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
14+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
15+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
16+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
17+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
18+
golang.org/x/tools v0.0.0-20190311212946-11955173bddd h1:/e+gpKk9r3dJobndpTytxS2gOy6m5uvpg+ISQoEcusQ=
19+
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
20+
golang.org/x/tools v0.0.0-20191030062658-86caa796c7ab h1:tpc/nJ4vD66vAk/2KN0sw/DvQIz2sKmCpWvyKtPmfMQ=
21+
golang.org/x/tools v0.0.0-20191030062658-86caa796c7ab/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
22+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
23+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
24+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
25+
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
26+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

tools.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright (c) 2019 Uber Technologies, Inc.
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in
11+
// all copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
// THE SOFTWARE.
20+
21+
// +build tools
22+
23+
package dig
24+
25+
import (
26+
_ "go.uber.org/tools/update-license"
27+
_ "golang.org/x/lint/golint"
28+
)

0 commit comments

Comments
 (0)