https://github.com/peakle/go-rules
Go syntax linter
https://github.com/peakle/go-rules
go golang linter static-analysis syntax-analysis
Last synced: about 1 year ago
JSON representation
Go syntax linter
- Host: GitHub
- URL: https://github.com/peakle/go-rules
- Owner: peakle
- License: mit
- Created: 2023-01-30T14:45:34.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2023-02-09T11:13:48.000Z (about 3 years ago)
- Last Synced: 2025-02-08T04:27:08.382Z (about 1 year ago)
- Topics: go, golang, linter, static-analysis, syntax-analysis
- Language: Go
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# go-rules
Go rules linter
[](https://github.com/peakle/go-rules/blob/master/.github/workflows/ci.yml)
[](https://goreportcard.com/report/github.com/peakle/go-rules)
[](https://pkg.go.dev/github.com/peakle/go-rules)
### How to use:
Full installation example: https://github.com/peakle/dc-rules-example
1. Install rules:
```shell
go get -v github.com/peakle/go-rules
```
2. Create rules.go file in your project like
in [example](https://github.com/peakle/go-rules/tree/master/example/rules.go)
3. Add linter to your pipeline:
1. Like another one check in golangci-lint (will work for golangci-lint >v1.46.0):
``` yaml
linters:
enable:
- gocritic
linters-settings:
gocritic:
enabled-checks:
- ruleguard
settings:
ruleguard:
rules: "YourDir/rules.go"
```
2. Like explicit check WITHOUT golangci-lint:
1. install binary by `curl` or `go install`:
```shell
curl -sSfL https://raw.githubusercontent.com/peakle/go-rules/master/releaser/install.sh | sh -s -- -d -b $(go env GOPATH)/bin latest
```
OR
``` shell
go install -v github.com/peakle/go-rules/cmd/goRules@latest
```
2. Run lint:
``` shell
goRules ./...
```
3. Like file watcher in Goland IDE (will work for golangci-lint >v1.46.0):
1. add golangci-lint as `File Watcher` in IDE (Preferences -> Tools -> File Watchers -> Add)
2. set `Arguments` field where `.golangci.yml` file will be like example above:
```
run $FileDir$ --config=$ProjectFileDir$/.golangci.yml
```
### How to update to new rules version:
1. update rules version in your go.mod file
2. download new rules version:
```shell
go get github.com/peakle/go-rules@newVersion
```
3. if you using golangci-lint update cache:
```shell
golangci-lint cache clean
```
### How to add new checks:
1. Ruleguard tour for newbees: https://go-ruleguard.github.io/by-example
2. Fork repo && open PR :D