Skip to content

Commit 951a51b

Browse files
authored
Merge pull request #61 from github/go-modules
Update to a modern Go version and start using Go modules
2 parents f0f1c1d + 8be3f55 commit 951a51b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+47
-10807
lines changed

.gitignore

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
/.gopath
21
/bin
32
/releases
4-
/vendor/go1.*

Gopkg.lock

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

Gopkg.toml

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

Makefile

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
PACKAGE := github.com/github/git-sizer
2-
ROOTDIR := $(abspath $(CURDIR))
3-
GOPATH := $(ROOTDIR)/.gopath
4-
export GOPATH
2+
GO111MODULES := 1
3+
export GO111MODULES
54

65
GO := $(CURDIR)/script/go
76
GOFMT := $(CURDIR)/script/gofmt
@@ -13,12 +12,12 @@ ifdef USE_ISATTY
1312
GOFLAGS := $(GOFLAGS) --tags isatty
1413
endif
1514

16-
GO_SRCS := $(sort $(shell cd $(GOPATH)/src/$(PACKAGE) && $(GO) list -f ' \
17-
{{$$ip := .ImportPath}} \
18-
{{range .GoFiles }}{{printf ".gopath/src/%s/%s\n" $$ip .}}{{end}} \
19-
{{range .CgoFiles }}{{printf ".gopath/src/%s/%s\n" $$ip .}}{{end}} \
20-
{{range .TestGoFiles }}{{printf ".gopath/src/%s/%s\n" $$ip .}}{{end}} \
21-
{{range .XTestGoFiles}}{{printf ".gopath/src/%s/%s\n" $$ip .}}{{end}} \
15+
GO_SRCS := $(sort $(shell $(GO) list -f ' \
16+
{{$$ip := .Dir}} \
17+
{{range .GoFiles }}{{printf "%s/%s\n" $$ip .}}{{end}} \
18+
{{range .CgoFiles }}{{printf "%s/%s\n" $$ip .}}{{end}} \
19+
{{range .TestGoFiles }}{{printf "%s/%s\n" $$ip .}}{{end}} \
20+
{{range .XTestGoFiles}}{{printf "%s/%s\n" $$ip .}}{{end}} \
2221
' ./...))
2322

2423
.PHONY: all
@@ -27,7 +26,7 @@ all: bin/git-sizer
2726
.PHONY: bin/git-sizer
2827
bin/git-sizer:
2928
mkdir -p bin
30-
cd $(GOPATH)/src/$(PACKAGE) && $(GO) build $(GOFLAGS) -o $(ROOTDIR)/$@ $(PACKAGE)
29+
$(GO) build $(GOFLAGS) -o $@ $(PACKAGE)
3130

3231
# Cross-compile for a bunch of common platforms. Note that this
3332
# doesn't work with USE_ISATTY:
@@ -51,8 +50,7 @@ define PLATFORM_template =
5150
.PHONY: bin/git-sizer-$(1)-$(2)$(3)
5251
bin/git-sizer-$(1)-$(2)$(3):
5352
mkdir -p bin
54-
cd $$(GOPATH)/src/$$(PACKAGE) && \
55-
GOOS=$(1) GOARCH=$(2) $$(GO) build $$(GOFLAGS) -ldflags "-X main.ReleaseVersion=$$(VERSION)" -o $$(ROOTDIR)/$$@ $$(PACKAGE)
53+
GOOS=$(1) GOARCH=$(2) $$(GO) build $$(GOFLAGS) -ldflags "-X main.ReleaseVersion=$$(VERSION)" -o $$@ $$(PACKAGE)
5654
common-platforms: bin/git-sizer-$(1)-$(2)$(3)
5755

5856
# Note that releases don't include code from vendor (they're only used
@@ -63,7 +61,8 @@ releases/git-sizer-$$(VERSION)-$(1)-$(2).zip: bin/git-sizer-$(1)-$(2)$(3)
6361
mkdir -p releases/tmp-$$(VERSION)-$(1)-$(2)
6462
cp README.md LICENSE.md releases/tmp-$$(VERSION)-$(1)-$(2)
6563
cp bin/git-sizer-$(1)-$(2)$(3) releases/tmp-$$(VERSION)-$(1)-$(2)/git-sizer$(3)
66-
cp vendor/github.com/spf13/pflag/LICENSE releases/tmp-$$(VERSION)-$(1)-$(2)/LICENSE-spf13-pflag
64+
cp $$$$($$(GO) list -f '{{.Dir}}' github.com/spf13/pflag)/LICENSE \
65+
releases/tmp-$$(VERSION)-$(1)-$(2)/LICENSE-spf13-pflag
6766
rm -f $$@
6867
zip -j $$@ releases/tmp-$$(VERSION)-$(1)-$(2)/*
6968
rm -rf releases/tmp-$$(VERSION)-$(1)-$(2)
@@ -84,7 +83,7 @@ test: bin/git-sizer gotest
8483

8584
.PHONY: gotest
8685
gotest:
87-
cd $(GOPATH)/src/$(PACKAGE) && $(GO) test -timeout 60s $(GOFLAGS) ./...
86+
$(GO) test -timeout 60s $(GOFLAGS) ./...
8887

8988
.PHONY: gofmt
9089
gofmt:
@@ -102,7 +101,7 @@ govet:
102101
clean:
103102
rm -rf bin
104103

105-
# List all of this project's Go sources, excluding vendor, within .gopath:
104+
# List all of this project's Go sources:
106105
.PHONY: srcs
107106
srcs:
108107
@printf "%s\n" $(GO_SRCS)

docs/BUILDING.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,6 @@ This procedure is intended for experts and people who want to help develop `git-
4545

4646
It is also possible to cross-compile for other platforms that are supported by Go. See the comments in the `Makefile` for more information.
4747

48-
Note that this procedure uses a project-local `GOPATH`. This means that you can clone the repository anywhere. The disadvantage is that Go tools need to know about this `GOPATH`. The `Makefile` and the scripts under `scripts/` take care of this automatically. But if you want to run `go` commands by hand, either first set your `GOPATH`:
49-
50-
export GOPATH="$(pwd)/.gopath"
51-
52-
Or use `script/go` and `script/gofmt` rather than `go` and `gofmt`, respectively.
53-
54-
Unfortunately, some Go tools get confused by the symlink that is used to make the project-local `GOPATH` work. If you have this problem, it sometimes helps to run such commands from `.gopath/src/github.com/github/git-sizer/`. Alternatively, clone the project into the traditional place in your normal `GOPATH`.
55-
5648

5749
## Making a release
5850

go.mod

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
module github.com/github/git-sizer
2+
3+
go 1.13
4+
5+
require (
6+
github.com/davecgh/go-spew v1.1.1 // indirect
7+
github.com/spf13/pflag v1.0.5
8+
github.com/stretchr/testify v1.4.0
9+
gopkg.in/yaml.v2 v2.2.7 // indirect
10+
)

go.sum

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
4+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
5+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
6+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7+
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
8+
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
9+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
10+
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
11+
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
12+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
13+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
14+
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
15+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
16+
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
17+
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

script/bootstrap

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,8 @@ set -e
55
cd "$(dirname "$0")/.."
66

77
export ROOTDIR="$(pwd)"
8-
export GOPATH="$ROOTDIR/.gopath"
98

109
if [[ "$(uname -s)" = "Darwin" ]]; then
1110
brew bundle
1211
fi
1312
. script/ensure-go-installed.sh
14-
15-
BASE="$GOPATH/src/github.com/github/git-sizer"
16-
rm -f "$BASE"
17-
mkdir -p $(dirname "$BASE")
18-
ln -s "$(pwd)" "$BASE"

script/ensure-go-installed.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ if [ -z "$ROOTDIR" ]; then
44
echo 1>&2 'ensure-go-installed.sh invoked without ROOTDIR set!'
55
fi
66

7-
# Is go installed, and at least 1.9?
7+
# Is go installed, and at least 1.13?
88
go_ok() {
99
set -- $(go version 2>/dev/null |
1010
sed -n 's/.*go\([0-9][0-9]*\)\.\([0-9][0-9]*\).*/\1 \2/p' |
1111
head -n 1)
12-
[ $# -eq 2 ] && [ "$1" -eq 1 ] && [ "$2" -ge 9 ]
12+
[ $# -eq 2 ] && [ "$1" -eq 1 ] && [ "$2" -ge 13 ]
1313
}
1414

1515
# If a local go is installed, use it.
1616
set_up_vendored_go() {
17-
GO_VERSION=go1.9.2
17+
GO_VERSION=go1.13.4
1818
VENDORED_GOROOT="$ROOTDIR/vendor/$GO_VERSION/go"
1919
if [ -x "$VENDORED_GOROOT/bin/go" ]; then
2020
export GOROOT="$VENDORED_GOROOT"

script/go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@ set -e
44

55
export ROOTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
66
. $ROOTDIR/script/ensure-go-installed.sh
7-
export GOPATH=$ROOTDIR/.gopath
87

98
exec "$(basename $0)" "$@"

0 commit comments

Comments
 (0)