Skip to content

Commit

Permalink
Use go modules instead of govendor
Browse files Browse the repository at this point in the history
  • Loading branch information
bugraaydogar committed Apr 8, 2021
1 parent 2cc726a commit 118d09e
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 128 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
language: go
go_import_path: github.com/canonical/iot-devicetwin
go:
- 1.12
- 1.13
env:
matrix:
- TEST_SUITE="--static"
- TEST_SUITE="--unit"

before_install:
- go get golang.org/x/lint/golint
- sh ./get-deps.sh

install:
- echo $GOPATH
Expand Down
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
FROM golang:1.12 as builder1
FROM golang:1.13 as builder1
COPY . ./src/github.com/canonical/iot-devicetwin
WORKDIR /go/src/github.com/canonical/iot-devicetwin
RUN ./get-deps.sh
RUN CGO_ENABLED=1 GOOS=linux go build -a -o /go/bin/devicetwin -ldflags='-extldflags "-static"' cmd/devicetwin/main.go

# Copy the built applications to the docker image
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ The device twin record holds:
```bash
$ go get github.com/canonical/iot-devicetwin
$ cd iot-devicetwin
$ ./get-deps.sh
$ go build ./...
```

Expand Down
23 changes: 0 additions & 23 deletions get-deps.sh

This file was deleted.

14 changes: 14 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module github.com/canonical/iot-devicetwin

go 1.13

require (
github.com/alexkohler/nakedret v1.0.0 // indirect
github.com/canonical/iot-identity v0.0.0-20210408072605-83f114f75fbe
github.com/eclipse/paho.mqtt.golang v1.2.0
github.com/gorilla/mux v1.8.0
github.com/lib/pq v1.10.0
github.com/segmentio/ksuid v1.0.3
github.com/stretchr/testify v1.7.0
golang.org/x/net v0.0.0-20201021035429-f5854403a974 // indirect
)
48 changes: 48 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
github.com/alexkohler/nakedret v1.0.0 h1:S/bzOFhZHYUJp6qPmdXdFHS5nlWGFmLmoc8QOydvotE=
github.com/alexkohler/nakedret v1.0.0/go.mod h1:tfDQbtPt67HhBK/6P0yNktIX7peCxfOp0jO9007DrLE=
github.com/canonical/iot-identity v0.0.0-20210408072605-83f114f75fbe h1:KMVs5N8VkooNj5ByqHQ376rZAc8rNkI3U07BPKyXlmI=
github.com/canonical/iot-identity v0.0.0-20210408072605-83f114f75fbe/go.mod h1:Q7paRFEZrEtaGYlMBgKVTNi4GVQcwh4BUzFmIPyJ8ow=
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/eclipse/paho.mqtt.golang v1.2.0 h1:1F8mhG9+aO5/xpdtFkW4SxOJB67ukuDC3t2y2qayIX0=
github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=
github.com/godbus/dbus v4.1.0+incompatible/go.mod h1:/YcGZj5zSblfDWMMoOzV4fas9FZnQYTkDnsGvmh2Grw=
github.com/gorilla/mux v0.0.0-20190316133243-c5c6c98bc253/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/lib/pq v0.0.0-20190326042056-d6156e141ac6/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/lib/pq v1.10.0 h1:Zx5DJFEYQXio93kgXnQ09fXNiUKsqv4OUEu2UtGcB1E=
github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/mvo5/goconfigparser v0.0.0-20201015074339-50f22f44deb5/go.mod h1:xmt4k1xLDl8Tdan+0S/jmMK2uSUBSzTc18+5GN5Vea8=
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/segmentio/ksuid v1.0.3 h1:FoResxvleQwYiPAVKe1tMUlEirodZqlqglIuFsdDntY=
github.com/segmentio/ksuid v1.0.3/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O73XgrPE=
github.com/snapcore/go-gettext v0.0.0-20201130093759-38740d1bd3d2/go.mod h1:D3SsWAXK7wCCBZu+Vk5hc1EuKj/L3XN1puEMXTU4LrQ=
github.com/snapcore/snapd v0.0.0-20210316092951-71c2f53833de/go.mod h1:3xrn7QDDKymcE5VO2rgWEQ5ZAUGb9htfwlXnoel6Io8=
github.com/snapcore/squashfuse v0.0.0-20171220165323-319f6d41a041/go.mod h1:8loYitFPSdoeCXBs/XjO0fyGcpgLAybOHLUsGwgMq90=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v0.0.0-20190311161405-34c6fa2dc709/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/net v0.0.0-20190328230028-74de082e2cca/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190329044733-9eb1bfa1ce65/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/tomb.v2 v2.0.0-20161208151619-d5d1b5820637/go.mod h1:BHsqpu/nsuzkT5BpiH1EMZPLyqSMM8JbIavyFACoFNk=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
16 changes: 7 additions & 9 deletions run-checks
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export LANG=C.UTF-8
export LANGUAGE=en
set -eu

