Skip to content

Commit 5c10272

Browse files
committed
Upgrade to Go 1.13.4 and set up for use with Go modules
1 parent f0f1c1d commit 5c10272

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

+38
-10806
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 & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PACKAGE := github.com/github/git-sizer
22
ROOTDIR := $(abspath $(CURDIR))
3-
GOPATH := $(ROOTDIR)/.gopath
4-
export GOPATH
3+
GO111MODULES := 1
4+
export GO111MODULES
55

66
GO := $(CURDIR)/script/go
77
GOFMT := $(CURDIR)/script/gofmt
@@ -13,12 +13,12 @@ ifdef USE_ISATTY
1313
GOFLAGS := $(GOFLAGS) --tags isatty
1414
endif
1515

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}} \
16+
GO_SRCS := $(sort $(shell $(GO) list -f ' \
17+
{{$$ip := .Dir}} \
18+
{{range .GoFiles }}{{printf "%s/%s\n" $$ip .}}{{end}} \
19+
{{range .CgoFiles }}{{printf "%s/%s\n" $$ip .}}{{end}} \
20+
{{range .TestGoFiles }}{{printf "%s/%s\n" $$ip .}}{{end}} \
21+
{{range .XTestGoFiles}}{{printf "%s/%s\n" $$ip .}}{{end}} \
2222
' ./...))
2323

2424
.PHONY: all
@@ -27,7 +27,7 @@ all: bin/git-sizer
2727
.PHONY: bin/git-sizer
2828
bin/git-sizer:
2929
mkdir -p bin
30-
cd $(GOPATH)/src/$(PACKAGE) && $(GO) build $(GOFLAGS) -o $(ROOTDIR)/$@ $(PACKAGE)
30+
$(GO) build $(GOFLAGS) -o $(ROOTDIR)/$@ $(PACKAGE)
3131

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

5857
# Note that releases don't include code from vendor (they're only used
@@ -63,7 +62,8 @@ releases/git-sizer-$$(VERSION)-$(1)-$(2).zip: bin/git-sizer-$(1)-$(2)$(3)
6362
mkdir -p releases/tmp-$$(VERSION)-$(1)-$(2)
6463
cp README.md LICENSE.md releases/tmp-$$(VERSION)-$(1)-$(2)
6564
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
65+
cp $$$$($$(GO) list -f '{{.Dir}}' github.com/spf13/pflag)/LICENSE \
66+
releases/tmp-$$(VERSION)-$(1)-$(2)/LICENSE-spf13-pflag
6767
rm -f $$@
6868
zip -j $$@ releases/tmp-$$(VERSION)-$(1)-$(2)/*
6969
rm -rf releases/tmp-$$(VERSION)-$(1)-$(2)
@@ -84,7 +84,7 @@ test: bin/git-sizer gotest
8484

8585
.PHONY: gotest
8686
gotest:
87-
cd $(GOPATH)/src/$(PACKAGE) && $(GO) test -timeout 60s $(GOFLAGS) ./...
87+
$(GO) test -timeout 60s $(GOFLAGS) ./...
8888

8989
.PHONY: gofmt
9090
gofmt:
@@ -102,7 +102,7 @@ govet:
102102
clean:
103103
rm -rf bin
104104

105-
# List all of this project's Go sources, excluding vendor, within .gopath:
105+
# List all of this project's Go sources:
106106
.PHONY: srcs
107107
srcs:
108108
@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.0
7+
github.com/pmezard/go-difflib v1.0.0
8+
github.com/spf13/pflag v1.0.0
9+
github.com/stretchr/testify v1.2.1
10+
)

go.sum

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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/spf13/pflag v1.0.0 h1:oaPbdDe/x0UncahuwiPxW1GYJyilRAdsPnq3e1yaPcI=
6+
github.com/spf13/pflag v1.0.0/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
7+
github.com/stretchr/testify v1.2.1 h1:52QO5WkIUcHGIR7EnGagH88x1bUzqGXTC5/1bDTUQ7U=
8+
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=

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)