Skip to content

Commit

Permalink
Go lang linter (#53)
Browse files Browse the repository at this point in the history
* Add GO lang linter to GH workflow and pre-commit hook

* fix .golangci.yaml

* go lang ci lint workflow

* remove comments from golang-ci.yml
  • Loading branch information
tomas-balaz authored Nov 30, 2021
1 parent b706560 commit aef471c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: golangci-lint
on:
push:
pull_request:
permissions:
contents: read

jobs:
golangci:
name: GO lang CI linter
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/golangci-lint-action@v2 # https://github.com/marketplace/actions/run-golangci-lint
with:
version: v1.43
11 changes: 11 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
linters:
enable:
- megacheck
- gofmt
- govet
- revive # replacement for golint

linters-settings:
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: true
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: trailing-whitespace
- id: check-merge-conflict
- id: end-of-file-fixer

- repo: https://github.com/golangci/golangci-lint
rev: v1.43.0
hooks:
- id: golangci-lint
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,17 @@ docker run --rm -p 8080:8080 -i ghcr.io/lablabs/cloudflare_exporter --help
## Contributing and reporting issues
Feel free to create an issue in this repository if you have questions, suggestions or feature requests.

### Validation, linters and pull-requests

We want to provide high quality code and modules. For this reason we are using
several [pre-commit hooks](.pre-commit-config.yaml) and
[GitHub Actions workflow](.github/workflows/golangci-lint.yml). A pull-request to the
master branch will trigger these validations and lints automatically. Please
check your code before you will create pull-requests. See
[pre-commit documentation](https://pre-commit.com/) and
[GitHub Actions documentation](https://docs.github.com/en/actions) for further
details.

## License
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

Expand Down

0 comments on commit aef471c

Please sign in to comment.