github.com/jonsyu1/godel@v0.0.0-20171017211503-64567a0cf169/docs/Exclude.md (about) 1 Summary 2 ------- 3 The `godel/config/exclude.yml` configuration specifies patterns for paths and names that should be ignored. 4 5 Tutorial start state 6 -------------------- 7 8 * `$GOPATH/src/github.com/nmiyake/echgo` exists and is the working directory 9 * Project contains `godel` and `godelw` 10 * Project contains `main.go` 11 * Project contains `.gitignore` that ignores IDEA files 12 * Project contains `echo/echo.go`, `echo/echo_test.go` and `echo/echoer.go` 13 * `godel/config/dist.yml` is configured to build `echgo` 14 * Project is tagged as 0.0.1 15 * `godel/config/dist.yml` is configured to create distributions for `echgo` 16 * Project is tagged as 0.0.2 17 * Go files have license headers 18 * `godel/config/generate.yml` is configured to generate string function 19 20 ([Link](https://github.com/nmiyake/echgo/tree/08752b2ae998c14dd5abb789cebc8f5848f7cf4e)) 21 22 Exclude names/paths 23 ------------------- 24 25 In the previous step of the tutorial, we updated the `godel/config/exclude.yml` configuration file to specify that a 26 generated source file should be excluded from checks. This portion of the tutorial examines the file in more detail. 27 28 Examine the current state of `godel/config/exclude.yml`: 29 30 ``` 31 ➜ cat godel/config/exclude.yml 32 names: 33 - "\\..+" 34 - "vendor" 35 paths: 36 - "godel" 37 - "echo/type_string.go" 38 ``` 39 40 As seen in the previous section, specifying `echo/type_string.go` as an exclude path caused this file to be ignored for 41 all checks and operations. However, listing individual paths like this can be cumbersome and fragile -- for example, if 42 we wanted to use `stringer` for other types or in other packages, this approach would require us to manually add each 43 new entry. 44 45 We can make this approach more general by excluding all files that end in `_string.go` instead. Run the following to 46 update the configuration: 47 48 ``` 49 ➜ echo 'names: 50 - "\\\\..+" 51 - "vendor" 52 - ".+_string.go" 53 paths: 54 - "godel"' > godel/config/exclude.yml 55 ``` 56 57 Verify that the `golint` check still succeeds: 58 59 ``` 60 ➜ ./godelw check golint 61 Running golint... 62 ``` 63 64 Check in the changes: 65 66 ``` 67 ➜ git add godel/config/exclude.yml 68 ➜ git commit -m "Update exclude.yml" 69 [master 1982133] Update exclude.yml 70 1 file changed, 1 insertion(+), 1 deletion(-) 71 ``` 72 73 Tutorial end state 74 ------------------ 75 76 * `$GOPATH/src/github.com/nmiyake/echgo` exists and is the working directory 77 * Project contains `godel` and `godelw` 78 * Project contains `main.go` 79 * Project contains `.gitignore` that ignores IDEA files 80 * Project contains `echo/echo.go`, `echo/echo_test.go` and `echo/echoer.go` 81 * `godel/config/dist.yml` is configured to build `echgo` 82 * Project is tagged as 0.0.1 83 * `godel/config/dist.yml` is configured to create distributions for `echgo` 84 * Project is tagged as 0.0.2 85 * Go files have license headers 86 * `godel/config/generate.yml` is configured to generate string function 87 * `godel/config/exclude.yml` is configured to ignore all `.+_string.go` files 88 89 ([Link](https://github.com/nmiyake/echgo/tree/1982133dbe7c811f1e2d71f4dcc25ff20f84146a)) 90 91 Tutorial next step 92 ------------------ 93 94 [Write integration tests](https://github.com/palantir/godel/wiki/Integration-tests) 95 96 More 97 ---- 98 99 ### Names, paths and default configuration 100 101 `godel/config/exclude.yml` starts with the following defaults: 102 103 ```yml 104 names: 105 - "\\..+" 106 - "vendor" 107 paths: 108 - "godel" 109 ``` 110 111 The `names` configuration specifies a list of names that should be ignored. The values can be literals or regular 112 expressions. In either case, the value must fully match the name to be a match -- for regular expressions, this means 113 that a name is considered a match only if the entire name matches the regular expression. The `names` configuration is 114 useful for ignoring classes of files -- for example, `.*\\.pb\\.go` can be used to ignore all files that end in 115 `.pb.go`. 116 117 The default configuration for `names` ignores all hidden files (names that start with `.`) and all vendor directories. 118 `vendor` is specified as a name rather than a path so that vendor directories are ignored in all directories. 119 120 The `paths` configuration specifies a list of paths that should be ignored. Paths can be specified as literal values or 121 as globs. The `paths` configuration is useful for ignoring specific files or directories that should be ignored. 122 123 The default configuration for `paths` ignores the `godel` directory in the root level of the project. 124 125 In the case of both `names` and `paths`, if the configuration matches a file, that file is ignored, while if it matches 126 a directory, then that directory (and all of its contents) is ignored.