https://github.com/zemanlx/gotests-template
Template for gotests compatible with all linters of golangci-lint.
https://github.com/zemanlx/gotests-template
Last synced: 3 months ago
JSON representation
Template for gotests compatible with all linters of golangci-lint.
- Host: GitHub
- URL: https://github.com/zemanlx/gotests-template
- Owner: zemanlx
- License: apache-2.0
- Created: 2022-01-25T22:10:38.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-04-08T14:27:06.000Z (about 4 years ago)
- Last Synced: 2025-02-05T12:29:46.647Z (over 1 year ago)
- Size: 57.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# gotests-template
Opinionated template for generation of Go tests using
[gotests](https://github.com/cweill/gotests) utility which is natively
integrated to [VS Code Go
extension](https://marketplace.visualstudio.com/items?itemName=golang.go) and
Goland.
## Features
- Uses [go-cmp](github.com/google/go-cmp/cmp) instead of `reflect.DeepEqual`
for non-basic types
- `wantErr`is type of `error` which is enabling use of `errors.Is` in assert
part of tests
- Compatible with all `golangci-lint` linters (whitespace, variable names, etc.)
## Usage
Clone this repository and refer it in VS Code settings:
```json
"go.generateTestsFlags": [
"-template_dir=/path/to/this/repo/gotests-template/cmp-linted"
]
```
For Goland you may need to use *external tool* settings to pass `-template_dir`
option as kindly described in [gotests issue
161](https://github.com/cweill/gotests/issues/161#issuecomment-848329955).