Skip to content

Commit

Permalink
Merge pull request #38 from 9seconds/go11modules
Browse files Browse the repository at this point in the history
Support of Go 1.11 modules
  • Loading branch information
9seconds authored Sep 21, 2018
2 parents 96e80fc + b81505e commit 278753d
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 248 deletions.
7 changes: 1 addition & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ sudo: false
dist: trusty

go:
- "1.9.x"
- "1.10.x"
- "1.11.x"
- master

before_script: make prepare
Expand All @@ -17,10 +16,6 @@ script:
- make critic
- make test

cache:
directories:
- vendor

matrix:
allow_failures:
- go: master
9 changes: 1 addition & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@ RUN set -x \
upx \
&& update-ca-certificates

COPY Gopkg.toml Gopkg.lock Makefile /go/src/github.com/9seconds/mtg/

RUN set -x && \
cd /go/src/github.com/9seconds/mtg && \
make -j 4 prepare && \
make vendor

COPY . /go/src/github.com/9seconds/mtg
COPY . /go/src/github.com/9seconds/mtg/

RUN set -x \
&& cd /go/src/github.com/9seconds/mtg \
Expand Down
154 changes: 0 additions & 154 deletions Gopkg.lock

This file was deleted.

58 changes: 0 additions & 58 deletions Gopkg.toml

This file was deleted.

41 changes: 19 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,28 @@ ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
IMAGE_NAME := mtg
APP_NAME := $(IMAGE_NAME)

VENDOR_FILES := $(shell find "$(ROOT_DIR)/vendor" 2>/dev/null || echo -n "vendor")
CC_BINARIES := $(shell bash -c "echo -n $(APP_NAME)-{linux,freebsd,openbsd}-{386,amd64} $(APP_NAME)-linux-{arm,arm64}")
APP_DEPS := version.go $(VENDOR_FILES)
APP_DEPS := version.go

GOLANGCI_LINT_VERSION := v1.10.2

COMMON_BUILD_FLAGS := -ldflags="-s -w"

MOD_ON := env GO111MODULE=on
MOD_OFF := env GO111MODULE=auto

# -----------------------------------------------------------------------------

$(APP_NAME): $(APP_DEPS)
@go build $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
@$(MOD_ON) go build $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"

static-$(APP_NAME): $(APP_DEPS)
@env CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"
@$(MOD_ON) env CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo $(COMMON_BUILD_FLAGS) -o "$(APP_NAME)"

$(APP_NAME)-%: GOOS=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f1 -d-)
$(APP_NAME)-%: GOARCH=$(shell echo -n "$@" | sed 's?$(APP_NAME)-??' | cut -f2 -d-)
$(APP_NAME)-%: $(APP_DEPS) ccbuilds
@env "GOOS=$(GOOS)" "GOARCH=$(GOARCH)" \
@$(MOD_ON) env "GOOS=$(GOOS)" "GOARCH=$(GOARCH)" \
go build \
$(COMMON_BUILD_FLAGS) \
-o "./ccbuilds/$(APP_NAME)-$(GOOS)-$(GOARCH)"
Expand All @@ -30,10 +32,10 @@ ccbuilds:
@rm -rf ./ccbuilds && mkdir -p ./ccbuilds

version.go:
@go generate main.go
@$(MOD_ON) go generate main.go

vendor: Gopkg.lock Gopkg.toml
@dep ensure --vendor-only
vendor: go.mod go.sum
@$(MOD_ON) go mod vendor

# -----------------------------------------------------------------------------

Expand All @@ -51,16 +53,16 @@ crosscompile-dir:
@rm -rf "$(CC_DIR)" && mkdir -p "$(CC_DIR)"

.PHONY: test
test: vendor version.go
@go test -v ./...
test: vendor $(APP_DEPS)
@$(MOD_ON) go test -v ./...

.PHONY: lint
lint: version.go
@golangci-lint run
lint: vendor $(APP_DEPS)
@$(MOD_OFF) golangci-lint run

