golangci-lint
ls-lint
Our great sponsors
golangci-lint | ls-lint | |
---|---|---|
72 | 6 | |
14,288 | 1,682 | |
2.4% | - | |
9.7 | 9.0 | |
2 days ago | 4 days ago | |
Go | Go | |
GNU General Public License v3.0 only | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
golangci-lint
-
Using Private Go Modules with golangci-lint in GitHub Actions
golangci-lint is an amazing open-source tool for CI in Go projects. Basically, it's an aggregator and a Go linters runner that makes life easier for developers. It includes all the well-known liners by default but also provides an easy way to integrate new ones.
-
️👨🔧 3 Tiny Fixes You Can Make To Start Contributing to Any Open Source Project 🚀
Fun fact: We actually use a code linter via golangci-linter to catch misspellings in code/comments using client9/misspell.
-
Show HN: Error return traces for Go, inspired by Zig
The "standard linter" in Go is https://golangci-lint.run/ , which includes [1] the absolutely-vital errcheck which will do that for you.
For an Advent of Code challenge you may want to turn off a lot of other things, since the linter is broadly tuned for production, public code by default and you're creating burner code and don't care whether or not you have godoc comments for your functions, for instance. But I suggest using golangci-lint rather than errcheck directly because there's some other things you may find useful, like ineffassign, exportloopref, etc.
-
Hacking Go to give it sum types
golangci-lint recently integrated go-check-sumtype. I recommend using golangci-lint as a pre-commit hook, but if you're in a real hurry you can replace "go build" with a shell script that runs go-check-sumtype instead. This is probably better than a weird hack, not that you're saying that the weird hack is a good idea anyhow.
-
Building RESTful API with Hexagonal Architecture in Go
Golangci-lint is a tool for checking Go code quality, finding issues, bugs, and style problems. It helps keep the code clean and maintainable.
-
Structured Logging with Slog
This is such an infuriating problem. I'm convinced I'm using Go wrong, because I simply can't understand how this doesn't make it a toy language. Why the $expletive am I wasting 20-30 and more minutes per week of my life looking for the source of an error!?
Have you seen https://github.com/tomarrell/wrapcheck? It's a linter than does a fairly good job of warning when an error originates from an external package but hasn't been wrapped in your codebase to make it unique or stacktraced. It comes with https://github.com/golangci/golangci-lint and can even be made part of your in-editor LSP diagnostics.
But still, it's not perfect. And so I remain convinced that I'm misunderstanding something fundamental about the language because not being able to consistently find the source of an error is such an egregious failing for a programming language.
- Seeking Insights: Tools Used in GitHub Actions for Security Code Checks and Vulnerability Detection
-
Is it a bad convention to overwrite err variable?
You should be using golangci-lint, because all serious Go programmers should. golangci-lint contains errcheck, which will detect if you overwrite an error without having done something with it in the meantime. I consider this one of the most important linters (this doesn't just detect things that may sorta kinda someday turn into bugs, this quite likely is a bug RIGHT NOW), and it helps you have the confidence you can overwrite errors as you go and don't need to keep allocating new ones.
-
Golang’s best-kept secret: ‘executable examples’
Note that without the `Output:` line you can silently not be running these tests - https://github.com/golangci/golangci-lint/issues/3084 covers when this can be problematic and there's now a golangci-lint integrated linter for catching it
-
How to start a Go project in 2023
Things I can't live without in a new Go project in no particular order:
- https://github.com/golangci/golangci-lint - meta-linter
- https://goreleaser.com - automate release workflows
- https://magefile.org - build tool that can version your tools
- https://github.com/ory/dockertest/v3 - run containers for e2e testing
- https://github.com/ecordell/optgen - generate functional options
- https://golang.org/x/tools/cmd/stringer - generate String()
- https://mvdan.cc/gofumpt - stricter gofmt
- https://github.com/stretchr/testify - test assertion library
- https://github.com/rs/zerolog - logging
- https://github.com/spf13/cobra - CLI framework
FWIW, I just lifted all the tools we use for https://github.com/authzed/spicedb
We've also written some custom linters that might be useful for other folks: https://github.com/authzed/spicedb/tree/main/tools/analyzers
ls-lint
-
An ESlint plugin for consistent filename and folder naming. Allows you to enforce a consistent naming pattern for the filename and folder.
There is also https://github.com/loeffel-io/ls-lint
-
Today is the day: ls-lint just reached more then 1 million downloads
ls-lint is an extremely fast directory and filename linter: GitHub 1 million npm downloads and over ~110 000 downloads per month is huge! Thank you to all users that made this happen! <3 This day also marks the release of the version 1.11.0 which brings several improvements: - Massive performance improvements: up to 1100% faster to version 1.10.x (see benchmarks) - New SCREAMING_SNAKE_CASE rule - The warn option gives you the opportunity to migrate your project seamlessly - The debug option allows support for debugging your config - Major updates for all dependencies Would love to see more and more people like nuxt.js, renovate and terser playing with this to bring more and more structure to their projects <3
- ls-lint just reached the 500 000 npm downloads - road to 1 million!
What are some alternatives?
ireturn - Accept Interfaces, Return Concrete Types
gosec - Go security checker
golangci-lint-action - Official GitHub action for golangci-lint from its authors
gopl.io - Example programs from "The Go Programming Language"
go - The Go programming language
go-tools - Staticcheck - The advanced Go linter
reviewdog - 🐶 Automated code review tool integrated with any code analysis tools regardless of programming language
golang-standards/project-layout - Standard Go Project Layout
staticcheck
maligned - Tool to detect Go structs that would take less memory if their fields were sorted.
viper - Go configuration with fangs
gofumpt - A stricter gofmt