From 0cda63aa8056f851da07c0e30c77c27a0826f7d1 Mon Sep 17 00:00:00 2001 From: Alex Bice Date: Fri, 17 Jan 2020 13:57:37 -0700 Subject: [PATCH] Modules (#9) * cleanliness --- .circleci/config.yml | 27 ++++------- Makefile | 55 ++++++++++++----------- benchmark.sh | 6 +-- benchmark_failfast.md | 32 ++++++------- benchmark_nooptions.md | 32 ++++++------- benchmark_noprealloc.md | 32 ++++++------- benchmark_playground.md | 28 ++++++------ deps.mk | 18 ++++++++ generator/assets.go | 57 ++++++++---------------- glide.lock | 89 ------------------------------------- glide.yaml | 15 ------- go.mod | 29 ++++++++++++ go.sum | 83 ++++++++++++++++++++++++++++++++++ internal/benchmark/types.go | 2 +- internal/example/example.go | 2 +- tools.go | 12 +++++ 16 files changed, 265 insertions(+), 254 deletions(-) create mode 100644 deps.mk delete mode 100644 glide.lock delete mode 100644 glide.yaml create mode 100644 go.mod create mode 100644 go.sum create mode 100644 tools.go diff --git a/.circleci/config.yml b/.circleci/config.yml index d653aa0..e83c5fd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -4,19 +4,10 @@ jobBase: &jobBase working_directory: /go/src/github.com/abice/gencheck steps: - checkout - - run: - name: Install Go Deps - command: | - curl https://glide.sh/get | sh - go get -v github.com/kevinburke/go-bindata/... - go get -v golang.org/x/tools/cmd/cover - go get -v github.com/mattn/goveralls - go get -v github.com/modocache/gover - glide install - run: name: Build command: | - make reinstall + make build - run: name: Test command: | @@ -25,23 +16,23 @@ jobBase: &jobBase make coveralls jobs: - golang_1.9: + golang_1.11: <<: *jobBase docker: - - image: circleci/golang:1.9 - golang_1.10: + - image: circleci/golang:1.11 + golang_1.12: <<: *jobBase docker: - - image: circleci/golang:1.10 - golang_1.11: + - image: circleci/golang:1.12 + golang_1.13: <<: *jobBase docker: - - image: circleci/golang:1.11 + - image: circleci/golang:1.13 workflows: version: 2 build_and_test: jobs: - - golang_1.9 - - golang_1.10 - golang_1.11 + - golang_1.12 + - golang_1.13 diff --git a/Makefile b/Makefile index 71ab7ce..6d36a0f 100644 --- a/Makefile +++ b/Makefile @@ -1,56 +1,57 @@ +.DEFAULT_GOAL:=all +ifdef VERBOSE +V = -v +else +.SILENT: +endif + +GO ?= GO111MODULE=on go + +include $(wildcard *.mk) + COVERAGEDIR = coverage -SERVICE = drone.io ifdef CIRCLE_ARTIFACTS COVERAGEDIR = $(CIRCLE_ARTIFACTS) SERVICE=circle-ci endif .PHONY: all -all: generate fmt build test cover install - -.PHONY: install-deps -install-deps: - glide install +all: generate fmt build test cover .PHONY: benchmarks -benchmarks: generate fmt reinstall +benchmarks: generate fmt build ./benchmark.sh build: generate if [ ! -d bin ]; then mkdir bin; fi - go build -v -o bin/gencheck ./gencheck + $(GO) build -v -o bin/gencheck ./gencheck fmt: gofmt -l -w -s $$(find . -type f -name '*.go' -not -path "./vendor/*") test: generate gen-test if [ ! -d coverage ]; then mkdir coverage; fi - go test -v ./generator -race -cover -coverprofile=$(COVERAGEDIR)/generator.coverprofile - go test -v ./ -race -cover -coverprofile=$(COVERAGEDIR)/gencheck.coverprofile - go test -v ./internal/example -race -cover -coverprofile=$(COVERAGEDIR)/example.coverprofile + $(GO) test -v ./... -race -cover -coverprofile=$(COVERAGEDIR)/coverage.out + cover: - go tool cover -html=$(COVERAGEDIR)/generator.coverprofile -o $(COVERAGEDIR)/generator.html - go tool cover -html=$(COVERAGEDIR)/gencheck.coverprofile -o $(COVERAGEDIR)/gencheck.html - go tool cover -html=$(COVERAGEDIR)/gencheck.coverprofile -o $(COVERAGEDIR)/example.html + $(GO) tool cover -html=$(COVERAGEDIR)/coverage.out -o $(COVERAGEDIR)/coverage.html + tc: test cover -coveralls: - gover $(COVERAGEDIR) $(COVERAGEDIR)/coveralls.coverprofile - goveralls -coverprofile=$(COVERAGEDIR)/coveralls.coverprofile -service=$(SERVICE) -repotoken=$(COVERALLS_TOKEN) -clean: - go clean +coveralls: $(GOVERALLS) + $(GOVERALLS) -coverprofile=$(COVERAGEDIR)/coverage.out -service=$(SERVICE) -repotoken=$(COVERALLS_TOKEN) + +clean: cleandeps + $(GO) clean rm -f bin/gencheck rm -rf coverage/ # go-bindata will take all of the template files and create readable assets from them in the executable. # This way the templates are readable in atom (or another text editor with golang template language support) -generate: - go-bindata -o generator/assets.go -nometadata -pkg=generator template/*.tmpl +generate: deps + $(GOBINDATA) -o generator/assets.go -nometadata -pkg=generator template/*.tmpl -gen-test: build install - go generate $$(glide novendor) +gen-test: build + $(GO) generate ./... install: - go install ./gencheck - -reinstall: build - go install ./gencheck + $(GO) install ./gencheck phony: clean tc build diff --git a/benchmark.sh b/benchmark.sh index c344d14..25f0348 100755 --- a/benchmark.sh +++ b/benchmark.sh @@ -6,9 +6,9 @@ gencheckBench(){ echo "\`\`\`" >> "$benchMD" f="-f=./internal/benchmark/types.go" if [[ -n $options ]]; then - gencheck "$f" "$options" + ./bin/gencheck "$f" "$options" else - gencheck "$f" + ./bin/gencheck "$f" fi go test -v -run=XXX -bench=BenchmarkCompareGencheck -benchmem ./internal/benchmark >> "$benchMD" echo "\`\`\`" >> "$benchMD" @@ -32,4 +32,4 @@ echo "# PLAYGROUND" echo "# PLAYGROUND" > "$benchMD" echo "\`\`\`" >> "$benchMD" go test -v -run=XXX -bench=BenchmarkComparePlayground -benchmem ./internal/benchmark >> "$benchMD" -echo "\`\`\`" >> "$benchMD" \ No newline at end of file +echo "\`\`\`" >> "$benchMD" diff --git a/benchmark_failfast.md b/benchmark_failfast.md index 5d6bc92..7823fde 100644 --- a/benchmark_failfast.md +++ b/benchmark_failfast.md @@ -3,21 +3,21 @@ goos: darwin goarch: amd64 pkg: github.com/abice/gencheck/internal/benchmark -BenchmarkCompareGencheck/UUID_Pass-8 2000000 739 ns/op 0 B/op 0 allocs/op -BenchmarkCompareGencheck/UUID_Fail-8 1000000 1130 ns/op 208 B/op 6 allocs/op -BenchmarkCompareGencheck/Hex_Pass-8 3000000 538 ns/op 0 B/op 0 allocs/op -BenchmarkCompareGencheck/Hex_Fail-8 2000000 882 ns/op 192 B/op 6 allocs/op -BenchmarkCompareGencheck/ContainsAny_Pass-8 30000000 44.6 ns/op 0 B/op 0 allocs/op -BenchmarkCompareGencheck/ContainsAny_Fail-8 10000000 232 ns/op 128 B/op 4 allocs/op -BenchmarkCompareGencheck/TestStrings_Pass-8 200000000 7.11 ns/op 0 B/op 0 allocs/op -BenchmarkCompareGencheck/TestStrings_Fail-8 10000000 169 ns/op 128 B/op 4 allocs/op -BenchmarkCompareGencheck/TestMap_Pass-8 200000000 8.45 ns/op 0 B/op 0 allocs/op -BenchmarkCompareGencheck/TestMap_Fail-8 10000000 173 ns/op 128 B/op 4 allocs/op -BenchmarkCompareGencheck/TestDive_Pass-8 100000000 23.8 ns/op 0 B/op 0 allocs/op -BenchmarkCompareGencheck/TestDive_Fail-8 1000000 1271 ns/op 800 B/op 15 allocs/op -BenchmarkCompareGencheck/TestDive_Nil-8 10000000 193 ns/op 128 B/op 4 allocs/op -BenchmarkCompareGencheck/TestAll_Pass-8 500000 2682 ns/op 328 B/op 6 allocs/op -BenchmarkCompareGencheck/TestAll_Fail-8 10000000 201 ns/op 128 B/op 4 allocs/op +BenchmarkCompareGencheck/UUID_Pass-12 3019042 413 ns/op 0 B/op 0 allocs/op +BenchmarkCompareGencheck/UUID_Fail-12 1584471 756 ns/op 208 B/op 6 allocs/op +BenchmarkCompareGencheck/Hex_Pass-12 3540170 350 ns/op 0 B/op 0 allocs/op +BenchmarkCompareGencheck/Hex_Fail-12 1829170 651 ns/op 192 B/op 6 allocs/op +BenchmarkCompareGencheck/ContainsAny_Pass-12 31153759 33.7 ns/op 0 B/op 0 allocs/op +BenchmarkCompareGencheck/ContainsAny_Fail-12 6937201 172 ns/op 128 B/op 4 allocs/op +BenchmarkCompareGencheck/TestStrings_Pass-12 169096743 7.32 ns/op 0 B/op 0 allocs/op +BenchmarkCompareGencheck/TestStrings_Fail-12 8132941 143 ns/op 128 B/op 4 allocs/op +BenchmarkCompareGencheck/TestMap_Pass-12 197221968 6.07 ns/op 0 B/op 0 allocs/op +BenchmarkCompareGencheck/TestMap_Fail-12 8839633 140 ns/op 128 B/op 4 allocs/op +BenchmarkCompareGencheck/TestDive_Pass-12 80319295 15.1 ns/op 0 B/op 0 allocs/op +BenchmarkCompareGencheck/TestDive_Fail-12 1629925 751 ns/op 592 B/op 13 allocs/op +BenchmarkCompareGencheck/TestDive_Nil-12 9048465 137 ns/op 128 B/op 4 allocs/op +BenchmarkCompareGencheck/TestAll_Pass-12 714092 1758 ns/op 328 B/op 6 allocs/op +BenchmarkCompareGencheck/TestAll_Fail-12 8258488 154 ns/op 128 B/op 4 allocs/op PASS -ok github.com/abice/gencheck/internal/benchmark 30.099s +ok github.com/abice/gencheck/internal/benchmark 23.385s ``` diff --git a/benchmark_nooptions.md b/benchmark_nooptions.md index c31cff2..55543d5 100644 --- a/benchmark_nooptions.md +++ b/benchmark_nooptions.md @@ -3,21 +3,21 @@ goos: darwin goarch: amd64 pkg: github.com/abice/gencheck/internal/benchmark -BenchmarkCompareGencheck/UUID_Pass-8 2000000 818 ns/op 16 B/op 1 allocs/op -BenchmarkCompareGencheck/UUID_Fail-8 1000000 1230 ns/op 208 B/op 6 allocs/op -BenchmarkCompareGencheck/Hex_Pass-8 2000000 537 ns/op 16 B/op 1 allocs/op -BenchmarkCompareGencheck/Hex_Fail-8 2000000 862 ns/op 192 B/op 6 allocs/op -BenchmarkCompareGencheck/ContainsAny_Pass-8 20000000 94.0 ns/op 16 B/op 1 allocs/op -BenchmarkCompareGencheck/ContainsAny_Fail-8 5000000 265 ns/op 128 B/op 4 allocs/op -BenchmarkCompareGencheck/TestStrings_Pass-8 20000000 88.3 ns/op 64 B/op 1 allocs/op -BenchmarkCompareGencheck/TestStrings_Fail-8 3000000 541 ns/op 416 B/op 10 allocs/op -BenchmarkCompareGencheck/TestMap_Pass-8 30000000 54.4 ns/op 16 B/op 1 allocs/op -BenchmarkCompareGencheck/TestMap_Fail-8 10000000 211 ns/op 128 B/op 4 allocs/op -BenchmarkCompareGencheck/TestDive_Pass-8 20000000 114 ns/op 32 B/op 2 allocs/op -BenchmarkCompareGencheck/TestDive_Fail-8 1000000 1284 ns/op 800 B/op 15 allocs/op -BenchmarkCompareGencheck/TestDive_Nil-8 10000000 204 ns/op 128 B/op 4 allocs/op -BenchmarkCompareGencheck/TestAll_Pass-8 500000 2927 ns/op 632 B/op 8 allocs/op -BenchmarkCompareGencheck/TestAll_Fail-8 300000 6046 ns/op 2929 B/op 56 allocs/op +BenchmarkCompareGencheck/UUID_Pass-12 2869220 407 ns/op 16 B/op 1 allocs/op +BenchmarkCompareGencheck/UUID_Fail-12 1858568 645 ns/op 208 B/op 6 allocs/op +BenchmarkCompareGencheck/Hex_Pass-12 3280252 365 ns/op 16 B/op 1 allocs/op +BenchmarkCompareGencheck/Hex_Fail-12 1954568 632 ns/op 192 B/op 6 allocs/op +BenchmarkCompareGencheck/ContainsAny_Pass-12 21148444 56.3 ns/op 16 B/op 1 allocs/op +BenchmarkCompareGencheck/ContainsAny_Fail-12 7321660 167 ns/op 128 B/op 4 allocs/op +BenchmarkCompareGencheck/TestStrings_Pass-12 19691707 65.2 ns/op 64 B/op 1 allocs/op +BenchmarkCompareGencheck/TestStrings_Fail-12 3345627 363 ns/op 416 B/op 10 allocs/op +BenchmarkCompareGencheck/TestMap_Pass-12 39226683 31.0 ns/op 16 B/op 1 allocs/op +BenchmarkCompareGencheck/TestMap_Fail-12 9257938 131 ns/op 128 B/op 4 allocs/op +BenchmarkCompareGencheck/TestDive_Pass-12 18120820 67.3 ns/op 32 B/op 2 allocs/op +BenchmarkCompareGencheck/TestDive_Fail-12 1685066 704 ns/op 592 B/op 13 allocs/op +BenchmarkCompareGencheck/TestDive_Nil-12 9715989 130 ns/op 128 B/op 4 allocs/op +BenchmarkCompareGencheck/TestAll_Pass-12 644622 1933 ns/op 632 B/op 8 allocs/op +BenchmarkCompareGencheck/TestAll_Fail-12 316861 4088 ns/op 2722 B/op 54 allocs/op PASS -ok github.com/abice/gencheck/internal/benchmark 28.927s +ok github.com/abice/gencheck/internal/benchmark 22.311s ``` diff --git a/benchmark_noprealloc.md b/benchmark_noprealloc.md index 707ec34..0b989d2 100644 --- a/benchmark_noprealloc.md +++ b/benchmark_noprealloc.md @@ -3,21 +3,21 @@ goos: darwin goarch: amd64 pkg: github.com/abice/gencheck/internal/benchmark -BenchmarkCompareGencheck/UUID_Pass-8 2000000 855 ns/op 0 B/op 0 allocs/op -BenchmarkCompareGencheck/UUID_Fail-8 1000000 1161 ns/op 208 B/op 6 allocs/op -BenchmarkCompareGencheck/Hex_Pass-8 3000000 507 ns/op 0 B/op 0 allocs/op -BenchmarkCompareGencheck/Hex_Fail-8 2000000 861 ns/op 192 B/op 6 allocs/op -BenchmarkCompareGencheck/ContainsAny_Pass-8 30000000 43.2 ns/op 0 B/op 0 allocs/op -BenchmarkCompareGencheck/ContainsAny_Fail-8 10000000 236 ns/op 128 B/op 4 allocs/op -BenchmarkCompareGencheck/TestStrings_Pass-8 200000000 7.11 ns/op 0 B/op 0 allocs/op -BenchmarkCompareGencheck/TestStrings_Fail-8 2000000 594 ns/op 464 B/op 12 allocs/op -BenchmarkCompareGencheck/TestMap_Pass-8 200000000 8.49 ns/op 0 B/op 0 allocs/op -BenchmarkCompareGencheck/TestMap_Fail-8 10000000 175 ns/op 128 B/op 4 allocs/op -BenchmarkCompareGencheck/TestDive_Pass-8 50000000 24.0 ns/op 0 B/op 0 allocs/op -BenchmarkCompareGencheck/TestDive_Fail-8 1000000 1159 ns/op 800 B/op 15 allocs/op -BenchmarkCompareGencheck/TestDive_Nil-8 10000000 167 ns/op 128 B/op 4 allocs/op -BenchmarkCompareGencheck/TestAll_Pass-8 1000000 2300 ns/op 328 B/op 6 allocs/op -BenchmarkCompareGencheck/TestAll_Fail-8 300000 5777 ns/op 3649 B/op 61 allocs/op +BenchmarkCompareGencheck/UUID_Pass-12 3060320 388 ns/op 0 B/op 0 allocs/op +BenchmarkCompareGencheck/UUID_Fail-12 1633210 675 ns/op 208 B/op 6 allocs/op +BenchmarkCompareGencheck/Hex_Pass-12 3488574 345 ns/op 0 B/op 0 allocs/op +BenchmarkCompareGencheck/Hex_Fail-12 1812626 663 ns/op 192 B/op 6 allocs/op +BenchmarkCompareGencheck/ContainsAny_Pass-12 36120229 34.1 ns/op 0 B/op 0 allocs/op +BenchmarkCompareGencheck/ContainsAny_Fail-12 6942110 171 ns/op 128 B/op 4 allocs/op +BenchmarkCompareGencheck/TestStrings_Pass-12 168171955 7.15 ns/op 0 B/op 0 allocs/op +BenchmarkCompareGencheck/TestStrings_Fail-12 2564859 461 ns/op 464 B/op 12 allocs/op +BenchmarkCompareGencheck/TestMap_Pass-12 188108667 6.45 ns/op 0 B/op 0 allocs/op +BenchmarkCompareGencheck/TestMap_Fail-12 8653820 141 ns/op 128 B/op 4 allocs/op +BenchmarkCompareGencheck/TestDive_Pass-12 77069458 15.9 ns/op 0 B/op 0 allocs/op +BenchmarkCompareGencheck/TestDive_Fail-12 1583066 727 ns/op 592 B/op 13 allocs/op +BenchmarkCompareGencheck/TestDive_Nil-12 8740198 132 ns/op 128 B/op 4 allocs/op +BenchmarkCompareGencheck/TestAll_Pass-12 695394 1772 ns/op 328 B/op 6 allocs/op +BenchmarkCompareGencheck/TestAll_Fail-12 286522 4457 ns/op 3443 B/op 59 allocs/op PASS -ok github.com/abice/gencheck/internal/benchmark 29.262s +ok github.com/abice/gencheck/internal/benchmark 23.473s ``` diff --git a/benchmark_playground.md b/benchmark_playground.md index b3ccb49..d65e3b7 100644 --- a/benchmark_playground.md +++ b/benchmark_playground.md @@ -3,21 +3,21 @@ goos: darwin goarch: amd64 pkg: github.com/abice/gencheck/internal/benchmark -BenchmarkComparePlayground/UUID_Pass-8 2000000 880 ns/op 16 B/op 1 allocs/op -BenchmarkComparePlayground/UUID_Fail-8 1000000 1168 ns/op 224 B/op 5 allocs/op -BenchmarkComparePlayground/Hex_Pass-8 2000000 621 ns/op 0 B/op 0 allocs/op -BenchmarkComparePlayground/Hex_Fail-8 2000000 850 ns/op 208 B/op 4 allocs/op -BenchmarkComparePlayground/ContainsAny_Pass-8 10000000 170 ns/op 0 B/op 0 allocs/op -BenchmarkComparePlayground/ContainsAny_Fail-8 3000000 412 ns/op 224 B/op 4 allocs/op -BenchmarkComparePlayground/TestStrings_Pass-8 3000000 425 ns/op 16 B/op 1 allocs/op -BenchmarkComparePlayground/TestStrings_Fail-8 1000000 1240 ns/op 816 B/op 13 allocs/op +BenchmarkComparePlayground/UUID_Pass-12 2187891 594 ns/op 16 B/op 1 allocs/op +BenchmarkComparePlayground/UUID_Fail-12 1668792 754 ns/op 224 B/op 5 allocs/op +BenchmarkComparePlayground/Hex_Pass-12 2723215 434 ns/op 0 B/op 0 allocs/op +BenchmarkComparePlayground/Hex_Fail-12 1905054 644 ns/op 208 B/op 4 allocs/op +BenchmarkComparePlayground/ContainsAny_Pass-12 9700926 126 ns/op 0 B/op 0 allocs/op +BenchmarkComparePlayground/ContainsAny_Fail-12 3581966 323 ns/op 224 B/op 4 allocs/op +BenchmarkComparePlayground/TestStrings_Pass-12 3550527 342 ns/op 16 B/op 1 allocs/op +BenchmarkComparePlayground/TestStrings_Fail-12 1000000 1058 ns/op 816 B/op 13 allocs/op --- SKIP: BenchmarkComparePlayground/TestMap_Pass --- SKIP: BenchmarkComparePlayground/TestMap_Fail -BenchmarkComparePlayground/TestDive_Pass-8 5000000 327 ns/op 32 B/op 2 allocs/op -BenchmarkComparePlayground/TestDive_Fail-8 3000000 591 ns/op 272 B/op 7 allocs/op -BenchmarkComparePlayground/TestDive_Nil-8 5000000 338 ns/op 208 B/op 4 allocs/op -BenchmarkComparePlayground/TestAll_Pass-8 500000 4019 ns/op 408 B/op 11 allocs/op -BenchmarkComparePlayground/TestAll_Fail-8 200000 6275 ns/op 4209 B/op 51 allocs/op +BenchmarkComparePlayground/TestDive_Pass-12 4978272 240 ns/op 32 B/op 2 allocs/op +BenchmarkComparePlayground/TestDive_Fail-12 2600906 479 ns/op 272 B/op 7 allocs/op +BenchmarkComparePlayground/TestDive_Nil-12 4445193 273 ns/op 208 B/op 4 allocs/op +BenchmarkComparePlayground/TestAll_Pass-12 339356 3064 ns/op 408 B/op 11 allocs/op +BenchmarkComparePlayground/TestAll_Fail-12 223174 5596 ns/op 4211 B/op 51 allocs/op PASS -ok github.com/abice/gencheck/internal/benchmark 24.609s +ok github.com/abice/gencheck/internal/benchmark 19.918s ``` diff --git a/deps.mk b/deps.mk new file mode 100644 index 0000000..bbda807 --- /dev/null +++ b/deps.mk @@ -0,0 +1,18 @@ +GOBINDATA=bin/go/github.com/kevinburke/go-bindata/go-bindata +GOIMPORTS=bin/go/golang.org/x/tools/cmd/goimports +GOVERALLS=bin/go/github.com/mattn/goveralls +MOCKGEN=bin/go/github.com/golang/mock/mockgen +TOOLS = $(GOBINDATA) \ + $(GOIMPORTS) \ + $(MOCKGEN) \ + $(GOVERALLS) + +cleandeps: + if [ -d "./bin" ]; then rm -rf "./bin"; fi + +freshdeps: cleandeps deps + +deps: $(TOOLS) +bin/go/%: + @echo "installing $*" + $(GO) build -o bin/go/$* $* diff --git a/generator/assets.go b/generator/assets.go index c4f97e3..0363b21 100644 --- a/generator/assets.go +++ b/generator/assets.go @@ -579,45 +579,26 @@ func AssetNames() []string { // _bindata is a table, holding each asset generator, mapped to its name. var _bindata = map[string]func() (*asset, error){ - "template/bcp47.tmpl": templateBcp47Tmpl, - - "template/cidr.tmpl": templateCidrTmpl, - - "template/contains.tmpl": templateContainsTmpl, - + "template/bcp47.tmpl": templateBcp47Tmpl, + "template/cidr.tmpl": templateCidrTmpl, + "template/contains.tmpl": templateContainsTmpl, "template/containsany.tmpl": templateContainsanyTmpl, - - "template/dive.tmpl": templateDiveTmpl, - - "template/eq.tmpl": templateEqTmpl, - - "template/gt.tmpl": templateGtTmpl, - - "template/gte.tmpl": templateGteTmpl, - - "template/hex.tmpl": templateHexTmpl, - - "template/len.tmpl": templateLenTmpl, - - "template/lt.tmpl": templateLtTmpl, - - "template/lte.tmpl": templateLteTmpl, - - "template/main.tmpl": templateMainTmpl, - - "template/max.tmpl": templateMaxTmpl, - - "template/min.tmpl": templateMinTmpl, - - "template/ne.tmpl": templateNeTmpl, - - "template/notnil.tmpl": templateNotnilTmpl, - - "template/required.tmpl": templateRequiredTmpl, - - "template/url.tmpl": templateUrlTmpl, - - "template/uuid.tmpl": templateUuidTmpl, + "template/dive.tmpl": templateDiveTmpl, + "template/eq.tmpl": templateEqTmpl, + "template/gt.tmpl": templateGtTmpl, + "template/gte.tmpl": templateGteTmpl, + "template/hex.tmpl": templateHexTmpl, + "template/len.tmpl": templateLenTmpl, + "template/lt.tmpl": templateLtTmpl, + "template/lte.tmpl": templateLteTmpl, + "template/main.tmpl": templateMainTmpl, + "template/max.tmpl": templateMaxTmpl, + "template/min.tmpl": templateMinTmpl, + "template/ne.tmpl": templateNeTmpl, + "template/notnil.tmpl": templateNotnilTmpl, + "template/required.tmpl": templateRequiredTmpl, + "template/url.tmpl": templateUrlTmpl, + "template/uuid.tmpl": templateUuidTmpl, } // AssetDir returns the file names below a certain diff --git a/glide.lock b/glide.lock deleted file mode 100644 index ece5d65..0000000 --- a/glide.lock +++ /dev/null @@ -1,89 +0,0 @@ -hash: 27aed37d7934fd5a9c0bd302aa1bbe60551ce38043572407a8bd93e85b732ab3 -updated: 2019-02-11T13:30:47.974438-07:00 -imports: -- name: github.com/aokoli/goutils - version: 41ac8693c5c10a92ea1ff5ac3a7f95646f6123b0 -- name: github.com/Bowery/prompt - version: 8a1d5376df1cbec3468f2138fecc44dd8b48e342 -- name: github.com/google/uuid - version: 064e2069ce9c359c118179501254f67d7d37ba24 -- name: github.com/huandu/xstrings - version: f02667b379e2fb5916c3cda2cf31e0eb885d79f8 -- name: github.com/imdario/mergo - version: 7fe0c75c13abdee74b09fcacef5ea1c6bba6a874 -- name: github.com/labstack/gommon - version: 82ef680aef5189b68682876cf70d09daa4ac0f51 - subpackages: - - color -- name: github.com/Masterminds/semver - version: 59c29afe1a994eacb71c833025ca7acf874bb1da -- name: github.com/Masterminds/sprig - version: 544a9b1d90f323f6509491b389714fbbd126bee3 -- name: github.com/mattn/go-colorable - version: efa589957cd060542a26d2dd7832fd6a6c6c3ade -- name: github.com/mattn/go-isatty - version: 3fb116b820352b7f0c281308a4d6250c22d94e27 -- name: github.com/mkideal/cli - version: a48c2cee5b5ee91096961d344681edc2083b9422 -- name: github.com/mkideal/pkg - version: 3e188c9e7ecc83d0fe7040a9161ce3c67885470d - subpackages: - - debug - - expr -- name: github.com/pkg/errors - version: 645ef00459ed84a119197bfb8d8205042c6df63d -- name: golang.org/x/crypto - version: eb0de9b17e854e9b1ccd9963efafc79862359959 - subpackages: - - pbkdf2 - - scrypt -- name: golang.org/x/sys - version: 62eef0e2fa9b2c385f7b2778e763486da6880d37 - subpackages: - - unix -- name: golang.org/x/text - version: e6919f6577db79269a6443b9dc46d18f2238fb5d - subpackages: - - internal/language - - internal/language/compact - - internal/tag - - language -- name: golang.org/x/tools - version: 657755b003d86beb7f1e59808a410123ce89b15b - subpackages: - - go/ast/astutil - - go/gcexportdata - - go/internal/cgo - - go/internal/gcimporter - - go/internal/packagesdriver - - go/packages - - imports - - internal/fastwalk - - internal/gopathwalk - - internal/module - - internal/semver -testImports: -- name: github.com/davecgh/go-spew - version: 8991bc29aa16c548c550c7ff78260e27b9ab7c73 - subpackages: - - spew -- name: github.com/go-playground/locales - version: f63010822830b6fe52288ee52d5a1151088ce039 - subpackages: - - currency -- name: github.com/go-playground/universal-translator - version: 71201497bace774495daed26a3874fd339e0b538 -- name: github.com/leodido/go-urn - version: a67a23e1c1af3c66528573bb86a87246477277c1 -- name: github.com/pmezard/go-difflib - version: d8ed2627bdf02c080bf22230dbb337003b7aba2d - subpackages: - - difflib -- name: github.com/stretchr/testify - version: ffdc059bfe9ce6a4e144ba849dbedead332c6053 - subpackages: - - assert - - require - - suite -- name: gopkg.in/go-playground/validator.v9 - version: 774d09c3863ffb2e137ebe4c39ba27648d208f80 diff --git a/glide.yaml b/glide.yaml deleted file mode 100644 index 29cec1a..0000000 --- a/glide.yaml +++ /dev/null @@ -1,15 +0,0 @@ -package: github.com/abice/gencheck -import: -- package: github.com/Masterminds/sprig - version: ^2.17.1 -- package: github.com/mkideal/cli -- package: golang.org/x/tools - subpackages: - - imports -- package: github.com/pkg/errors - version: v0.8.0 -testImport: -- package: github.com/stretchr/testify - version: ^1.1.4 -- package: gopkg.in/go-playground/validator.v9 - version: ^9.3.1 diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..bea7874 --- /dev/null +++ b/go.mod @@ -0,0 +1,29 @@ +module github.com/abice/gencheck + +go 1.13 + +require ( + github.com/Bowery/prompt v0.0.0-20180817134258-8a1d5376df1c // indirect + github.com/Masterminds/semver v1.2.2 // indirect + github.com/Masterminds/sprig v2.17.1+incompatible + github.com/aokoli/goutils v1.1.0 // indirect + github.com/go-playground/universal-translator v0.17.0 // indirect + github.com/golang/mock v1.3.1 + github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c + github.com/huandu/xstrings v1.2.0 // indirect + github.com/imdario/mergo v0.0.0-20171009183408-7fe0c75c13ab // indirect + github.com/kevinburke/go-bindata v3.16.0+incompatible + github.com/labstack/gommon v0.2.9-0.20190125185610-82ef680aef51 // indirect + github.com/leodido/go-urn v1.2.0 // indirect + github.com/mattn/go-colorable v0.1.0 // indirect + github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035 // indirect + github.com/mattn/goveralls v0.0.5 + github.com/mkideal/cli v0.0.3-0.20190117035342-a48c2cee5b5e + github.com/mkideal/pkg v0.0.0-20170503154153-3e188c9e7ecc // indirect + github.com/pkg/errors v0.8.0 + github.com/stretchr/testify v1.4.0 + golang.org/x/text v0.3.2 + golang.org/x/tools v0.0.0-20200117173607-7ad9cd8f3189 + gopkg.in/go-playground/assert.v1 v1.2.1 // indirect + gopkg.in/go-playground/validator.v9 v9.31.0 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..7fe7198 --- /dev/null +++ b/go.sum @@ -0,0 +1,83 @@ +github.com/Bowery/prompt v0.0.0-20180817134258-8a1d5376df1c h1:fAMg70P5ydy1uiIj6CdA69h6nmQKbv18VlVOXhKNrcM= +github.com/Bowery/prompt v0.0.0-20180817134258-8a1d5376df1c/go.mod h1:4/6eNcqZ09BZ9wLK3tZOjBA1nDj+B0728nlX5YRlSmQ= +github.com/Masterminds/semver v1.2.2 h1:ptelpryog9A0pR4TGFvIAvw2c8SaNrYkFtfrxhSviss= +github.com/Masterminds/semver v1.2.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= +github.com/Masterminds/sprig v2.17.1+incompatible h1:PChbxFGKTWsg9IWh+pSZRCSj3zQkVpL6Hd9uWsFwxtc= +github.com/Masterminds/sprig v2.17.1+incompatible/go.mod h1:y6hNFY5UBTIWBxnzTeuNhlNS5hqE0NB0E6fgfo2Br3o= +github.com/aokoli/goutils v1.1.0 h1:jy4ghdcYvs5EIoGssZNslIASX5m+KNMfyyKvRQ0TEVE= +github.com/aokoli/goutils v1.1.0/go.mod h1:SijmP0QR8LtwsmDs8Yii5Z/S4trXFGFC2oO5g9DP+DQ= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +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/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c h1:jWtZjFEUE/Bz0IeIhqCnyZ3HG6KRXSntXe4SjtuTH7c= +github.com/google/uuid v0.0.0-20161128191214-064e2069ce9c/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/huandu/xstrings v1.2.0 h1:yPeWdRnmynF7p+lLYz0H2tthW9lqhMJrQV/U7yy4wX0= +github.com/huandu/xstrings v1.2.0/go.mod h1:DvyZB1rfVYsBIigL8HwpZgxHwXozlTgGqn63UyNX5k4= +github.com/imdario/mergo v0.0.0-20171009183408-7fe0c75c13ab h1:k/Biv+LJL35wkk0Hveko1nj7as4tSHkHdZaNlzn/gcQ= +github.com/imdario/mergo v0.0.0-20171009183408-7fe0c75c13ab/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/kevinburke/go-bindata v3.16.0+incompatible h1:TFzFZop2KxGhqNwsyjgmIh5JOrpG940MZlm5gNbxr8g= +github.com/kevinburke/go-bindata v3.16.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM= +github.com/labstack/gommon v0.2.9-0.20190125185610-82ef680aef51 h1:kqWediUZSpRhIW6ZeTClKd1wIT3Hc1PlO3NQIMtKSaw= +github.com/labstack/gommon v0.2.9-0.20190125185610-82ef680aef51/go.mod h1:pnGpdM3THFBN3cctRYV09Bn7QqeQJp4ptXl7VIh2p4I= +github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.0 h1:v2XXALHHh6zHfYTJ+cSkwtyffnaOyR1MXaA91mTrb8o= +github.com/mattn/go-colorable v0.1.0/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035 h1:USWjF42jDCSEeikX/G1g40ZWnsPXN5WkZ4jMHZWyBK4= +github.com/mattn/go-isatty v0.0.5-0.20180830101745-3fb116b82035/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/goveralls v0.0.5 h1:spfq8AyZ0cCk57Za6/juJ5btQxeE1FaEGMdfcI+XO48= +github.com/mattn/goveralls v0.0.5/go.mod h1:Xg2LHi51faXLyKXwsndxiW6uxEEQT9+3sjGzzwU4xy0= +github.com/mkideal/cli v0.0.3-0.20190117035342-a48c2cee5b5e h1:cBVYCHL7QOJRvphH9/81e/rDgW64AkdJSIwx4zgwG4o= +github.com/mkideal/cli v0.0.3-0.20190117035342-a48c2cee5b5e/go.mod h1:HLuSls75T7LFlTgByGeuLwcvdUmmx/aUQxnnEKxoZzY= +github.com/mkideal/pkg v0.0.0-20170503154153-3e188c9e7ecc h1:eyN9UWVX+CeeCQZPudCUAPc84xQYTjEu9MWNa2HuJrs= +github.com/mkideal/pkg v0.0.0-20170503154153-3e188c9e7ecc/go.mod h1:DECgB56amjU/mmmsKuooNPQ1856HASOMC3D4ntSVU70= +github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw= +github.com/pkg/errors v0.8.0/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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasttemplate v0.0.0-20170224212429-dcecefd839c4/go.mod h1:50wTf68f99/Zt14pr046Tgt3Lp2vLyFZKzbFXTOabXw= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550 h1:ObdrDkeb4kJdCP557AjRjq69pTHfNouLtWZG7j9rPN8= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20181217223516-dcdaa6325bcb/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d h1:+R4KGOnez64A81RvjARKc4UT5/tI9ujCIVX+P5KiHuI= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262 h1:qsl9y/CJx34tuA7QCPNp86JNJe4spst6Ff8MjvPUdPg= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20200113040837-eac381796e91 h1:OOkytthzFBKHY5EfEgLUabprb0LtJVkQtNxAQ02+UE4= +golang.org/x/tools v0.0.0-20200113040837-eac381796e91/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117173607-7ad9cd8f3189 h1:8208oB0AyZ5ZA7xACIuGkDVU+o6u+E1ha6CMRcxL2ew= +golang.org/x/tools v0.0.0-20200117173607-7ad9cd8f3189/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +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/go-playground/assert.v1 v1.2.1 h1:xoYuJVE7KT85PYWrN730RguIQO0ePzVRfFMXadIrXTM= +gopkg.in/go-playground/assert.v1 v1.2.1/go.mod h1:9RXL0bg/zibRAgZUYszZSwO/z8Y/a8bDuhia5mkpMnE= +gopkg.in/go-playground/validator.v9 v9.31.0 h1:bmXmP2RSNtFES+bn4uYuHT7iJFJv7Vj+an+ZQdDaD1M= +gopkg.in/go-playground/validator.v9 v9.31.0/go.mod h1:+c9/zcJMFNgbLvly1L1V+PpxWdVbfP1avr/N00E2vyQ= +gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/internal/benchmark/types.go b/internal/benchmark/types.go index 6495d25..b01cf34 100644 --- a/internal/benchmark/types.go +++ b/internal/benchmark/types.go @@ -1,4 +1,4 @@ -//go:generate gencheck -f=types.go +//go:generate ../../bin/gencheck -f=types.go package benchmark diff --git a/internal/example/example.go b/internal/example/example.go index 541796d..2899132 100644 --- a/internal/example/example.go +++ b/internal/example/example.go @@ -1,4 +1,4 @@ -//go:generate gencheck --supp=example_other_file.go -f=example.go +//go:generate ../../bin/gencheck --supp=example_other_file.go -f=example.go package example diff --git a/tools.go b/tools.go new file mode 100644 index 0000000..612666e --- /dev/null +++ b/tools.go @@ -0,0 +1,12 @@ +// +build tools + +package main + +import ( + _ "github.com/golang/mock/mockgen" + _ "github.com/golang/mock/mockgen/model" + _ "github.com/kevinburke/go-bindata/go-bindata" + _ "github.com/mattn/goveralls" + _ "golang.org/x/tools/cmd/cover" + _ "golang.org/x/tools/cmd/goimports" +)