.PHONY: critic
critic: version.go
@gocritic check-project "$(ROOT_DIR)"
critic: vendor $(APP_DEPS)
@$(MOD_OFF) gocritic check-project "$(ROOT_DIR)"

.PHONY: clean
clean:
Expand All @@ -73,18 +75,13 @@ docker:
@docker build --pull -t "$(IMAGE_NAME)" "$(ROOT_DIR)"

.PHONY: prepare
prepare: install-dep install-lint install-critic
@dep ensure --vendor-only

.PHONY: install-dep
install-dep:
@go get -u github.com/golang/dep/cmd/dep
prepare: install-lint install-critic

.PHONY: install-lint
install-lint:
@curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh \
| bash -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION)
| $(MOD_OFF) bash -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT_VERSION)

.PHONY: install-critic
install-critic:
@go get -u github.com/go-critic/go-critic/...
@$(MOD_OFF) go get -u github.com/go-critic/go-critic/...
19 changes: 19 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module github.com/9seconds/mtg

require (
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc // indirect
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf // indirect
github.com/beevik/ntp v0.2.0
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dustin/go-humanize v0.0.0-20180713052910-9f541cc9db5d
github.com/juju/errors v0.0.0-20180806074554-22422dad46e1
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/satori/go.uuid v1.2.0
github.com/stretchr/testify v1.2.2
go.uber.org/atomic v1.3.2 // indirect
go.uber.org/multierr v1.1.0 // indirect
go.uber.org/zap v1.9.1
golang.org/x/net v0.0.0-20180921000356-2f5d2388922f // indirect
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/alexcesaro/statsd.v2 v2.0.0
)
30 changes: 30 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc h1:cAKDfWh5VpdgMhJosfJnn5/FoN2SRZ4p7fJNX58YPaU=
github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf h1:qet1QNfXsQxTZqLG4oE62mJzwPIB8+Tee4RNCL9ulrY=
github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0=
github.com/beevik/ntp v0.2.0 h1:sGsd+kAXzT0bfVfzJfce04g+dSRfrs+tbQW8lweuYgw=
github.com/beevik/ntp v0.2.0/go.mod h1:hIHWr+l3+/clUnF44zdK+CWW7fO8dR5cIylAQ76NRpg=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dustin/go-humanize v0.0.0-20180713052910-9f541cc9db5d h1:lDrio3iIdNb0Gw9CgH7cQF+iuB5mOOjdJ9ERNJCBgb4=
github.com/dustin/go-humanize v0.0.0-20180713052910-9f541cc9db5d/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/juju/errors v0.0.0-20180806074554-22422dad46e1 h1:wnhMXidtb70kDZCeLt/EfsVtkXS5c8zLnE9y/6DIRAU=
github.com/juju/errors v0.0.0-20180806074554-22422dad46e1/go.mod h1:W54LbzXuIE0boCoNJfwqpmkKJ1O4TCTZMetAt6jGk7Q=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/satori/go.uuid v1.2.0 h1:0uYX9dsZ2yD7q2RtLRtPSdGDWzjeM3TbMJP9utgA0ww=
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4=
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/multierr v1.1.0 h1:HoEmRHQPVSqub6w2z2d2EOVs2fjyFRGyofhKuyDq0QI=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.9.1 h1:XCJQEf3W6eZaVwhRBof6ImoYGJSITeKWsyeh3HFu/5o=
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/net v0.0.0-20180921000356-2f5d2388922f h1:QM2QVxvDoW9PFSPp/zy9FgxJLfaWTZlS61KEPtBwacM=
golang.org/x/net v0.0.0-20180921000356-2f5d2388922f/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/alexcesaro/statsd.v2 v2.0.0 h1:FXkZSCZIH17vLCO5sO2UucTHsH9pc+17F6pl3JVCwMc=
gopkg.in/alexcesaro/statsd.v2 v2.0.0/go.mod h1:i0ubccKGzBVNBpdGV5MocxyA/XlLUJzA7SLonnE4drU=

0 comments on commit 278753d

Please sign in to comment.