diff --git a/.vendor.txt b/.vendor.txt index 60c3072d..57198930 100644 --- a/.vendor.txt +++ b/.vendor.txt @@ -1,29 +1,28 @@ - ./_vendor/src/golang.org/x/net da118f7b8e5954f39d0d2130ab35d4bf0e3cb344 https://go.googlesource.com/net - ./_vendor/src/golang.org/x/sys 9a7256cb28ed514b4e1e5f68959914c4c28a92e0 https://go.googlesource.com/sys - ./_vendor/src/golang.org/x/crypto 3cb07270c9455e8ad27956a70891c962d121a228 https://go.googlesource.com/crypto - ./_vendor/src/golang.org/x/tools 94b14834a20132093826ea5e2da5502a13908ad3 https://go.googlesource.com/tools + ./_vendor/src/mvdan.cc/sh 43f0b783abe67b568ff4fe4d0b84c44d73eac979 git@github.com:mvdan/sh + ./_vendor/src/honnef.co/go/js/dom 0a64a2db1425c1881d4ec762370250c65f44b85b git@github.com:dominikh/go-js-dom + ./_vendor/src/honnef.co/go/js/xhr 00e3346113aed89b501ead4e863c7c3d04fa0c5b git@github.com:dominikh/go-js-xhr + ./_vendor/src/honnef.co/go/js/util 96b8dd9d16214b6cd9d8c8e84b3a375da4688108 git@github.com:dominikh/go-js-util ./_vendor/src/github.com/jteeuwen/go-bindata a0ff2567cfb70903282db057e799fd826784d41d git@github.com:jteeuwen/go-bindata + ./_vendor/src/github.com/spf13/cobra 16c014f1a19d865b765b420e74508f80eb831ada git@github.com:spf13/cobra + ./_vendor/src/github.com/spf13/pflag 9ff6c6923cfffbcd502984b8e0c80539a94968b7 git@github.com:spf13/pflag + ./_vendor/src/github.com/russross/blackfriday b253417e1cb644d645a0a3bb1fa5034c8030127c git@github.com:russross/blackfriday ./_vendor/src/github.com/gopherjs/gopherjs 8dffc02ea1cb8398bb73f30424697c60fcf8d4c5 git@github.com:gopherjs/gopherjs ./_vendor/src/github.com/gopherjs/jsbuiltin 67703bfb044e3192fbcab025c3aeaeedafad1f2f git@github.com:gopherjs/jsbuiltin ./_vendor/src/github.com/kisielk/gotool 0de1eaf82fa3f583ce21fde859f1e7e0c5e9b220 git@github.com:kisielk/gotool ./_vendor/src/github.com/fsnotify/fsnotify 7d7316ed6e1ed2de075aab8dfc76de5d158d66e1 git@github.com:fsnotify/fsnotify - ./_vendor/src/github.com/spf13/cobra 16c014f1a19d865b765b420e74508f80eb831ada git@github.com:spf13/cobra - ./_vendor/src/github.com/spf13/pflag 9ff6c6923cfffbcd502984b8e0c80539a94968b7 git@github.com:spf13/pflag ./_vendor/src/github.com/kardianos/osext 9d302b58e975387d0b4d9be876622c86cefe64be git@github.com:kardianos/osext ./_vendor/src/github.com/sclevine/agouti 8cf0313221cb2c26a4059f8e273c0856b4cb091d git@github.com:sclevine/agouti ./_vendor/src/github.com/neelance/astrewrite 99348263ae862cc230986ce88deaddbf7edcc034 git@github.com:neelance/astrewrite ./_vendor/src/github.com/neelance/sourcemap 8c68805598ab8d5637b1a72b5f7d381ea0f39c31 git@github.com:neelance/sourcemap ./_vendor/src/github.com/shurcooL/sanitized_anchor_name 79c90efaf01eddc01945af5bc1797859189b830b git@github.com:shurcooL/sanitized_anchor_name ./_vendor/src/github.com/shurcooL/httpfs 809beceb23714880abc4a382a00c05f89d13b1cc git@github.com:shurcooL/httpfs - ./_vendor/src/github.com/russross/blackfriday b253417e1cb644d645a0a3bb1fa5034c8030127c git@github.com:russross/blackfriday - ./_vendor/src/myitcv.io/highlightjs e0ea663591fbdbce10ca2658c680ba7be2391ff8 git@github.com:myitcv/highlightjs - ./_vendor/src/myitcv.io/gogenerate 99436ff35ff9bbe6e17d0b1e93d483d6b5d76528 git@github.com:myitcv/gogenerate + ./_vendor/src/myitcv.io/gogenerate 8ad09dd98465cdb14438b1f82397ad8eb745ec01 git@github.com:myitcv/gogenerate + ./_vendor/src/myitcv.io/immutable d40652f0ca28eff7665d58d506d2ba98ac863f56 git@github.com:myitcv/immutable ./_vendor/src/myitcv.io/gjbt 380934b3729925dd61d0eda6b7513042cfea6914 git@github.com:myitcv/gjbt.git - ./_vendor/src/myitcv.io/gg 6081cb6439ba00f382553b2eadd85c5b3a577816 git@github.com:myitcv/gg + ./_vendor/src/myitcv.io/highlightjs e0ea663591fbdbce10ca2658c680ba7be2391ff8 git@github.com:myitcv/highlightjs + ./_vendor/src/myitcv.io/sorter e31395312285046bfee144dd5347387a9a2358d2 git@github.com:myitcv/sorter ./_vendor/src/myitcv.io/remarkable 6e8b85d04c0c2559fec23559cf88780db6d93083 git@github.com:myitcv/remarkable - ./_vendor/src/myitcv.io/sorter b66c9061eedc0adeb2e46c786bc5a33de021fe24 git@github.com:myitcv/sorter - ./_vendor/src/myitcv.io/immutable 35777ee564a2a4f5ed15aa68792f7e913288409c git@github.com:myitcv/immutable - ./_vendor/src/honnef.co/go/js/xhr 00e3346113aed89b501ead4e863c7c3d04fa0c5b git@github.com:dominikh/go-js-xhr - ./_vendor/src/honnef.co/go/js/util 96b8dd9d16214b6cd9d8c8e84b3a375da4688108 git@github.com:dominikh/go-js-util - ./_vendor/src/honnef.co/go/js/dom 0a64a2db1425c1881d4ec762370250c65f44b85b git@github.com:dominikh/go-js-dom - ./_vendor/src/mvdan.cc/sh 43f0b783abe67b568ff4fe4d0b84c44d73eac979 git@github.com:mvdan/sh + ./_vendor/src/golang.org/x/net da118f7b8e5954f39d0d2130ab35d4bf0e3cb344 https://go.googlesource.com/net + ./_vendor/src/golang.org/x/tools 94b14834a20132093826ea5e2da5502a13908ad3 https://go.googlesource.com/tools + ./_vendor/src/golang.org/x/sys 9a7256cb28ed514b4e1e5f68959914c4c28a92e0 https://go.googlesource.com/sys + ./_vendor/src/golang.org/x/crypto 3cb07270c9455e8ad27956a70891c962d121a228 https://go.googlesource.com/crypto diff --git a/.vendored_bin_deps b/.vendored_bin_deps index 089defa1..8efdc922 100644 --- a/.vendored_bin_deps +++ b/.vendored_bin_deps @@ -2,7 +2,6 @@ github.com/gopherjs/gopherjs github.com/jteeuwen/go-bindata/go-bindata golang.org/x/tools/cmd/goimports golang.org/x/tools/cmd/stringer -myitcv.io/gg myitcv.io/gjbt myitcv.io/immutable/cmd/immutableGen myitcv.io/immutable/cmd/immutableVet diff --git a/_scripts/run_tests.sh b/_scripts/run_tests.sh index 34377110..3e34267e 100755 --- a/_scripts/run_tests.sh +++ b/_scripts/run_tests.sh @@ -38,7 +38,7 @@ find -path ./_vendor -prune -o -name "gen_*.go" -exec rm '{}' \; popd } -gg ./... +go generate ./... z=$(goimports -l !(_vendor|_talks)/**/!(gen_*).go !(gen_*).go) if [ ! -z "$z" ] diff --git a/_vendor/src/myitcv.io/gg/.gitattributes b/_vendor/src/myitcv.io/gg/.gitattributes deleted file mode 100644 index 4235e36d..00000000 --- a/_vendor/src/myitcv.io/gg/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -_vendor/* linguist-vendored diff --git a/_vendor/src/myitcv.io/gg/.travis.yml b/_vendor/src/myitcv.io/gg/.travis.yml deleted file mode 100644 index 966bb9fe..00000000 --- a/_vendor/src/myitcv.io/gg/.travis.yml +++ /dev/null @@ -1,12 +0,0 @@ -language: go - -go: - - 1.x - -go_import_path: myitcv.io/gg - -install: true - -script: - - ./_scripts/run_tests.sh - - ./_scripts/check_git_is_clean.sh diff --git a/_vendor/src/myitcv.io/gg/.vendor.txt b/_vendor/src/myitcv.io/gg/.vendor.txt deleted file mode 100644 index 00478a17..00000000 --- a/_vendor/src/myitcv.io/gg/.vendor.txt +++ /dev/null @@ -1,2 +0,0 @@ - ./_vendor/src/github.com/kisielk/gotool 0de1eaf82fa3f583ce21fde859f1e7e0c5e9b220 git@github.com:kisielk/gotool - ./_vendor/src/myitcv.io/gogenerate bd69a94c96953d20e106734856b69d71c8fa122b git@github.com:myitcv/gogenerate diff --git a/_vendor/src/myitcv.io/gg/LICENSE b/_vendor/src/myitcv.io/gg/LICENSE deleted file mode 100644 index 20513b6a..00000000 --- a/_vendor/src/myitcv.io/gg/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2016 Paul Jolly. All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/_vendor/src/myitcv.io/gg/README.md b/_vendor/src/myitcv.io/gg/README.md deleted file mode 100644 index 8f416a03..00000000 --- a/_vendor/src/myitcv.io/gg/README.md +++ /dev/null @@ -1,48 +0,0 @@ -## `gg` - a tool to wrap `go generate` - -_Very much work in progress._ - -```bash -go get -u myitcv.io/gg - -# list all go:generate directives in packages ./... -gg -l ./... - -# run go generate according to the "algorithm" described below on packages ./... -# here, immutableGen generates code that contains go:generate directives -gg -typed stringer -untyped sortGen,immutableGen,keyGen ./... -``` - -`gg` was born out of the following scenario: - -* it's a good idea to clean all generated files as part of a CI build and regenerate; therefore we need a simple, - reliable means to re-run `go generate` (or similar) on an entire repo of packages -* some `go generate` programs will generate code that itself contains `go generate` directives; this requires `go generate` - to be called multiple times before a "fixed point" is reached -* some `go generate` programs do type checking (e.g. [`stringer`](https://godoc.org/golang.org/x/tools/cmd/stringer)); - let's call these **typed generators** (vs **untyped generators**) -* typed generators often (always?) fail in situations where a package does not compile -* we therefore need to ensure our untyped generators run first and repeatedly until there are no more changes (if we - assume that it is generally generated code from the untyped generators that allows a package to otherwise compile) -* then we can run the typed generators; it there is any change, we need to rinse and repeat with the untyped generators, - then the typed generators... until we reach a fixed point with the typed generators - -Whilst it's possible to achieve all of this on a per-project basis by writing a relatively simple program to wrap things -up, there is some merit in writing a tool to wrap `go generate`: - -* the tool can be reused by others -* existing `go generate` programs can be re-used with zero effort (other than needing to classify them as either typed - or untyped) - - -## TODO - -* The code is very much WIP -* Docs -* Some automatic means of detecting typed vs untyped generators? - -## Credit - -* https://github.com/rsc/gt -* `go generate` source code in [the main Go repo](https://github.com/golang/go/tree/master/src/cmd/go) - diff --git a/_vendor/src/myitcv.io/gg/_scripts/check_git_is_clean.sh b/_vendor/src/myitcv.io/gg/_scripts/check_git_is_clean.sh deleted file mode 100755 index e947d4dc..00000000 --- a/_vendor/src/myitcv.io/gg/_scripts/check_git_is_clean.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2016 Paul Jolly , all rights reserved. -# Use of this document is governed by a license found in the LICENSE document. - -if [ ! -z "$(git status --porcelain)" ] -then - echo "Git is not clean" - git status - exit 1 -fi diff --git a/_vendor/src/myitcv.io/gg/_scripts/run_tests.sh b/_vendor/src/myitcv.io/gg/_scripts/run_tests.sh deleted file mode 100755 index 98ba9c56..00000000 --- a/_vendor/src/myitcv.io/gg/_scripts/run_tests.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -# Copyright (c) 2016 Paul Jolly , all rights reserved. -# Use of this document is governed by a license found in the LICENSE document. - -function error() { - local lineno="$1" - local file="$2" - - # intentional so we can test BASH_SOURCE - if [[ -n "$file" ]] ; then - echo "Error on line $file:$lineno" - fi - - exit 1 -} - -trap 'set +u; error "${LINENO}" "${BASH_SOURCE}"' ERR - -set -u -set -v - -export GOPATH=$PWD/_vendor:$GOPATH -export PATH=$GOPATH/bin:$PATH - -go generate ./... -go test ./... -go install ./... -go vet ./... diff --git a/_vendor/src/myitcv.io/gg/config.go b/_vendor/src/myitcv.io/gg/config.go deleted file mode 100644 index c71a2c32..00000000 --- a/_vendor/src/myitcv.io/gg/config.go +++ /dev/null @@ -1,123 +0,0 @@ -package main - -import ( - "encoding/json" - "log" - "os" - "path/filepath" - "regexp" - "strings" -) - -const ( - ConfigFileName = ".ggconfig.json" -) - -type Config struct { - Typed []string - Untyped []string - - // maps of the packages - typed map[string]struct{} - untyped map[string]struct{} - - // maps of the commands, essentially the bases of the packages - typedCmds map[string]struct{} - untypedCmds map[string]struct{} -} - -var config Config - -var validCmd = regexp.MustCompile(`^[a-zA-Z0-9]+$`) - -func loadConfig() { - if *fUntyped != "" || *fTyped != "" { - config.Untyped = splitCmdList(*fUntyped) - config.Typed = splitCmdList(*fTyped) - } else { - // TODO maybe instead of using $PWD as the starting point for finding a config file we should start at - // the package directory... - - var err error - - wd, err := os.Getwd() - if err != nil { - log.Fatal(err) - } - - dir := wd - - var fi *os.File - - for { - f := filepath.Join(dir, ConfigFileName) - - fi, err = os.Open(f) - if err == nil { - break - } - - p := filepath.Dir(dir) - - if p == dir { - break - } - - dir = p - } - - if fi == nil { - log.Fatalf("Could not find %v in %v (or any parent directory)", ConfigFileName, wd) - } - - j := json.NewDecoder(fi) - err = j.Decode(&config) - if err != nil { - log.Fatalf("Could not decode config file %v:\n%v", fi.Name(), err) - } - } - - config.typed = make(map[string]struct{}) - config.untyped = make(map[string]struct{}) - - config.typedCmds = make(map[string]struct{}) - config.untypedCmds = make(map[string]struct{}) - - for _, v := range config.Typed { - b := filepath.Base(v) - config.typed[v] = struct{}{} - config.typedCmds[b] = struct{}{} - } - - for _, v := range config.Untyped { - b := filepath.Base(v) - config.untyped[v] = struct{}{} - config.untypedCmds[b] = struct{}{} - } - - config.Typed = keySlice(config.typed) - config.Untyped = keySlice(config.untyped) -} - -func splitCmdList(s string) []string { - s = strings.TrimSpace(s) - ps := strings.Split(s, ",") - - parts := make([]string, 0, len(ps)) - - for _, v := range ps { - v = strings.TrimSpace(v) - - if v == "" { - continue - } - - if !validCmd.MatchString(v) { - log.Fatalf("Invalid go generate cmd: %v\n", v) - } - - parts = append(parts, v) - } - - return parts -} diff --git a/_vendor/src/myitcv.io/gg/flag.go b/_vendor/src/myitcv.io/gg/flag.go deleted file mode 100644 index c55d4235..00000000 --- a/_vendor/src/myitcv.io/gg/flag.go +++ /dev/null @@ -1,37 +0,0 @@ -package main - -import ( - "flag" - "fmt" - "log" - "strings" -) - -var ( - fXPkgs xPkgs - fVVerbose = flag.Bool("vv", false, "output commands as they are executed") - fList = flag.Bool("l", false, "list go generate directive commands in packages") - fVerbose = flag.Bool("v", false, "print the names of packages and files as they are processed") - fExecute = flag.Bool("x", false, "print commands as they are executed") - fUntyped = flag.String("untyped", "", "a list of untyped generators to run") - fTyped = flag.String("typed", "", "a list of typed generators to run") -) - -type xPkgs []string - -func (i *xPkgs) Set(value string) error { - if strings.HasPrefix(value, ".") { - log.Fatal("Cannot use \".\" as an exclude pattern") - } - - *i = append(*i, value) - return nil -} - -func (i *xPkgs) String() string { - return fmt.Sprint(*i) -} - -func init() { - flag.Var(&fXPkgs, "X", "packages to exclude") -} diff --git a/_vendor/src/myitcv.io/gg/gg.go b/_vendor/src/myitcv.io/gg/gg.go deleted file mode 100644 index 23866f13..00000000 --- a/_vendor/src/myitcv.io/gg/gg.go +++ /dev/null @@ -1,384 +0,0 @@ -// Copyright (c) 2016 Paul Jolly , all rights reserved. -// Use of this document is governed by a license found in the LICENSE document. - -package main // import "myitcv.io/gg" - -// gg is a wrapper for ``go generate''. More docs to follow - -import ( - "bufio" - "bytes" - "flag" - "fmt" - "log" - "os" - "os/exec" - "path/filepath" - "regexp" - "sort" - "strings" - "time" - - "github.com/kisielk/gotool" - "myitcv.io/gogenerate" -) - -const ( - untypedLoopLimit = 10 - typedLoopLimit = untypedLoopLimit -) - -var ( - wd string -) - -// All code basically derived from rsc.io/gt - -// TODO we effectively read from some files twice... whilst computing stale and scanning -// for directives. These two operations could potentially be collapsed into a single read - -func main() { - var err error - - log.SetFlags(0) - log.SetPrefix("gg: ") - - defer func() { - err := recover() - if err != nil { - log.Fatalln(err) - } - }() - - flag.Parse() - - wd, err = os.Getwd() - if err != nil { - fatalf("could not get working directory: %v", err) - } - - loadConfig() - - specs := gotool.ImportPaths(flag.Args()) - sort.Strings(specs) - - readPkgs(specs, true) - - pkgs := make([]string, 0, len(pkgInfo)) - for k := range pkgInfo { - pkgs = append(pkgs, k) - } - - pkgs = cmdList(pkgs) - - if len(pkgs) == 0 { - vvlogf("No packages contain any directives") - os.Exit(0) - } - - if *fList { - // cmdList above will have done the logging for us - - os.Exit(0) - } - - untypedRunExp := buildGoGenRegex(config.Untyped) - typedRunExp := buildGoGenRegex(config.Typed) - - diffs := computeStale(pkgs, false) - - typedCount := 1 - - for { - untypedCount := 1 - - preUntyped := snapHash(diffs) - - for len(diffs) > 0 { - if untypedCount > untypedLoopLimit { - fatalf("Exceeded loop limit for untyped go generate cmd: %v\n", untypedRunExp) - } - - vvlogf("Untyped iteration %v.%v\n", typedCount, untypedCount) - goGenerate(diffs, untypedRunExp) - untypedCount++ - - // order is significant here... because the computeStale - // call does a readPkgs - prevDiffs := diffs - diffs = computeStale(prevDiffs, true) - cmdList(prevDiffs) - } - - // TODO work out what to do here when gg is being used in conjunction - // with gai - t := time.Now() - vvlogf("pre go install") - suc, _ := goInstall(pkgs) - vvlogf("post go install %v", time.Now().Sub(t)) - - if len(suc) == 0 { - fatalf("No packages from %v succeeded install; cannot continue\n", pkgs) - } - - if typedCount > typedLoopLimit { - fatalf("Exceeded loop limit for typed go generate cmd: %v\n", untypedRunExp) - } - - vvlogf("Typed iteration %v.0\n", typedCount) - goGenerate(suc, typedRunExp) - typedCount++ - - // order is significant here... because the computeStale - // call does a readPkgs - computeStale(suc, true) - cmdList(suc) - - postTypedDelta := deltaHash(preUntyped) - - // if there has been no change then regardless of how many fails etc - // we should break - if len(postTypedDelta) == 0 { - vvlogf("no delta from start of untyped iteration; breaking") - break - } - - pkgs = postTypedDelta - } -} - -func buildGoGenRegex(parts []string) string { - escpd := make([]string, len(parts)) - - for i := range parts { - cmd := filepath.Base(parts[i]) - escpd[i] = regexp.QuoteMeta(cmd) - } - - exp := fmt.Sprintf(gogenerate.GoGeneratePrefix+" (?:%v)(?:$| )", strings.Join(escpd, "|")) - - // aggressively ensure the regexp compiles here... else a call to go generate - // will be useless - _, err := regexp.Compile(exp) - if err != nil { - fatalf("Could not form valid go generate command: %v\n", err) - } - - return exp -} - -func goGenerate(pkgs []string, runExp string) { - args := []string{"generate"} - - if *fVerbose { - args = append(args, "-v") - } - - if *fExecute { - args = append(args, "-x") - } - - args = append(args, "-run", runExp) - args = append(args, pkgs...) - - xlogf("go %v", strings.Join(args, " ")) - - out, err := exec.Command("go", args...).CombinedOutput() - if err != nil { - fatalf("go generate: %v\n%s", err, out) - } - - if len(out) > 0 { - // we always log the output from go generate - fmt.Print(string(out)) - } -} - -func goInstall(pkgs []string) ([]string, []string) { - fmap := make(map[string]struct{}) - - xlogf("gai %v", strings.Join(pkgs, " ")) - vvlogf("gai %v", strings.Join(pkgs, " ")) - - out, err := exec.Command("gai", pkgs...).CombinedOutput() - if err != nil { - sc := bufio.NewScanner(bytes.NewBuffer(out)) - for sc.Scan() { - line := sc.Text() - - if strings.HasPrefix(line, "# ") { - parts := strings.Fields(line) - - if len(parts) != 2 { - fatalf("could not parse go install output\n%v", string(out)) - } - - fmap[parts[1]] = struct{}{} - } - } - - if err := sc.Err(); err != nil { - fatalf("could not parse go install output\n%v", string(out)) - } - } - - if len(out) > 0 { - xlog(string(out)) - } - - var f, s []string - - for _, p := range pkgs { - if _, ok := fmap[p]; ok { - f = append(f, p) - } else { - s = append(s, p) - } - } - - return s, f -} - -// cmdList returns a subset of packages (subset of pNames) that contain directives -// and a map[package] -> map[cmd]struct{} of which commands are used in which packages -// As it scans each package in pNames it removes any generated files that do not have -// an occurence of a directive for the associated generator in the package (not test -// aware right now). In the process it also validates the directives that are present -func cmdList(pNames []string) []string { - cmds := make(map[string]map[string]struct{}) - - for _, pName := range pNames { - var h map[string]struct{} - - pkg := pkgInfo[pName] - - var goFiles []string - goFiles = append(goFiles, pkg.GoFiles...) - goFiles = append(goFiles, pkg.CgoFiles...) - goFiles = append(goFiles, pkg.TestGoFiles...) - goFiles = append(goFiles, pkg.XTestGoFiles...) - - cmdFiles := make(map[string][]string) - - for _, f := range goFiles { - f = filepath.Join(pkg.Dir, f) - - visitDir := func(line int, dirArgs []string) error { - if *fList { - rel, err := filepath.Rel(wd, f) - if err != nil { - fatalf("could not create filepath.Re(%q, %q): %q", wd, f, err) - } - fmt.Printf("%v:%v: %v\n", rel, line, strings.Join(dirArgs, " ")) - } - if h == nil { - h = make(map[string]struct{}) - cmds[pName] = h - } - - h[dirArgs[0]] = struct{}{} - - return nil - } - - if cmd, ok := gogenerate.FileIsGenerated(f); ok { - // we only care about cmds which we know about in our config - // for now this helps to deal with the edge case that is protobuf - // files - - _, oktyp := config.typedCmds[cmd] - _, okuntyp := config.untypedCmds[cmd] - - if oktyp || okuntyp { - cmdFiles[cmd] = append(cmdFiles[cmd], f) - } - } - - gogenerate.DirFunc(pName, f, visitDir) - } - - removed := false - - for c, fs := range cmdFiles { - if _, ok := h[c]; !ok { - for _, f := range fs { - vvlogf("removing %v", f) - - removed = true - - err := os.Remove(f) - if err != nil { - fatalf("could not remove %v: %v", f, err) - } - } - } - } - - if removed { - readPkgs([]string{pName}, false) - } - } - - cm := cmdMap(cmds) - - for v := range cm { - - _, tok := config.typedCmds[v] - _, uok := config.untypedCmds[v] - - if !tok && !uok { - log.Fatalf("go generate directive command \"%v\" is not specified as either typed or untyped", v) - } - } - - dirPkgs := make([]string, 0, len(cmds)) - for k := range cmds { - dirPkgs = append(dirPkgs, k) - } - - return dirPkgs -} - -func fatalf(format string, args ...interface{}) { - panic(fmt.Errorf(format, args...)) -} - -func xlog(args ...interface{}) { - if *fVVerbose || *fExecute { - log.Print(args...) - } -} - -func xlogf(format string, args ...interface{}) { - if *fVVerbose || *fExecute { - log.Print(args...) - } -} - -func vvlogf(format string, args ...interface{}) { - if *fVVerbose { - log.Printf(format, args...) - } -} - -func cmdMap(cmds map[string]map[string]struct{}) map[string]struct{} { - allCmds := make(map[string]struct{}) - - for _, m := range cmds { - for k := range m { - allCmds[k] = struct{}{} - } - } - - return allCmds -} - -func keySlice(m map[string]struct{}) []string { - res := make([]string, 0, len(m)) - - for k := range m { - res = append(res, k) - } - - return res -} diff --git a/_vendor/src/myitcv.io/gg/pkg.go b/_vendor/src/myitcv.io/gg/pkg.go deleted file mode 100644 index 9bc4e29b..00000000 --- a/_vendor/src/myitcv.io/gg/pkg.go +++ /dev/null @@ -1,133 +0,0 @@ -package main - -import ( - "crypto/sha1" - "fmt" - "go/build" - "io" - "os" - "path/filepath" - "strings" -) - -var ( - pkgInfo = map[string]*Package{} -) - -type Package struct { - *build.Package - - pkgHash string -} - -func readPkgs(pkgs []string, ignore bool) { - -All: - for _, pn := range pkgs { - p, err := build.Import(pn, wd, 0) - if err != nil { - fatalf("could not load package %v: %v", pn, err) - } - - if ignore { - a := p.ImportPath - - for _, x := range fXPkgs { - if strings.HasSuffix(x, "/...") { - p := strings.TrimSuffix(x, "/...") - - if a == p || strings.HasPrefix(a, p+"/") { - continue All - } - } else { - if a == x { - continue All - } - } - - } - - } - - pkgInfo[p.ImportPath] = &Package{Package: p} - } -} - -func snapHash(pkgs []string) map[string]string { - prevHashes := make(map[string]string, len(pkgs)) - for _, p := range pkgs { - v := "" - - if pkg, ok := pkgInfo[p]; ok { - v = pkg.pkgHash - } - - prevHashes[p] = v - } - - return prevHashes -} - -func computeStale(pkgs []string, read bool) []string { - snap := snapHash(pkgs) - - if read { - readPkgs(pkgs, false) - } - - for _, pkg := range pkgs { - computePkgHash(pkgInfo[pkg]) - } - - return deltaHash(snap) -} - -func deltaHash(snap map[string]string) []string { - var deltas []string - - for p := range snap { - if snap[p] != pkgInfo[p].pkgHash { - deltas = append(deltas, p) - } - } - - return deltas -} - -func computePkgHash(p *Package) { - h := sha1.New() - - fmt.Fprintf(h, "pkg %v\n", p.ImportPath) - - hashFiles(h, p.Dir, p.GoFiles) - hashFiles(h, p.Dir, p.CgoFiles) - hashFiles(h, p.Dir, p.CFiles) - hashFiles(h, p.Dir, p.CXXFiles) - hashFiles(h, p.Dir, p.MFiles) - hashFiles(h, p.Dir, p.HFiles) - hashFiles(h, p.Dir, p.SFiles) - hashFiles(h, p.Dir, p.SwigFiles) - hashFiles(h, p.Dir, p.SwigCXXFiles) - hashFiles(h, p.Dir, p.SysoFiles) - hashFiles(h, p.Dir, p.TestGoFiles) - hashFiles(h, p.Dir, p.XTestGoFiles) - - hash := fmt.Sprintf("%x", h.Sum(nil)) - p.pkgHash = hash -} - -func hashFiles(h io.Writer, dir string, files []string) { - for _, file := range files { - fn := filepath.Join(dir, file) - f, err := os.Open(fn) - if err != nil { - fatalf("could not open file %v: %v\n", fn, err) - } - - fmt.Fprintf(h, "file %s\n", file) - n, _ := io.Copy(h, f) - fmt.Fprintf(h, "%d bytes\n", n) - - f.Close() - } -} diff --git a/_vendor/src/myitcv.io/gogenerate/.travis.yml b/_vendor/src/myitcv.io/gogenerate/.travis.yml index 5fc04532..3a7b06ac 100644 --- a/_vendor/src/myitcv.io/gogenerate/.travis.yml +++ b/_vendor/src/myitcv.io/gogenerate/.travis.yml @@ -1,5 +1,12 @@ language: go +notifications: + email: + recipients: + - paul@myitcv.io + on_success: change + on_failure: always + go: - 1.x diff --git a/_vendor/src/myitcv.io/gogenerate/_testFiles/eg01/d.go b/_vendor/src/myitcv.io/gogenerate/_testFiles/eg01/d.go index 8bf6dedc..3601541b 100644 --- a/_vendor/src/myitcv.io/gogenerate/_testFiles/eg01/d.go +++ b/_vendor/src/myitcv.io/gogenerate/_testFiles/eg01/d.go @@ -1,3 +1,4 @@ package main //go:generate "/bin/ls" +//go:generate "ls" diff --git a/_vendor/src/myitcv.io/gogenerate/coregogenerate.go b/_vendor/src/myitcv.io/gogenerate/coregogenerate.go index 57672d77..2fbced99 100644 --- a/_vendor/src/myitcv.io/gogenerate/coregogenerate.go +++ b/_vendor/src/myitcv.io/gogenerate/coregogenerate.go @@ -51,7 +51,6 @@ import ( type generator struct { f func(line int, dirArgs []string) error r io.Reader - path string // full rooted path name. dir string // full rooted directory of file. file string // base name of file. pkg string @@ -63,8 +62,8 @@ type generator struct { // DirFunc runs f(cmds) on each go generate directive (as defined by // go generate -help) found in the absolute-named file that is part // of package pkg -func DirFunc(pkg string, name string, f func(line int, dirArgs []string) error) error { - fi, err := os.Open(name) +func DirFunc(pkg string, dir, file string, f func(line int, dirArgs []string) error) error { + fi, err := os.Open(filepath.Join(dir, file)) if err != nil { return err } @@ -74,7 +73,8 @@ func DirFunc(pkg string, name string, f func(line int, dirArgs []string) error) f: f, pkg: pkg, commands: make(map[string][]string), - path: name, + dir: dir, + file: file, r: fi, } @@ -92,9 +92,6 @@ func (g *generator) matches() (err error) { } }() - g.dir, g.file = filepath.Split(g.path) - g.dir = filepath.Clean(g.dir) // No final separator please. - // Scan for lines that start "//go:generate". // Can't use bufio.Scanner because it can't handle long lines, // which are likely to appear when using generate. @@ -235,7 +232,7 @@ Words: // It then exits the program (with exit status 1) because generation stops // at the first error. func (g *generator) errorf(format string, args ...interface{}) { - panic(fmt.Errorf("%s:%d: %s", g.path, g.lineNum, fmt.Sprintf(format, args...))) + panic(fmt.Errorf("%s:%d: %s", filepath.Join(g.dir, g.file), g.lineNum, fmt.Sprintf(format, args...))) } // expandVar expands the $XXX invocation in word. It is called diff --git a/_vendor/src/myitcv.io/gogenerate/gogenerate.go b/_vendor/src/myitcv.io/gogenerate/gogenerate.go index 80bb5208..6f3f50f7 100644 --- a/_vendor/src/myitcv.io/gogenerate/gogenerate.go +++ b/_vendor/src/myitcv.io/gogenerate/gogenerate.go @@ -16,7 +16,6 @@ import ( "go/build" "os" "path/filepath" - "sort" "strings" ) @@ -48,11 +47,14 @@ const ( const ( // FlagLog is the name of the common flag shared between go generate generators - // to control logging verbosity + // to control logging verbosity. FlagLog = "gglog" + // FlagOutPkgPrefix is the prefix used for flags generated by OutPkgFlag. + FlagOutPkgPrefix = "outpkg:" + // FlagLicenseFile is the name of the common flag shared between go generate generators - // to provide a license header file + // to provide a license header file. FlagLicenseFile = "licenseFile" ) @@ -168,12 +170,12 @@ func (o *outputs) Set(value string) error { var outputsSet = make(map[string]bool) -// OutputFlag defines a new flag "outpkg:"+key that can accept a list of +// OutPkgFlag defines a new flag "outpkg:"+key that can accept a list of // package specifications that represent output targets above and beyond the // default of self. -func OutputFlag(key string) *outputs { +func OutPkgFlag(key string) *outputs { if outputsSet[key] { - panic(fmt.Errorf("already defined output flag for key %q", key)) + panic(fmt.Errorf("already defined outpkg flag for key %q", key)) } // safe doing this because we should be in init phase @@ -244,24 +246,16 @@ func DefaultLogLevel(f *string, ll LogLevel) { } } -// FilesContainingCmd returns a sorted list of Go file names (defined by go list as -// GoFiles + CgoFiles + TestGoFiles + XTestGoFiles) in the directory dir that -// contain a command matching any of the provided commands after quote and -// variable expansion (as described by go generate -help). When comparing commands, -// the filepath.Base of each is compared. The file names will, by definition, be -// relative to dir -func FilesContainingCmd(dir string, commands ...string) ([]string, error) { - - // clean our commands - nonZero := false - for i, c := range commands { - c = strings.TrimSpace(c) - if c != "" { - nonZero = true - } - commands[i] = filepath.Base(c) - } - if !nonZero { +// FilesContainingCmd returns a map of Go file name (defined by go list as +// GoFiles + CgoFiles + TestGoFiles + XTestGoFiles) in the directory dir, to a +// count of the number of times directive command appears in that file. (after +// quote and variable expansion as described by go generate -help). When +// comparing commands, the filepath.Base of each is compared. The file names +// will, by definition, be relative to dir +func FilesContainingCmd(dir string, command string) (map[string]int, error) { + + command = filepath.Base(strings.TrimSpace(command)) + if command == "" { return nil, nil } @@ -278,34 +272,23 @@ func FilesContainingCmd(dir string, commands ...string) ([]string, error) { gofiles = append(gofiles, pkg.TestGoFiles...) gofiles = append(gofiles, pkg.XTestGoFiles...) - matchMap := make(map[string]struct{}) + matchMap := make(map[string]int) for _, f := range gofiles { checkMatch := func(line int, args []string) error { - for _, cmd := range commands { - if filepath.Base(args[0]) == cmd { - matchMap[f] = struct{}{} - } + if filepath.Base(args[0]) == command { + matchMap[f] += 1 } return nil } - fp := filepath.Join(dir, f) - - err = DirFunc(pkg.ImportPath, fp, checkMatch) + err = DirFunc(pkg.ImportPath, dir, f, checkMatch) if err != nil { return nil, err } } - matches := make([]string, 0, len(matchMap)) - for k := range matchMap { - matches = append(matches, k) - } - sort.Slice(matches, func(i, j int) bool { - return filepath.Base(matches[i]) < filepath.Base(matches[j]) - }) - return matches, nil + return matchMap, nil } diff --git a/_vendor/src/myitcv.io/gogenerate/gogenerate_test.go b/_vendor/src/myitcv.io/gogenerate/gogenerate_test.go index 1ff783c4..a61554a3 100644 --- a/_vendor/src/myitcv.io/gogenerate/gogenerate_test.go +++ b/_vendor/src/myitcv.io/gogenerate/gogenerate_test.go @@ -6,7 +6,6 @@ package gogenerate import ( "os" "path/filepath" - "sort" "testing" ) @@ -18,10 +17,10 @@ func TestFilesContaining(t *testing.T) { checks := []struct { d string - cmds []string - matches []string + cmds string + matches map[string]int }{ - {"_testFiles/eg01", []string{"ls", "/bin/ls"}, []string{"a.go", "b.go", "c.go", "d.go"}}, + {"_testFiles/eg01", "/bin/ls", map[string]int{"a.go": 1, "b.go": 1, "c.go": 1, "d.go": 2}}, } Checks: @@ -29,7 +28,7 @@ Checks: path := filepath.Join(cwd, c.d) - res, err := FilesContainingCmd(path, c.cmds...) + res, err := FilesContainingCmd(path, c.cmds) if err != nil { t.Errorf("Got unexpected error find matches in %v: %v", c.d, err) continue Checks @@ -40,10 +39,6 @@ Checks: continue Checks } - // just in case we were sloppy in the test table - sort.Slice(c.matches, func(i, j int) bool { - return filepath.Base(c.matches[i]) < filepath.Base(c.matches[j]) - }) for i := range res { if res[i] != c.matches[i] { t.Errorf("Matches not up to expectations: %v vs %v", res, c.matches) diff --git a/_vendor/src/myitcv.io/immutable/.vendor.txt b/_vendor/src/myitcv.io/immutable/.vendor.txt index baf52abb..e3ac88ba 100644 --- a/_vendor/src/myitcv.io/immutable/.vendor.txt +++ b/_vendor/src/myitcv.io/immutable/.vendor.txt @@ -1,2 +1,2 @@ + ./_vendor/src/myitcv.io/gogenerate 8ad09dd98465cdb14438b1f82397ad8eb745ec01 git@github.com:myitcv/gogenerate ./_vendor/src/golang.org/x/tools 721f218496963f33ebc9fbc5cdbdeed007ad9c49 https://go.googlesource.com/tools - ./_vendor/src/myitcv.io/gogenerate 99436ff35ff9bbe6e17d0b1e93d483d6b5d76528 git@github.com:myitcv/gogenerate diff --git a/_vendor/src/myitcv.io/immutable/cmd/immutableGen/immutableGen.go b/_vendor/src/myitcv.io/immutable/cmd/immutableGen/immutableGen.go index 8104d5d2..0833db2b 100644 --- a/_vendor/src/myitcv.io/immutable/cmd/immutableGen/immutableGen.go +++ b/_vendor/src/myitcv.io/immutable/cmd/immutableGen/immutableGen.go @@ -52,12 +52,12 @@ func main() { fatalf("could not determine if we are the first file: %v", err) } - if len(dirFiles) == 0 { + if dirFiles == nil { fatalf("cannot find any files containing the %v directive", immutableGenCmd) } - if envFile != dirFiles[0] { - return + if dirFiles[envFile] != 1 { + fatalf("expected a single occurrence of %v directive in %v. Got: %v", immutableGenCmd, envFile, dirFiles) } licenseHeader, err := gogenerate.CommentLicenseHeader(fLicenseFile) diff --git a/_vendor/src/myitcv.io/immutable/example/gen_example_immutableGen.go b/_vendor/src/myitcv.io/immutable/example/gen_example_immutableGen.go index 6101f11d..efe8c987 100644 --- a/_vendor/src/myitcv.io/immutable/example/gen_example_immutableGen.go +++ b/_vendor/src/myitcv.io/immutable/example/gen_example_immutableGen.go @@ -1,11 +1,7 @@ // Code generated by immutableGen. DO NOT EDIT. -// Copyright (c) 2016 Paul Jolly , all rights reserved. -// Use of this document is governed by a license found in the LICENSE document. - package example -//go:generate echo "hello world" //immutableVet:skipFile import ( diff --git a/_vendor/src/myitcv.io/immutable/example/gen_example_immutableGen_test.go b/_vendor/src/myitcv.io/immutable/example/gen_example_immutableGen_test.go index bfdcb4c8..91a2a9f5 100644 --- a/_vendor/src/myitcv.io/immutable/example/gen_example_immutableGen_test.go +++ b/_vendor/src/myitcv.io/immutable/example/gen_example_immutableGen_test.go @@ -1,11 +1,7 @@ // Code generated by immutableGen. DO NOT EDIT. -// Copyright (c) 2016 Paul Jolly , all rights reserved. -// Use of this document is governed by a license found in the LICENSE document. - package example -//go:generate echo "hello world" //immutableVet:skipFile import ( diff --git a/_vendor/src/myitcv.io/immutable/example/gen_strings_immutableGen.go b/_vendor/src/myitcv.io/immutable/example/gen_strings_immutableGen.go index 3d3c74f8..6f7baf87 100644 --- a/_vendor/src/myitcv.io/immutable/example/gen_strings_immutableGen.go +++ b/_vendor/src/myitcv.io/immutable/example/gen_strings_immutableGen.go @@ -1,11 +1,7 @@ // Code generated by immutableGen. DO NOT EDIT. -// Copyright (c) 2016 Paul Jolly , all rights reserved. -// Use of this document is governed by a license found in the LICENSE document. - package example -//go:generate echo "hello world" //immutableVet:skipFile import ( diff --git a/_vendor/src/myitcv.io/sorter/.vendor.txt b/_vendor/src/myitcv.io/sorter/.vendor.txt index af8f93fb..0d12f565 100644 --- a/_vendor/src/myitcv.io/sorter/.vendor.txt +++ b/_vendor/src/myitcv.io/sorter/.vendor.txt @@ -1,3 +1,3 @@ + ./_vendor/src/myitcv.io/gogenerate 8ad09dd98465cdb14438b1f82397ad8eb745ec01 git@github.com:myitcv/gogenerate + ./_vendor/src/myitcv.io/immutable d40652f0ca28eff7665d58d506d2ba98ac863f56 git@github.com:myitcv/immutable ./_vendor/src/golang.org/x/tools 721f218496963f33ebc9fbc5cdbdeed007ad9c49 https://go.googlesource.com/tools - ./_vendor/src/myitcv.io/gogenerate 99436ff35ff9bbe6e17d0b1e93d483d6b5d76528 git@github.com:myitcv/gogenerate - ./_vendor/src/myitcv.io/immutable 35777ee564a2a4f5ed15aa68792f7e913288409c git@github.com:myitcv/immutable diff --git a/_vendor/src/myitcv.io/sorter/cmd/sortGen/sort_gen.go b/_vendor/src/myitcv.io/sorter/cmd/sortGen/sort_gen.go index 851f413d..0bf91dd3 100644 --- a/_vendor/src/myitcv.io/sorter/cmd/sortGen/sort_gen.go +++ b/_vendor/src/myitcv.io/sorter/cmd/sortGen/sort_gen.go @@ -77,7 +77,7 @@ func main() { gogenerate.DefaultLogLevel(fGoGenLog, gogenerate.LogFatal) - envFileName, ok := os.LookupEnv(gogenerate.GOFILE) + envFile, ok := os.LookupEnv(gogenerate.GOFILE) if !ok { fatalf("env not correct; missing %v", gogenerate.GOFILE) } @@ -87,19 +87,17 @@ func main() { fatalf("unable to get working directory: %v", err) } - // are we running against the first file that contains the sortGen directive? - // if not return dirFiles, err := gogenerate.FilesContainingCmd(wd, sortGenCmd) if err != nil { fatalf("could not determine if we are the first file: %v", err) } - if len(dirFiles) == 0 { + if dirFiles == nil { fatalf("cannot find any files containing the %v directive", sortGenCmd) } - if envFileName != dirFiles[0] { - return + if dirFiles[envFile] != 1 { + fatalf("expected a single occurrence of %v directive in %v. Got: %v", sortGenCmd, envFile, dirFiles) } license, err := gogenerate.CommentLicenseHeader(fLicenseFile) diff --git a/cmd/coreGen/coreGen.go b/cmd/coreGen/coreGen.go index 3abbf41f..aae308e4 100644 --- a/cmd/coreGen/coreGen.go +++ b/cmd/coreGen/coreGen.go @@ -44,7 +44,7 @@ func main() { func mainGen(wd string) { gogenerate.DefaultLogLevel(fGoGenLog, gogenerate.LogFatal) - envFileName, ok := os.LookupEnv(gogenerate.GOFILE) + envFile, ok := os.LookupEnv(gogenerate.GOFILE) if !ok { fatalf("env not correct; missing %v", gogenerate.GOFILE) } @@ -54,19 +54,17 @@ func mainGen(wd string) { fatalf("env not correct; missing %v", gogenerate.GOPACKAGE) } - // are we running against the first file that contains the coreGen directive? - // if not return dirFiles, err := gogenerate.FilesContainingCmd(wd, coreGenCmd) if err != nil { fatalf("could not determine if we are the first file: %v", err) } - if len(dirFiles) == 0 { + if dirFiles == nil { fatalf("cannot find any files containing the %v directive", coreGenCmd) } - if envFileName != dirFiles[0] { - return + if dirFiles[envFile] != 1 { + fatalf("expected a single occurrence of %v directive in %v. Got: %v", coreGenCmd, envFile, dirFiles) } license, err := gogenerate.CommentLicenseHeader(fLicenseFile) diff --git a/cmd/reactGen/react_gen.go b/cmd/reactGen/react_gen.go index 8b6a4199..ee6ccf8f 100644 --- a/cmd/reactGen/react_gen.go +++ b/cmd/reactGen/react_gen.go @@ -52,24 +52,22 @@ func mainInit(wd string) { func mainGen(wd string) { gogenerate.DefaultLogLevel(fGoGenLog, gogenerate.LogFatal) - envFileName, ok := os.LookupEnv(gogenerate.GOFILE) + envFile, ok := os.LookupEnv(gogenerate.GOFILE) if !ok { fatalf("env not correct; missing %v", gogenerate.GOFILE) } - // are we running against the first file that contains the reactGen directive? - // if not return dirFiles, err := gogenerate.FilesContainingCmd(wd, reactGenCmd) if err != nil { fatalf("could not determine if we are the first file: %v", err) } - if len(dirFiles) == 0 { + if dirFiles == nil { fatalf("cannot find any files containing the %v directive", reactGenCmd) } - if envFileName != dirFiles[0] { - return + if dirFiles[envFile] != 1 { + fatalf("expected a single occurrence of %v directive in %v. Got: %v", reactGenCmd, envFile, dirFiles) } license, err := gogenerate.CommentLicenseHeader(fLicenseFile) diff --git a/cmd/stateGen/state_gen.go b/cmd/stateGen/state_gen.go index b105670d..b1534393 100644 --- a/cmd/stateGen/state_gen.go +++ b/cmd/stateGen/state_gen.go @@ -34,7 +34,7 @@ func main() { gogenerate.DefaultLogLevel(fGoGenLog, gogenerate.LogFatal) - envFileName, ok := os.LookupEnv(gogenerate.GOFILE) + envFile, ok := os.LookupEnv(gogenerate.GOFILE) if !ok { fatalf("env not correct; missing %v", gogenerate.GOFILE) } @@ -44,19 +44,17 @@ func main() { fatalf("unable to get working directory: %v", err) } - // are we running against the first file that contains the stateGen directive? - // if not return dirFiles, err := gogenerate.FilesContainingCmd(wd, stateGenCmd) if err != nil { fatalf("could not determine if we are the first file: %v", err) } - if len(dirFiles) == 0 { + if dirFiles == nil { fatalf("cannot find any files containing the %v directive", stateGenCmd) } - if envFileName != dirFiles[0] { - return + if dirFiles[envFile] != 1 { + fatalf("expected a single occurrence of %v directive in %v. Got: %v", stateGenCmd, envFile, dirFiles) } license, err := gogenerate.CommentLicenseHeader(fLicenseFile) diff --git a/examples/blog/2017_04_16/main.go b/examples/blog/2017_04_16/main.go index 75480aa2..f55faa46 100644 --- a/examples/blog/2017_04_16/main.go +++ b/examples/blog/2017_04_16/main.go @@ -8,8 +8,6 @@ import ( "honnef.co/go/js/dom" ) -//go:generate reactGen - var document = dom.GetWindow().Document() func main() { diff --git a/examples/sites/latency/latency.go b/examples/sites/latency/latency.go index 09a6d6bc..1812a936 100644 --- a/examples/sites/latency/latency.go +++ b/examples/sites/latency/latency.go @@ -11,7 +11,6 @@ import ( "myitcv.io/react/jsx" ) -//go:generate reactGen //go:generate immutableGen type location string