An open API service indexing awesome lists of open source software.

https://github.com/manuelarte/presentation-create-your-first-linter

Presentation about creating your first linter.
https://github.com/manuelarte/presentation-create-your-first-linter

go golang golangci golangci-lint guide linter meetup plugin tutorial

Last synced: 3 months ago
JSON representation

Presentation about creating your first linter.

Awesome Lists containing this project

README

          

# Create Your First Linter

Here I have the content to give the presentation about how to create your first linter.

The goal of this presentation is to create a linter, and run:

- standalone
- inside [golangci-lint][golangci]

🔗[Link to the presentation][5]

## Tools

- I am using [reveal.js][2] to create the slides.

To start the slides, inside the [./slides/](./slides/) folder, run:

```bash
npm start
```

## Go Projects

### Ast Example

Example on how the AST looks like for a small .go file

```bash
cd astexample && make t
```

### Unexported Constants Check

Exercise to implement uber style guideline [Prefix Unerxported Globals with _](https://github.com/uber-go/guide/blob/master/style.md#prefix-unexported-globals-with-_).

BadGood

```go
// foo.go

const (
defaultPort = 8080
defaultUser = "user"
)

// bar.go

func Bar() {
defaultPort := 9090
...
fmt.Println("Default port", defaultPort)

// We will not see a compile error if the first line of
// Bar() is deleted.
}
```

```go
// foo.go

const (
_defaultPort = 8080
_defaultUser = "user"
)
```

To implement: [analyzer.go](./unexportedconstantscheck/analyzer.go)

### Custom Module

Small web app to run [custom plugin linters][4].

[golangci]: https://golangci-lint.run/
[2]: https://revealjs.com/
[3]: https://github.com/jj-vcs/jj
[4]: https://golangci-lint.run/plugins/module-plugins/
[5]: https://manuelarte.github.io/presentation-create-your-first-linter/