Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Initial go.mod definition using go mod init and go mod tidy
Browse files Browse the repository at this point in the history
* Issue #135.
* Unclear on how to proceed with dep. For now we keep the Gopkg.toml around.
* Repopulate vendor folder (some tools still need to work on module support, e.g. [1]).

[1] dominikh/go-tools#328
  • Loading branch information
bpicode committed Oct 21, 2018
1 parent 3d020bc commit 6a510f5
Show file tree
Hide file tree
Showing 63 changed files with 753 additions and 280 deletions.
83 changes: 38 additions & 45 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
GO ?= GO111MODULE=on go
GO_NOMODULE ?= GO111MODULE=off go

FIRST_GOPATH := $(firstword $(subst :, ,$(GOPATH)))
PKGS := $(shell go list ./...)
PKGS := $(shell $(GO) list ./...)
GOFILES_NOVENDOR := $(shell find . -type f -name '*.go' -not -path "./vendor/*")
FRITZCTL_VERSION ?= unknown
FRITZCTL_OUTPUT ?= fritzctl
FRITZCTL_REVISION := $(shell git rev-parse HEAD)
BASH_COMPLETION_OUTPUT ?= "os/completion/fritzctl"
MAN_PAGE_OUTPUT ?= "os/man/fritzctl.1"
COPYRIGHT_OUTPUT ?= "os/doc/copyright"
DEPENDENCIES_GRAPH_OUTPUT ?= "dependencies.png"
BUILDFLAGS := -ldflags="-s -w -X github.com/bpicode/fritzctl/config.Version=$(FRITZCTL_VERSION) -X github.com/bpicode/fritzctl/config.Revision=$(FRITZCTL_REVISION)" -gcflags="-trimpath=$(GOPATH)" -asmflags="-trimpath=$(GOPATH)"
TESTFLAGS ?=

Expand All @@ -21,6 +23,12 @@ define ok
@tput sgr0 2>/dev/null || echo -n ""
endef

define lazyinstall
@which $1 > /dev/null; if [ $$? -ne 0 ]; then \
$(GO_NOMODULE) get -u $2; \
fi
endef

sysinfo:
@echo ">> SYSTEM INFORMATION"
@echo -n " PLATFORM: $(shell uname -a)"
Expand All @@ -34,7 +42,7 @@ sysinfo:

clean:
@echo -n ">> CLEAN"
@go clean -i
@$(GO) clean -i
@rm -f ./os/completion/fritzctl
@rm -f ./os/man/*.gz
@rm -f ./os/doc/copyright
Expand All @@ -46,70 +54,53 @@ clean:
@rm -f ./analice
@$(call ok)

depinstall:
@go get github.com/golang/dep/cmd/dep

depensure: depinstall
@echo -n ">> DEPENDENCIES [ENSURE]"
@dep ensure
@$(call ok)

depprint: depinstall
@echo ">> DEPENDENCIES [STATUS]"
@dep status

depgraph: depinstall
@echo -n ">> DEPENDENCIES [GRAPH], output = $(DEPENDENCIES_GRAPH_OUTPUT)"
@dep status -dot | dot -T png -o $(DEPENDENCIES_GRAPH_OUTPUT)
@$(call ok)

depverify: depinstall
depverify:
@echo -n ">> DEPENDENCIES [VERIFY]"
@dep check
@$(GO) mod verify 1>/dev/null
@$(call ok)

build:
@echo -n ">> BUILD, version = $(FRITZCTL_VERSION)/$(FRITZCTL_REVISION), output = $(FRITZCTL_OUTPUT)"
@go build -o $(FRITZCTL_OUTPUT) $(BUILDFLAGS)
@$(GO) build -o $(FRITZCTL_OUTPUT) $(BUILDFLAGS)
@$(call ok)

install:
@echo -n ">> INSTALL, version = $(FRITZCTL_VERSION)"
@go install $(BUILDFLAGS)
@$(GO) install $(BUILDFLAGS)
@$(call ok)

test: build
test:
@echo ">> TEST, \"full-mode\": race detector on"
@echo "mode: count" > coverage-all.out
@$(foreach pkg, $(PKGS),\
echo -n " ";\
go test -run '(Test|Example)' $(BUILDFLAGS) $(TESTFLAGS) -race -coverprofile=coverage.out -covermode=atomic $(pkg) || exit 1;\
$(GO) test -run '(Test|Example)' $(BUILDFLAGS) $(TESTFLAGS) -race -coverprofile=coverage.out -covermode=atomic $(pkg) || exit 1;\
tail -n +2 coverage.out >> coverage-all.out;)
@go tool cover -html=coverage-all.out -o coverage-all.html
@$(GO) tool cover -html=coverage-all.out -o coverage-all.html

fasttest: build
@echo ">> TEST, \"fast-mode\": race detector off"
@echo "mode: count" > coverage-all.out
@$(foreach pkg, $(PKGS),\
echo -n " ";\
go test -run '(Test|Example)' $(BUILDFLAGS) $(TESTFLAGS) -coverprofile=coverage.out $(pkg) || exit 1;\
$(GO) test -run '(Test|Example)' $(BUILDFLAGS) $(TESTFLAGS) -coverprofile=coverage.out $(pkg) || exit 1;\
tail -n +2 coverage.out >> coverage-all.out;)
@go tool cover -html=coverage-all.out
@$(GO) tool cover -html=coverage-all.out

completion_bash:
@echo -n ">> BASH COMPLETION, output = $(BASH_COMPLETION_OUTPUT)"
@go run main.go completion bash > $(BASH_COMPLETION_OUTPUT)
@$(GO) run main.go completion bash > $(BASH_COMPLETION_OUTPUT)
@$(call ok)

man:
@echo -n ">> MAN PAGE, output = $(MAN_PAGE_OUTPUT).gz"
@go run main.go doc man > $(MAN_PAGE_OUTPUT)
@$(GO) run main.go doc man > $(MAN_PAGE_OUTPUT)
@gzip --force $(MAN_PAGE_OUTPUT)
@$(call ok)

analice:
@echo -n ">> ANALICE"
@go build github.com/bpicode/fritzctl/tools/analice
@$(GO) build github.com/bpicode/fritzctl/tools/analice
@$(call ok)

license_compliance: analice
Expand All @@ -121,15 +112,15 @@ license_compliance: analice

copyright: license_compliance
@echo -n ">> COPYRIGHT, output = $(COPYRIGHT_OUTPUT)"
@go build github.com/bpicode/fritzctl/tools/analice
@$(GO) build github.com/bpicode/fritzctl/tools/analice
@./analice generate copyright ./ > $(COPYRIGHT_OUTPUT)
@$(call ok)

codequality:
@echo ">> CODE QUALITY"

@echo -n " REVIVE"
@go get github.com/mgechev/revive
@$(call lazyinstall,revive,github.com/mgechev/revive)
@revive -formatter friendly -exclude vendor/... ./...
@$(call ok)

Expand All @@ -139,52 +130,54 @@ codequality:
@$(call ok)

@echo -n " VET"
@go vet ./...
@$(GO) vet ./...
@$(call ok)

@echo -n " CYCLO"
@go get github.com/fzipp/gocyclo
@$(call lazyinstall,gocyclo,github.com/fzipp/gocyclo)
@$(foreach gofile, $(GOFILES_NOVENDOR),\
gocyclo -over 15 $(gofile);)
@$(call ok)

@echo -n " LINT"
@go get golang.org/x/lint/golint
@$(call lazyinstall,golint,golang.org/x/lint/golint)
@$(foreach pkg, $(PKGS),\
golint -set_exit_status $(pkg);)
@$(call ok)

@echo -n " INEFF"
@go get github.com/gordonklaus/ineffassign
@$(call lazyinstall,ineffassign,github.com/gordonklaus/ineffassign)
@ineffassign .
@$(call ok)

@echo -n " SPELL"
@go get github.com/client9/misspell/cmd/misspell
@$(call lazyinstall,misspell,github.com/client9/misspell/cmd/misspell)
@$(foreach gofile, $(GOFILES_NOVENDOR),\
misspell --error $(gofile);)
@$(call ok)

@echo -n " SIMPLE"
@go get honnef.co/go/tools/cmd/gosimple
@$(call lazyinstall,gosimple,honnef.co/go/tools/cmd/gosimple)
@gosimple $(PKGS)
@$(call ok)

@echo -n " STATIC"
@go get honnef.co/go/tools/cmd/staticcheck
@$(call lazyinstall,staticcheck,honnef.co/go/tools/cmd/staticcheck)
@staticcheck $(PKGS)
@$(call ok)

@echo -n " UNUSED"
@go get honnef.co/go/tools/cmd/unused
@$(call lazyinstall,unused,honnef.co/go/tools/cmd/unused)
@unused $(PKGS)
@$(call ok)

@echo -n " INTERFACER"
@go get mvdan.cc/interfacer
@$(call lazyinstall,interfacer,mvdan.cc/interfacer)
@interfacer ./...
@$(call ok)

@echo -n " UNCONVERT"
@go get github.com/mdempsky/unconvert
@$(call lazyinstall,unconvert,github.com/mdempsky/unconvert)
@unconvert -v $(PKGS)
@$(call ok)

Expand Down Expand Up @@ -313,7 +306,7 @@ publish_win:

demogif:
@echo ">> DEMO GIF"
@go build -o mock/standalone/standalone mock/standalone/main.go
@$(GO) build -o mock/standalone/standalone mock/standalone/main.go
@(cd mock/ && standalone/./standalone -httptest.serve=127.0.0.1:8000 & echo $$! > /tmp/TEST_SERVER.PID)
@sleep 2
@(cd mock/ && asciinema rec -c '/bin/sh' ../images/fritzctl_demo.json)
Expand Down
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/bpicode/fritzctl

require (
github.com/cpuguy83/go-md2man v1.0.8
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/fatih/color v1.7.0
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/julienschmidt/httprouter v0.0.0-20150421170007-8c199fb6259f
github.com/mattn/go-colorable v0.0.9 // indirect
github.com/mattn/go-isatty v0.0.4 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/russross/blackfriday v1.5.1 // indirect
github.com/spf13/cobra v0.0.0-20180829160745-99dc12355885
github.com/spf13/pflag v1.0.2
github.com/stretchr/testify v1.2.2
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793
golang.org/x/sys v0.0.0-20180920110915-d641721ec2de // indirect
gopkg.in/yaml.v2 v2.2.1
)
32 changes: 32 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
github.com/cpuguy83/go-md2man v1.0.8 h1:DwoNytLphI8hzS2Af4D0dfaEaiSq2bN05mEm4R6vf8M=
github.com/cpuguy83/go-md2man v1.0.8/go.mod h1:N6JayAiVKtlHSnuTCeuLSQVs75hb8q+dYQLjr7cDsKY=
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/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/julienschmidt/httprouter v0.0.0-20150421170007-8c199fb6259f h1:uUls/Yg9JMVDQiD1vHplcHRNqz5wv6qylEXYM7JtLUY=
github.com/julienschmidt/httprouter v0.0.0-20150421170007-8c199fb6259f/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/mattn/go-colorable v0.0.9 h1:UVL0vNpWh04HeJXV0KLcaT7r06gOH2l4OW6ddYRUIY4=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-isatty v0.0.4 h1:bnP0vzxcAdeI1zdubAl5PjU6zsERjGZb7raWodagDYs=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
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/russross/blackfriday v1.5.1 h1:B8ZN6pD4PVofmlDCDUdELeYrbsVIDM/bpjW3v3zgcRc=
github.com/russross/blackfriday v1.5.1/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/spf13/cobra v0.0.0-20180829160745-99dc12355885 h1:/QQvE738d0yERA4B+d1WcV8+amUA3dOIc6PQJp9UKQw=
github.com/spf13/cobra v0.0.0-20180829160745-99dc12355885/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3XqQ=
github.com/spf13/pflag v1.0.2 h1:Fy0orTDgHdbnzHcsOgfCN4LtHf0ec3wwtiwJqwvf3Gc=
github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sys v0.0.0-20180920110915-d641721ec2de h1:soC2mvPVpAV+Ld2qtpNn1eq25WTn76uIGNV23bofu6Q=
golang.org/x/sys v0.0.0-20180920110915-d641721ec2de/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
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/yaml.v2 v2.2.1 h1:mUhvW9EsL+naU5Q3cakzfE91YhliOondGd6ZrsDBHQE=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
Loading

0 comments on commit 6a510f5

Please sign in to comment.