aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Abhinav Gupta <mail@abhinavg.net> 2019-01-02 16:36:04 -0800
committerGravatar GitHub <noreply@github.com> 2019-01-02 16:36:04 -0800
commitfa1cf198a7c22a0f7537c565e36a19567bbde0d8 (patch)
tree05784d90af9d96ebdab015e08372c76a3cf1aac1
parent4f14effe2d5e01058696fc1038255d0b2dd54179 (diff)
downloadsally-fa1cf198a7c22a0f7537c565e36a19567bbde0d8.tar.gz
sally-fa1cf198a7c22a0f7537c565e36a19567bbde0d8.tar.zst
sally-fa1cf198a7c22a0f7537c565e36a19567bbde0d8.zip
Upgrade to Go 1.11 and use modules (#33)
This commit modernizes the repository organization a bit. In short, this, - Upgrades to Go 1.11. - Uses Go modules instead of Glide. - Drops errcheck, which we rarely use in our codebase internally. - Uses `./...` to run build, tests, etc. since that does not have to account for vendor anymore. - Drops `-installsuffix cgo` from the production build. This was a workaround for pre-1.10 versions of Go. See https://github.com/golang/go/issues/9344#issuecomment-69944514. - Uses a tools.go as recommended in [go-modules-by-example/tools][1] to pin to tool dependencies. - Uses `go run` instead of `go install`ing tools globally. [1]: https://github.com/go-modules-by-example/index/tree/master/010_tools Tested locally with `make docker-launch`.
-rw-r--r--.envrc1
-rw-r--r--Dockerfile6
-rw-r--r--Makefile43
-rw-r--r--glide.lock43
-rw-r--r--glide.yaml19
-rw-r--r--go.mod18
-rw-r--r--go.sum31
-rw-r--r--tools.go8
8 files changed, 71 insertions, 98 deletions
diff --git a/.envrc b/.envrc
new file mode 100644
index 0000000..37b1096
--- /dev/null
+++ b/.envrc
@@ -0,0 +1 @@
+export GO111MODULE=on
diff --git a/Dockerfile b/Dockerfile
index 8c06098..131220f 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,12 +1,12 @@
-FROM golang:1.7.5
+FROM golang:1.11
EXPOSE 8080
RUN \
curl -fsSLO https://get.docker.com/builds/Linux/x86_64/docker-latest.tgz && \
tar --strip-components=1 -xvzf docker-latest.tgz -C /usr/local/bin
+ENV GO111MODULE=on
RUN mkdir -p /go/src/go.uber.org/sally
WORKDIR /go/src/go.uber.org/sally
-ADD glide.yaml glide.lock /go/src/go.uber.org/sally/
-RUN go get -v github.com/Masterminds/glide && glide install
ADD . /go/src/go.uber.org/sally/
+RUN go mod vendor
CMD ["make", "run"]
diff --git a/Makefile b/Makefile
index 43bae42..7c25a34 100644
--- a/Makefile
+++ b/Makefile
@@ -1,61 +1,38 @@
-PKGS := $(shell go list ./... | grep -v go.uber.org/sally/vendor)
-SRCS := $(wildcard *.go)
+GOLINT = go run github.com/golang/lint/golint
+STATICCHECK = go run honnef.co/go/tools/cmd/staticcheck
.PHONY: all
all: test
-.PHONY: vendor-update
-vendor-update:
- go get -v github.com/Masterminds/glide
- glide update
-
-.PHONY: vendor-install
-vendor-install:
- go get -v github.com/Masterminds/glide
- glide install
-
.PHONY: build
build:
- go build $(PKGS)
+ go build
.PHONY: install
install:
- go install $(PKGS)
+ go install .
.PHONY: lint
lint:
- go install ./vendor/github.com/golang/lint/golint
- for file in $(SRCS); do \
- golint $$file; \
- if [ -n "$$(golint $$file)" ]; then \
- exit 1; \
- fi; \
- done
+ $(GOLINT) ./...
.PHONY: vet
vet:
- go vet $(PKGS)
-
-.PHONY: errcheck
-errcheck:
- go install ./vendor/github.com/kisielk/errcheck
- errcheck $(PKGS)
+ go vet ./...
.PHONY: staticcheck
staticcheck:
- go install ./vendor/honnef.co/go/tools/cmd/staticcheck
- staticcheck $(PKGS)
+ $(STATICCHECK) -tests=false ./...
.PHONY: pretest
-pretest: lint vet errcheck staticcheck
+pretest: lint vet staticcheck
.PHONY: test
test: pretest
- go test -race $(PKGS)
+ go test -race ./...
.PHONY: clean
clean:
- go clean -i $(PKGS)
rm -rf _tmp
.PHONY: docker-build-dev
@@ -70,7 +47,7 @@ docker-test: docker-build-dev
docker-build-internal:
rm -rf _tmp
mkdir -p _tmp
- CGO_ENABLED=0 go build -a -installsuffix cgo -o _tmp/sally $(SRCS)
+ CGO_ENABLED=0 go build -a -o _tmp/sally .
docker build -t uber/sally -f Dockerfile.scratch .
.PHONY: docker-build
diff --git a/glide.lock b/glide.lock
deleted file mode 100644
index 7e67e77..0000000
--- a/glide.lock
+++ /dev/null
@@ -1,43 +0,0 @@
-hash: f5c47d20486f8bbe6bbd77ef06c41209229aab49601a6671a432c24dce1ed830
-updated: 2018-12-31T11:25:19.957346842-08:00
-imports:
-- name: github.com/julienschmidt/httprouter
- version: 348b672cd90d8190f8240323e372ecd1e66b59dc
-- name: gopkg.in/yaml.v2
- version: 51d6538a90f86fe93ac480b35f37b2be17fef232
-testImports:
-- name: github.com/davecgh/go-spew
- version: d8f796af33cc11cb798c1aaeb27a4ebc5099927d
- subpackages:
- - spew
-- name: github.com/golang/lint
- version: 8f45f776aaf18cebc8d65861cc70c33c60471952
- subpackages:
- - golint
-- name: github.com/kisielk/errcheck
- version: 1787c4bee836470bf45018cfbc783650db3c6501
-- name: github.com/kisielk/gotool
- version: 80517062f582ea3340cd4baf70e86d539ae7d84d
-- name: github.com/pmezard/go-difflib
- version: 5d4384ee4fb2527b0a1256a821ebfc92f91efefc
- subpackages:
- - difflib
-- name: github.com/stretchr/testify
- version: 660f15d67dbb878de0d9d79894f728d691c91b91
- subpackages:
- - assert
-- name: github.com/yosssi/gohtml
- version: 97fbf36f4aa81f723d0530f5495a820ba267ae5f
-- name: golang.org/x/net
- version: 640f4622ab692b87c2f3a94265e6f579fe38263d
- subpackages:
- - html
- - html/atom
-- name: golang.org/x/tools
- version: 4e70a1b26a7875f00ca1916637a876b5ffaeec59
- subpackages:
- - go/gcimporter15
-- name: honnef.co/go/tools
- version: e3ad64cb4ed3e25a30bf42def711f9cb5b004f72
- subpackages:
- - cmd/staticcheck
diff --git a/glide.yaml b/glide.yaml
deleted file mode 100644
index ef43e8e..0000000
--- a/glide.yaml
+++ /dev/null
@@ -1,19 +0,0 @@
-package: go.uber.org/sally
-import:
-- package: gopkg.in/yaml.v2
-- package: github.com/julienschmidt/httprouter
- version: ^1
-testImport:
-- package: github.com/stretchr/testify
-- package: github.com/yosssi/gohtml
-- package: github.com/golang/lint
- subpackages:
- - golint
-- package: golang.org/x/tools
- subpackages:
- - go/gcimporter15
-- package: github.com/kisielk/errcheck
-- package: github.com/kisielk/gotool
-- package: honnef.co/go/tools
- subpackages:
- - cmd/staticcheck
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..86ea6f5
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,18 @@
+module go.uber.org/sally
+
+require (
+ github.com/davecgh/go-spew v1.1.1 // indirect
+ github.com/golang/lint v0.0.0-20181217174547-8f45f776aaf1
+ github.com/julienschmidt/httprouter v1.2.0
+ github.com/kisielk/gotool v1.0.0 // indirect
+ github.com/kr/pretty v0.1.0 // indirect
+ github.com/pmezard/go-difflib v1.0.0 // indirect
+ github.com/stretchr/testify v1.2.2
+ github.com/yosssi/gohtml v0.0.0-20180130040904-97fbf36f4aa8
+ golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1 // indirect
+ golang.org/x/net v0.0.0-20181220203305-927f97764cc3 // indirect
+ golang.org/x/tools v0.0.0-20181221235234-d00ac6d27372 // indirect
+ gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
+ gopkg.in/yaml.v2 v2.2.2
+ honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3
+)
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..a011e9b
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,31 @@
+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/golang/lint v0.0.0-20181217174547-8f45f776aaf1 h1:6DVPu65tee05kY0/rciBQ47ue+AnuY8KTayV6VHikIo=
+github.com/golang/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
+github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g=
+github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
+github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=
+github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
+github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
+github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
+github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
+github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
+github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
+github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
+github.com/yosssi/gohtml v0.0.0-20180130040904-97fbf36f4aa8 h1:OlIHDBRrlQk8fHa662oG2gzOO/ixBRU9sLht/M9kzK0=
+github.com/yosssi/gohtml v0.0.0-20180130040904-97fbf36f4aa8/go.mod h1:+ccdNT0xMY1dtc5XBxumbYfOUhmduiGudqaDgD2rVRE=
+golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1 h1:rJm0LuqUjoDhSk2zO9ISMSToQxGz7Os2jRiOL8AWu4c=
+golang.org/x/lint v0.0.0-20181217174547-8f45f776aaf1/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
+golang.org/x/net v0.0.0-20181220203305-927f97764cc3 h1:eH6Eip3UpmR+yM/qI9Ijluzb1bNv/cAU/n+6l8tRSis=
+golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
+golang.org/x/tools v0.0.0-20181221235234-d00ac6d27372 h1:zWPUEY/PjVHT+zO3L8OfkjrtIjf55joTxn/RQP/AjOI=
+golang.org/x/tools v0.0.0-20181221235234-d00ac6d27372/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY=
+gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
+gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
+honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3 h1:LyX67rVB0kBUFoROrQfzKwdrYLH1cRzHibxdJW85J1c=
+honnef.co/go/tools v0.0.0-20180920025451-e3ad64cb4ed3/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
diff --git a/tools.go b/tools.go
new file mode 100644
index 0000000..d2af1bd
--- /dev/null
+++ b/tools.go
@@ -0,0 +1,8 @@
+// +build tools
+
+package main
+
+import (
+ _ "github.com/golang/lint/golint"
+ _ "honnef.co/go/tools/cmd/staticcheck"
+)