errcheck
crystal
errcheck | crystal | |
---|---|---|
9 | 239 | |
2,284 | 19,109 | |
- | 0.3% | |
6.3 | 9.8 | |
15 days ago | 4 days ago | |
Go | Crystal | |
MIT License | Apache License 2.0 |
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.
errcheck
-
Linter to check for errors ignored with _
In our codebase I noticed a few cases where people ignored errors returned from functions by assigning them to _, ie result, _ := foo(). The errcheck linter doesn't seem to catch this, does anyone know of a linter that does?
-
Golang panics in libraries
And we also expect that the caller will check the error and handle it. There is a popular linter that checks it for us: errcheck.
-
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.
-
Integration Tests failing
Run golangci-lint over your code if you haven't already and pay special attention to errcheck's output.
-
Luciano Remes | Golang is πΌπ‘π’π€π¨π© Perfect
errcheck has a flag for that ;)
-
Proposal: Go 2: Lightweight anonymous function syntax
https://github.com/kisielk/errcheck, which is in most of the combined linter packages by default.
We'll agree to disagree about unused imports; imports have can side-effects.
-
Lies we tell ourselves to keep using Golang
I prefer functions returning errors over throwing exceptions. Whether it's Go's errors or ML-style options/results, they're both better than exceptions. I cannot remember the last time I had a bug from not checking an error in Go. There's also errcheck which I use as part of my linting that will catch unchecked errors, such that I cannot even commit the code.
-
I Want Off Mr. Golang's Wild Ride
> Go compiler raise an error if a variable (error) goes unused
It doesn't though. It's perfectly valid to not use the return value of a function that only returns an error, for instance.
There are static error checking tools you can use like https://github.com/kisielk/errcheck to work around this, but most people don't use them.
I've run into a lack of Go error checking many times. Many times it's just the trivial case, where the compiler doesn't warn about not checking the result of an error-returning function.
But often it'll be subtler, and the result of Go's API design. One example is its file writing API, which requires you to close the file and check its error to be correct. Many times people will just `defer file.Close()`, but that isn't good enough - you're ignoring the error there.
Worse still is e.g: writing to a file through a bufio.Writer. To be correct, you need to remember to flush the writer, check that error, then close the file and check that error. There's no type-level support to make sure you do that.
-
Trying Out Generics in Go
I'd be really happy with that! Building the functionality of errcheck[1] and ineffassign[2] into the compiler β or at the very least, into govet β would go a long way to allay my worries with Go.
I think the reason they don't do this is that it's a slight (albeit a very tiny one) against Go's philosophy of errors being values, just like any other. While the `error` type is standard and used throughout Go source code, it still just has a simple three-line definition[3] and is not treated as a special case anywhere else; there is nothing stopping you from returning your own error type if you wish. A third-party linter could simply check for the `error` type specifically, but the first-party tools should not, and there's nothing like Rust's `#[must_use]` attribute that could be used instead. I respect Go's philosophy, but I feel like pragmatism must win in this case.
[1]: https://github.com/kisielk/errcheck
crystal
- A Language for Humans and Computers
-
Top Paying Programming Technologies 2024
27. Crystal - $77,104
-
Crystal 1.11.0 Is Released
I like the first code example on https://crystal-lang.org
# A very basic HTTP server
- Is Fortran "A Dead Language"?
- Choosing Go at American Express
- Odin Programming Language
- I Love Ruby
-
Ruby 3.3's YJIT: Faster While Using Less Memory
Obviously as an interpreted language, it's never going to be as fast as something like C, Rust, or Go. Traditionally the ruby maintainers have not designed or optimized for pure speed, but that is changing, and the language is definitely faster these days compared to a decade ago.
If you like the ruby syntax/language but want the speed of a compiled language, it's also worth checking out Crystal[^1]. It's mostly ruby-like in syntax, style, and developer ergonomics.[^2] Although it's an entirely different language. Also a tiny community.
[1]: https://crystal-lang.org/
-
What languages are useful for contribution to the GNOME project.
Crystal is a nice language that's not only simple to read and write but performs very well too. And the documentation is amazing as well.
-
Jets: The Ruby Serverless Framework
Ruby is a super fun scripting language. I much prefer it to python when I need something with a little more "ooomph" than bash. It's just...nice...to write in. Ruby performance has come a long way in the last decade as well. There's libraries for pretty much everything.
My modern programming toolkit is basically golang + ruby + bash and I am never left wanting.
I do find Crystal (https://crystal-lang.org/) really interesting and am hoping it has its own "ruby on rails" moment that helps the language reach a tipping point in popularity. All the beauty of ruby with all of the speed of Go (and then some, it often compares favorably to languages like rust in benchmarks).
What are some alternatives?
GoLint - [mirror] This is a linter for Go source code. (deprecated)
zig - General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
staticcheck
Nim - Nim is a statically typed compiled systems programming language. It combines successful concepts from mature languages like Python, Ada and Modula. Its design focuses on efficiency, expressiveness, and elegance (in that order of priority).
gosimple
go - The Go programming language
gcvis - Visualise Go program GC trace data in real time
Elixir - Elixir is a dynamic, functional language for building scalable and maintainable applications
apicompat - apicompat checks recent changes to a Go project for backwards incompatible changes
mint-lang - :leaves: A refreshing programming language for the front-end web
Go Metalinter
Odin - Odin Programming Language