export GO111MODULE=off
export GO111MODULE=on

if which goctest >/dev/null; then
goctest="goctest"
Expand Down Expand Up @@ -76,11 +76,10 @@ append_coverage() {


if [ "$STATIC" = 1 ]; then
./get-deps.sh

echo Checking formatting
fmt=""
for dir in $(go list -f '{{.Dir}}' ./... | grep -v '/vendor/' ); do
for dir in $(go list -f '{{.Dir}}' ./... ); do
s="$(gofmt -s -l "$dir")"
if [ -n "$s" ]; then
fmt="$s\n$fmt"
Expand All @@ -95,7 +94,7 @@ if [ "$STATIC" = 1 ]; then

# go vet
echo Running vet
go list ./... | grep -v '/vendor/' | xargs go vet
go list ./... | xargs go vet

# golint
echo Install golint
Expand All @@ -104,7 +103,7 @@ if [ "$STATIC" = 1 ]; then
fi

echo Running lint
for dir in $(go list -f '{{.Dir}}' ./... | grep -v '/vendor/' ); do
for dir in $(go list -f '{{.Dir}}' ./... ); do
lint="$(golint "$dir")"
if [ -n "$lint" ]; then
echo "Lint complains:"
Expand All @@ -118,7 +117,7 @@ if [ "$STATIC" = 1 ]; then
go get -u github.com/client9/misspell/cmd/misspell
fi
for file in *; do
if [ "$file" = "vendor" ] || [ "$file" = "static" ] || [ "$file" = "webapp-admin" ] || [ "$file" = "webapp-user" ] || [ "$file" = "test" ]; then
if [ "$file" = "static" ] || [ "$file" = "webapp-admin" ] || [ "$file" = "webapp-user" ] || [ "$file" = "test" ]; then
continue
fi
misspell -error -i auther,PROCES,PROCESSS,proces,processs,exportfs,mosquitto "$file"
Expand All @@ -129,7 +128,7 @@ if [ "$STATIC" = 1 ]; then
go get -u github.com/gordonklaus/ineffassign
fi
# ineffassign knows about ignoring vendor/ \o/
ineffassign .
ineffassign ./...

echo Checking for naked returns
if ! which nakedret >/dev/null; then
Expand All @@ -143,7 +142,6 @@ if [ "$STATIC" = 1 ]; then
fi

if [ ! -z "$UNIT" ]; then
./get-deps.sh

# Prepare the coverage output profile.
rm -rf .coverage
Expand All @@ -155,7 +153,7 @@ if [ ! -z "$UNIT" ]; then

# tests
echo Running tests from "$PWD"
for pkg in $(go list ./... | grep -v '/vendor/' ); do
for pkg in $(go list ./... ); do
go test -i "$pkg"
$goctest -v -coverprofile=.coverage/profile.out -covermode="$COVERMODE" "$pkg"
append_coverage .coverage/profile.out
Expand Down
91 changes: 0 additions & 91 deletions vendor/vendor.json

This file was deleted.

0 comments on commit 118d09e

Please sign in to comment.