13

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.

Comments
  • 3
    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
  • 1
    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. ^^
  • 9
    I love hearing about people discovering and falling in love with new tools 🥰
  • 0
    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.
  • 2
    I have to use Golang at work, and i absolutely dislike it.
  • 0
    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!
  • 1
    I 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)
Add Comment