github.com/jdhenke/godel@v0.0.0-20161213181855-abeb3861bf0d/apps/gonform/README.md (about) 1 gonform 2 ======= 3 gonform is a library and CLI for running formatting operations on Go files. It uses 4 [gofmt](https://golang.org/cmd/gofmt/) and [ptimports](https://github.com/palantir/checks/tree/develop/ptimports) as the 5 libraries that perform the formatting operations. 6 7 Documentation 8 ------------- 9 Documentation for gonform is provided in the Go code and as part of the application itself. 10 11 * Run `gonform --help` to get an overview of the commands and flags 12 * gonform is configured using a YML or JSON configuration file. Refer to the documentation in 13 `apps/gonform/config/config.go` for information on the configuration parameters that are available. 14 * Refer to `apps/gonform/config/example_test.go` for sample configuration files 15 16 Development 17 ----------- 18 Use the following commands for development. All paths in the example commands assume that they are run from the root 19 project directory of godel -- if the current working directory is `apps/gonform`, use `../../godelw` instead. 20 21 * Run `./godelw verify` to apply formatting, perform linting checks and run the gödel tests 22 * Run `./godelw test --tags=gonform` to run the gonform-specific tests (not included by default in the tests run by `./godlew verify`) 23 * Run `./godelw build` to build the gonform binary in `apps/gonform/build` 24 25 ### Add a new formatter 26 * In order for a formatter to be added, it must be a Go program that has a main package 27 * The formatters are managed and packaged by [amalgomate](https://github.com/palantir/amalgomate) 28 * Add the code required for the new check (the main package and any supporting code) to the vendor directory 29 * Edit `apps/gonform/formatters.yml` and add an entry for the new formatter 30 * Add an entry to `packages` where the key is the name of the formatter (no whitespace) and the value has a key 31 named `main` and the value is the import path to the main package for the formatter. For more details on the 32 config file format, refer to the documentation for amalgomate. 33 * Run `go generate` in the root directory of the project to re-generate the files in `generated_src` 34 35 ### Generate 36 Run `go generate` in the `apps/gonform` directory to create or update the `generated_src` directory and the source files 37 within it. The `go generate` task for this project requires the amalgomate command to run. The version of amalgomate 38 used to build the distribution is included as a vendored dependency.