-
Notifications
You must be signed in to change notification settings - Fork 34
Exclude
The exclude block in godel/config/godel.yml
specifies patterns for paths and names that should be ignored.
-
${GOPATH}/src/${PROJECT_PATH}
exists, is the working directory and is initialized as a Git repository - Project contains
godel
andgodelw
- Project contains
main.go
- Project contains
.gitignore
that ignores GoLand files - Project contains
echo/echo.go
,echo/echo_test.go
andecho/echoer.go
-
godel/config/dist-plugin.yml
is configured to buildechgo2
- Project is tagged as 0.0.1
-
godel/config/dist-plugin.yml
is configured to create distributions forechgo
- Project is tagged as 0.0.2
- Go files have license headers
-
godel/config/godel.yml
is configured to add the go-generate plugin -
godel/config/generate-plugin.yml
is configured to generate string function
In the previous step of the tutorial, we updated the exclude
section of godel/config/godel.yml
configuration file to
specify that a generated source file should be excluded from checks. This portion of the tutorial examines the file in
more detail.
Examine the current state of godel/config/godel.yml
:
➜ cat godel/config/godel.yml
plugins:
resolvers:
- "https://palantir.bintray.com/releases/{{GroupPath}}/{{Product}}/{{Version}}/{{Product}}-{{Version}}-{{OS}}-{{Arch}}.tgz"
plugins:
- locator:
id: "com.palantir.godel-generate-plugin:generate-plugin:1.0.0-rc1"
exclude:
names:
- "\\..+"
- "vendor"
paths:
- "godel"
- "echo/type_string.go"
As seen in the previous section, specifying echo/type_string.go
as an exclude path caused this file to be ignored for
all checks and operations. However, listing individual paths like this can be cumbersome and fragile -- for example, if
we wanted to use stringer
for other types or in other packages, this approach would require us to manually add each
new entry.
We can make this approach more general by excluding all files that end in _string.go
instead. Run the following to
update the configuration:
➜ echo 'plugins:
resolvers:
- "https://palantir.bintray.com/releases/{{GroupPath}}/{{Product}}/{{Version}}/{{Product}}-{{Version}}-{{OS}}-{{Arch}}.tgz"
plugins:
- locator:
id: "com.palantir.godel-generate-plugin:generate-plugin:1.0.0-rc1"
exclude:
names:
- "\\\\..+"
- "vendor"
- ".+_string.go"
paths:
- "godel"' > godel/config/godel.yml
Verify that the golint
check still succeeds:
➜ ./godelw check golint
Running golint...
Finished golint
Check in the changes:
➜ git add godel/config/godel.yml
➜ git commit -m "Update exclude configuration in godel.yml"
[master 08fba76] Update exclude configuration in godel.yml
1 file changed, 1 insertion(+), 1 deletion(-)
-
${GOPATH}/src/${PROJECT_PATH}
exists, is the working directory and is initialized as a Git repository - Project contains
godel
andgodelw
- Project contains
main.go
- Project contains
.gitignore
that ignores GoLand files - Project contains
echo/echo.go
,echo/echo_test.go
andecho/echoer.go
-
godel/config/dist-plugin.yml
is configured to buildechgo2
- Project is tagged as 0.0.1
-
godel/config/dist-plugin.yml
is configured to create distributions forechgo
- Project is tagged as 0.0.2
- Go files have license headers
-
godel/config/godel.yml
is configured to add the go-generate plugin -
godel/config/generate-plugin.yml
is configured to generate string function -
godel/config/godel.yml
is configured to ignore all.+_string.go
files
godel/config/godel.yml
starts with the following defaults:
exclude:
names:
- "\\..+"
- "vendor"
paths:
- "godel"
The names
configuration specifies a list of names that should be ignored. The values can be literals or regular
expressions. In either case, the value must fully match the name to be a match -- for regular expressions, this means
that a name is considered a match only if the entire name matches the regular expression. The names
configuration is
useful for ignoring classes of files -- for example, .*\\.pb\\.go
can be used to ignore all files that end in
.pb.go
.
The default configuration for names
ignores all hidden files (names that start with .
) and all vendor directories.
vendor
is specified as a name rather than a path so that vendor directories are ignored in all directories.
The paths
configuration specifies a list of paths that should be ignored. Paths can be specified as literal values or
as globs. The paths
configuration is useful for ignoring specific files or directories that should be ignored.
The default configuration for paths
ignores the godel
directory in the root level of the project.
In the case of both names
and paths
, if the configuration matches a file, that file is ignored, while if it matches
a directory, then that directory (and all of its contents) is ignored.
- Home
-
Tutorial
- Add gödel to a project
- Add Git hooks to enforce formatting
- Generate IDE project for GoLand
- Format Go files
- Run static checks on code
- Run tests
- Build
- Run
- Dist
- Publish
- Build and push Docker images
- Generate license headers
- Go generate tasks
- Define excludes
- Write integration tests
- Sync a documentation directory with GitHub wiki
- Verify project
- Set up CI to run tasks
- Update gödel
- Update legacy gödel
- Other commands
- Conclusion
- Name
- Philosophy
- Architecture
- Plugins
- Configuration