Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple APILearn More
I love Golang myself but this is the first time I've seen error handling mentioned positively. If err is basically the same thing as try/catch
The difference is that go is consistent in the error handling methods. Coming from Node, where an error can be almost any data type, it's easier. ^^
Root836142yI love hearing about people discovering and falling in love with new tools 🥰
I still can't decide if I like golang or not. I like many things about it, but unlike you, I'm not a fan of the error handling.
Sometimes I have multiple lines, each of which could generate an error, and if any of them throw an error I want to immediately return from the function. In most languages, I could just wrap the whole thing in a try/catch block. In golang, I have to put a separate error check after every statement that could possibly return an error.
It's consistent, but I'd much rather have a simple try/catch block than constantly checking if err is nil after every function call.
Maybe it's because I'm coming from Python instead of Node. In Python you can only raise an Exception or a subclass of Exception. So it's consistent enough for me.
I have to use Golang at work, and i absolutely dislike it.
I've had the same experience with golang, right down to rewriting my discord bot in it. I agree that I like the consistency of errors, but I also agree with some of the other people in that when you have consecutive functions that can return errors, it gets a little verbose and reminds me of some c++ library error checking.
In general though, it's been a nice language that I haven't been able to work enough in!
ngCry3252yI also like the error handling in Go, it can get verbose quickly but i think Go isn't about writing the most elegant code but about stability and consistence.
I also like that things don't get too abstract like in Java/C# where im struggling even finding the concrete implementation of one of the many interfaces. (If i have to debug someone elses codebase)
xorith19HTML: Hate This Meaningless Life CSS: Can't Style Shit JS: Just Shit Java: Just another vicious asshole PH...
ObiSwagKenobi6> Receive sudden phone call in the middle of the night > Check caller, unknown number > "Either something ba...
dyslxr40So I named my daughter "io" everyone calls her by the name and then we register her on our local gov't to get...
I started learning Golang today and really like it.
The error handling is *excellent*. It always works the same way and is standardized, unlike the hell that NodeJS error handling is (.catch(), try).
Modules confused the fuck out of me. I eventually figured out how they worked, but Go really doesn't try to make it easy to have multiple source folders...
I'll probably be re-writing my Discord Bot in Golang soon. Being able to have just one binary output will make things infinitely easier. Compile-time variables are another feature that's nice and easy to implement.
The goal is only having to upload a single binary to deploy on production from my CI script that has all keys and stuff inside. Feels good to finally throw all that old bad JS code out and starting completely fresh.