Skip to content

Commit

Permalink
Use golang 1.11 with modules (#109)
Browse files Browse the repository at this point in the history
* go mod init
* Migrate scripts
* Change resources package
* Update Dockerfile
* Fix gofmt
* Fix appveyor
* Fix code coverage
* Update licenses
* Add tools.go for build-time dependencies
  • Loading branch information
rdsubhas authored Nov 9, 2018
1 parent 87b21d5 commit 7979841
Show file tree
Hide file tree
Showing 13 changed files with 10,660 additions and 378 deletions.
11 changes: 5 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
language: go
go_import_path: github.com/goeuro/myke
go:
- 1.8
install:
- bin/init.sh
- 1.11
env:
- GO111MODULE=on
script:
- gofmt -d -s -e . 2>&1 | tee -a fmt.out
- test ! -s fmt.out
- golint -set_exit_status .
- overalls -project=github.com/goeuro/myke -covermode=atomic -- -coverpkg=github.com/goeuro/myke/core,github.com/goeuro/myke/cmd
- go run github.com/golang/lint/golint -set_exit_status .
- go test -coverprofile=coverage.txt -coverpkg=github.com/goeuro/myke/core,github.com/goeuro/myke/cmd -covermode=atomic -timeout 10s -v ./...
- bin/cross-compile.sh "$TRAVIS_TAG-$TRAVIS_COMMIT"
after_success:
- mv overalls.coverprofile coverage.txt
- bash <(curl -s https://codecov.io/bash) -t 5dfb580c-fad8-49bc-93eb-bf758daaca64
deploy:
provider: releases
Expand Down
6 changes: 1 addition & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
FROM golang:1.8
FROM golang:1.11

WORKDIR /go/src/github.com/goeuro/myke
COPY Godeps Godeps
COPY bin/init.sh bin/
RUN bin/init.sh

COPY . /go/src/github.com/goeuro/myke
CMD ["bin/cross-compile.sh"]
119 changes: 0 additions & 119 deletions Godeps/Godeps.json

This file was deleted.

5 changes: 0 additions & 5 deletions Godeps/Readme

This file was deleted.

6 changes: 3 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ branches:

environment:
GOPATH: C:\gopath
GO111MODULE: "on"
matrix:
- environment:
GOVERSION: 1.8
GOVERSION: 1.11

install:
- set PATH=%GOPATH%\bin;C:\go\bin;%WINDIR%;%WINDIR%\System32;C:\Program Files\Git\cmd;C:\Program Files\Git\usr\bin
- go version
- go env
- sh c:\gopath\src\github.com\goeuro\myke\bin\init.sh

build_script:
- gofmt -d -s -e . 2>&1 | tee -a fmt.out
- test ! -s fmt.out
- golint -set_exit_status .
- go run github.com/golang/lint/golint -set_exit_status .
- go test -timeout 10s -v ./...
16 changes: 9 additions & 7 deletions bin/cross-compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,31 @@ version=${1?"version is required"}
echo $version >> "tmp/version"

# Generate license notices
go mod vendor
deps="github.com/goeuro/myke $(go list -f '{{ join .Deps "\n"}}' ./... | grep -v 'goeuro/myke')"
out="tmp/LICENSES"
echo -e "OPEN SOURCE LICENSES\n" > $out

for dep in $deps; do
if [ -d "$GOPATH/src/$dep" ]; then
notices=$(ls -d $GOPATH/src/$dep/* 2>/dev/null | grep -i -e "license" -e "licence" -e "copying" -e "notice" || echo)
if [ -d "vendor/$dep" ]; then
notices=$(ls -d vendor/$dep/* 2>/dev/null | grep -i -e "license" -e "licence" -e "copying" -e "notice" || echo)
if [ ! -z "$notices" ]; then
echo -e "$dep\n\n" >> $out
echo -e "BEGIN LICENSE FOR $dep\n\n" >> $out
for notice in $notices; do
echo "Adding license: $notice"
cat $notice >> $out
done
echo -e "\n\n" >> $out
echo -e "\nEND LICENSE FOR $dep\n\n" >> $out
fi
fi
done

# Compile bindata
go-bindata -o core/bindata.go -nometadata -pkg core tmp/
# Compile resources
go run github.com/omeid/go-resources/cmd/resources \
-declare -var=FS -output core/bindata.go -package core tmp/*

# Cross compile
gox \
go run github.com/mitchellh/gox \
-osarch="darwin/amd64 linux/amd64 windows/amd64" \
-ldflags="-s -w" \
-output="bin/{{.Dir}}_{{.OS}}_{{.Arch}}"
8 changes: 0 additions & 8 deletions bin/init.sh

This file was deleted.

8 changes: 2 additions & 6 deletions cmd/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ package cmd

import (
"fmt"

"github.com/goeuro/myke/core"
"github.com/pkg/errors"
)

// License prints all open source licenses
func License(opts *mykeOpts) error {
data, err := core.Asset("tmp/LICENSES")
if err != nil {
return errors.Wrap(err, "error showing licenses")
}

data, _ := core.FS.String("/tmp/LICENSES")
fmt.Fprintln(opts.Writer, string(data))
return nil
}
10 changes: 3 additions & 7 deletions cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ package cmd

import (
"fmt"
"github.com/goeuro/myke/core"
"github.com/pkg/errors"
"strings"

"github.com/goeuro/myke/core"
)

// Version prints myke version
func Version(opts *mykeOpts) error {
data, err := core.Asset("tmp/version")
if err != nil {
return errors.Wrap(err, "error showing version")
}

data, _ := core.FS.String("/tmp/version")
version := strings.TrimSpace(string(data))
fmt.Fprintf(opts.Writer, "myke version %s\n", version)
return nil
Expand Down
10,729 changes: 10,517 additions & 212 deletions core/bindata.go

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module github.com/goeuro/myke

require (
github.com/Masterminds/semver v0.0.0-20170407153603-923f129261de // indirect
github.com/Masterminds/sprig v0.0.0-20170407153254-4fd5bcb33f76
github.com/aokoli/goutils v0.0.0-20140502001128-9c37978a95bd // indirect
github.com/apex/log v0.0.0-20170412164658-a0bcece0a725
github.com/buger/jsonparser v0.0.0-20181023193515-52c6e1462ebd // indirect
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/ghodss/yaml v1.0.0
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7
github.com/jessevdk/go-flags v0.0.0-20161215105708-4e64e4a4e255
github.com/joho/godotenv v0.0.0-20161216230537-726cc8b906e3
github.com/json-iterator/go v1.1.5 // indirect
github.com/kardianos/osext v0.0.0-20170309185600-9d302b58e975
github.com/kr/pretty v0.1.0 // indirect
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 // indirect
github.com/mitchellh/gox v0.4.0
github.com/mitchellh/iochan v1.0.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.1 // indirect
github.com/olekukonko/ts v0.0.0-20140412220145-ecf753e7c962 // indirect
github.com/omeid/go-resources v0.0.0-20171025031226-ca9993b7d1a4
github.com/pkg/errors v0.0.0-20161029093637-248dadf4e906
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pquerna/ffjson v0.0.0-20181028064349-e517b90714f7 // indirect
github.com/rdsubhas/go-elastictable v0.0.0-20170420232059-6f173a85235b
github.com/satori/go.uuid v0.0.0-20160927100844-b061729afc07 // indirect
github.com/stretchr/testify v0.0.0-20161217200445-2402e8e7a02f
github.com/tgulacsi/wrap v0.0.0-20160112181456-972bd931cfd1 // indirect
github.com/tidwall/gjson v0.0.0-20170418162851-e30a9c1037e0
github.com/tidwall/match v0.0.0-20160830173930-173748da739a // indirect
golang.org/x/crypto v0.0.0-20170420163513-0242f07995e6 // indirect
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3 // indirect
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52 // indirect
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect
gopkg.in/yaml.v2 v2.0.0-20170407172122-cd8b52f8269e // indirect
)
71 changes: 71 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
github.com/Masterminds/semver v0.0.0-20170407153603-923f129261de h1:Sy4fF9DSjYNgvTWe/oHvQCfrG2RL+pFXi0opvagssvM=
github.com/Masterminds/semver v0.0.0-20170407153603-923f129261de/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Masterminds/sprig v0.0.0-20170407153254-4fd5bcb33f76 h1:THqGf7VaassXbUcKXlqZFL+6QZ0Y+5M0DZy7X8VuU7c=
github.com/Masterminds/sprig v0.0.0-20170407153254-4fd5bcb33f76/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o=
github.com/aokoli/goutils v0.0.0-20140502001128-9c37978a95bd h1:gE1k0mCB0xXeVlUd54YnVzrNA2odhHUdY/qYL5jf3HY=
github.com/aokoli/goutils v0.0.0-20140502001128-9c37978a95bd/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ=
github.com/apex/log v0.0.0-20170412164658-a0bcece0a725 h1:enWbgnn8tOTk85yg4p7xrjsZ7ufKLuBXOS4Zh2mvhsE=
github.com/apex/log v0.0.0-20170412164658-a0bcece0a725/go.mod h1:yA770aXIDQrhVOIGurT/pVdfCpSq1GQV/auzMN5fzvY=
github.com/buger/jsonparser v0.0.0-20181023193515-52c6e1462ebd h1:5T+u+bQ8I1bOgzmu96rHImT0VjPsj3q33dR3j2AqmXU=
github.com/buger/jsonparser v0.0.0-20181023193515-52c6e1462ebd/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
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/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7 h1:2hRPrmiwPrp3fQX967rNJIhQPtiGXdlQWAxKbKw3VHA=
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
github.com/jessevdk/go-flags v0.0.0-20161215105708-4e64e4a4e255 h1:mFVIonNWyjX7ihw6PbnZNbMrJ0VGJg0NpMp8IWBXcIg=
github.com/jessevdk/go-flags v0.0.0-20161215105708-4e64e4a4e255/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJSGM75WSRxI=
github.com/joho/godotenv v0.0.0-20161216230537-726cc8b906e3 h1:zShOjUfrFegEHgln4TPkWk3KkN9sug3Es3Ml6YpgFJI=
github.com/joho/godotenv v0.0.0-20161216230537-726cc8b906e3/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE=
github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/kardianos/osext v0.0.0-20170309185600-9d302b58e975 h1:xvknIKxUQpEypzxKGX59kCIEHYKRcqBa/6jQqXiWKF0=
github.com/kardianos/osext v0.0.0-20170309185600-9d302b58e975/go.mod h1:1NbS8ALrpOvjt0rHPNLyCIeMtbizbir8U//inJ+zuB8=
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/mailru/easyjson v0.0.0-20180823135443-60711f1a8329 h1:2gxZ0XQIU/5z3Z3bUBu+FXuk2pFbkN6tcwi/pjyaDic=
github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mitchellh/gox v0.4.0 h1:lfGJxY7ToLJQjHHwi0EX6uYBdK78egf954SQl13PQJc=
github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg=
github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY=
github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
github.com/olekukonko/ts v0.0.0-20140412220145-ecf753e7c962 h1:3ev7csw9n4tLCxb5mtYXooCeQIFmC8Iw+4VhrSBy4zk=
github.com/olekukonko/ts v0.0.0-20140412220145-ecf753e7c962/go.mod h1:F/7q8/HZz+TXjlsoZQQKVYvXTZaFH4QRa3y+j1p7MS0=
github.com/omeid/go-resources v0.0.0-20171025031226-ca9993b7d1a4 h1:Uv6HZs0LhOEByIbxsZ+Ph0hMAfrv+aCkqhZpKVCY5wU=
github.com/omeid/go-resources v0.0.0-20171025031226-ca9993b7d1a4/go.mod h1:SIESmZeFlCKsQZcd2NEiX8spNNmCWB1V/RbM/eBKDfo=
github.com/pkg/errors v0.0.0-20161029093637-248dadf4e906 h1:aXc/AM323HlkOXjl3QuSO06wbXK45HrzBT+pwVOufXg=
github.com/pkg/errors v0.0.0-20161029093637-248dadf4e906/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
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/pquerna/ffjson v0.0.0-20181028064349-e517b90714f7 h1:gGBSHPOU7g8YjTbhwn+lvFm2VDEhhA+PwDIlstkgSxE=
github.com/pquerna/ffjson v0.0.0-20181028064349-e517b90714f7/go.mod h1:YARuvh7BUWHNhzDq2OM5tzR2RiCcN2D7sapiKyCel/M=
github.com/rdsubhas/go-elastictable v0.0.0-20170420232059-6f173a85235b h1:hQUl8cJkiYfCE3IEgVSVfPRM1ONpEbgZi4+Cc9Le8jM=
github.com/rdsubhas/go-elastictable v0.0.0-20170420232059-6f173a85235b/go.mod h1:ImFGRbRb/6h/45mIEy3Lp/PunOBrxZU1LFAIhej5A7U=
github.com/satori/go.uuid v0.0.0-20160927100844-b061729afc07 h1:DEZDfcCVq3xDJrjqdCgyN/dHYVoqR92MCsdqCdxmnhM=
github.com/satori/go.uuid v0.0.0-20160927100844-b061729afc07/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
github.com/stretchr/testify v0.0.0-20161217200445-2402e8e7a02f h1:LnH9yV1HtIJzh+HlIuWDOdVtNKF+J6P4JyFVNTiinS4=
github.com/stretchr/testify v0.0.0-20161217200445-2402e8e7a02f/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/tgulacsi/wrap v0.0.0-20160112181456-972bd931cfd1 h1:dxQsBwaYDoSeseTSFqtesKMGrhjh1AsLoWUfzqMB1Fc=
github.com/tgulacsi/wrap v0.0.0-20160112181456-972bd931cfd1/go.mod h1:wWhxzLP2llDlbOBxnEKB0XpS0uEnzCRi6xvRshYuva4=
github.com/tidwall/gjson v0.0.0-20170418162851-e30a9c1037e0 h1:yAzX6eXG6KBxoNRKH+CWGOoi5VWpyEbO2PO6vFZSQXw=
github.com/tidwall/gjson v0.0.0-20170418162851-e30a9c1037e0/go.mod h1:c/nTNbUr0E0OrXEhq1pwa8iEgc2DOt4ZZqAt1HtCkPA=
github.com/tidwall/match v0.0.0-20160830173930-173748da739a h1:jkSy//MOkpJzPmsdrxnM+wiF/wdmVCFGegxccsSkm2Q=
github.com/tidwall/match v0.0.0-20160830173930-173748da739a/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
golang.org/x/crypto v0.0.0-20170420163513-0242f07995e6 h1:lg7Mc3Q0kbaHlR9FF3X8mfwUncgM/VZ/HqoJMnZF4YE=
golang.org/x/crypto v0.0.0-20170420163513-0242f07995e6/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3 h1:x/bBzNauLQAlE3fLku/xy92Y8QwKX5HZymrMz2IiKFc=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52 h1:JG/0uqcGdTNgq7FdU+61l5Pdmb8putNZlXb65bJBROs=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
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.0.0-20170407172122-cd8b52f8269e h1:o/mfNjxpTLivuKEfxzzwrJ8PmulH2wEp7t713uMwKAA=
gopkg.in/yaml.v2 v2.0.0-20170407172122-cd8b52f8269e/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
11 changes: 11 additions & 0 deletions tools.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// +build tools
// Declaring build-time dependencies, these are ignored at compile-time
// Refer https://github.com/golang/go/issues/25922

package main

import (
_ "github.com/golang/lint/golint"
_ "github.com/mitchellh/gox"
_ "github.com/omeid/go-resources"
)

0 comments on commit 7979841

Please sign in to comment.