Golang Error Handling - ULTIMATE Golang Basics Tutorial

Поділитися
Вставка
  • Опубліковано 6 лис 2024

КОМЕНТАРІ • 28

  • @GolangDojo
    @GolangDojo  3 роки тому +2

    📝Get your *FREE Golang Cheat Sheet* -
    golangdojo.com/cheatsheet

    • @profauzan
      @profauzan 3 роки тому

      thankyouu

    • @robimalco
      @robimalco 3 роки тому

      Ehy Dojo, I add my email address...but I haven't receive any cheat sheet :/

  • @RafaelDurelli
    @RafaelDurelli 3 роки тому +1

    Nice. I just found you channel.. I'm loving all the videos. I have created a golang club with my students in an brasilian university. The goal is to teach them why golang is so nice :).. Thanks for your videos

    • @GolangDojo
      @GolangDojo  3 роки тому +1

      Sounds awesome! Golang is the GOAT!

  • @jachymtousek8728
    @jachymtousek8728 2 роки тому +1

    Now this actually ended up surprisingly unhelpful... one super basic thing: how can I get a stack trace of the error? Can't really debug without a stack trace, right?

  • @anirudh6781
    @anirudh6781 2 роки тому +1

    Thanks man!

  • @it1shka
    @it1shka 3 роки тому +6

    Golang really needs special syntax for error propagation (like Rust '?' operator), because Im building a parser in golang and im just tired of checking if err != nil {} after every function call

    • @letsgetrusty
      @letsgetrusty 3 роки тому +1

      Agreed ;)

    • @GolangDojo
      @GolangDojo  3 роки тому

      lolololol oh well

    • @TJ-wc3iq
      @TJ-wc3iq 3 роки тому

      Cannot agree 😅 Every new "feature" increases complexity. Why don't you build a helper function for that? Rust's "?", "or_else", "end_then", and so on operators don't make the code easier to read or to understand. But that are different "zen" approaches behind these languages. JavaScript ES3 was simple, ES2021 is not; C++ v2.0 was understandable, C++20 is not. KISS 🤗

    • @it1shka
      @it1shka 3 роки тому +2

      @@TJ-wc3iq how am I supposed to build a helper function? All my constructions look like:
      res, err := self.ParseSomeStatement()
      if err != nil {
      return nil, err
      }
      and yep, doing like
      return self.ParseSomeStatement()
      isn't my case. I always need to manually check if err != nil. This problem can be potentially solved with a macro system but there is no macro in golang!
      Despite the fact simplicity is a kinda advantage of golang, the language really lacks a lot of important and necessary things. And it is sad to see that the go community simply denies the obvious drawbacks. Btw you forgot about DRY principle.
      And finally, for me it was a big surprise that it is easier to write clean and short code in Rust which is a systems programming language without GC than in simple go. Thats it

    • @meggi8048
      @meggi8048 2 роки тому +1

      absolutely true, error handling in go is a shit show. for every line of code you need to add at least 3 lines for error handling. thats a overhead of at least 75%.
      thats + the inability of go to handle dynamic data structures led me to discard my golang efforts. sadly i actually like Golang.

  • @flannn6
    @flannn6 2 роки тому +1

    You could have talked about capturing specific errors. As it is the most confusing part, specially when it comes from outside your project, like a framework.

  • @simonllovefootball
    @simonllovefootball 2 роки тому +1

    ayo ur keyboard is funky

  • @md.ruhulamin8674
    @md.ruhulamin8674 2 роки тому +1

    return errors.New(text: "error here")
    man ( text )getting error

  • @doradora8925
    @doradora8925 3 роки тому +1

    Hey Mr, which IDE are you using ? I think im in love

  • @TheSheldorAFK
    @TheSheldorAFK 3 роки тому +1

    Dude we need tour of your workstation setup tour, chair table computer.. room..e.t.c. by the way i like your keyboard

    • @GolangDojo
      @GolangDojo  3 роки тому

      Thanks for the idea! Stay tuned!

  • @tearsinrain2049
    @tearsinrain2049 3 роки тому +1

    Kinessis Advantage 2 is the best!!! by the way Advantage 360 will coming out at the end of the year

  • @carghai9235
    @carghai9235 2 роки тому +1

    I wish go had try catch ):

  • @pedrobotsaris2036
    @pedrobotsaris2036 Рік тому

    C does not have exceptions

  • @meggi8048
    @meggi8048 2 роки тому +1

    error handling in go is a shit show. for every line of code you need to add at least 3 lines for error handling. thats a overhead of at least 75%.
    thats + the inability of go to handle dynamic data structures led me to discard my golang efforts. sadly i actually like Golang.

  • @_slier
    @_slier 2 роки тому

    ok that's disgusting way to handle error.. smmh.. this problem is long going problem is go ecosystem and yet the go author dont give a shit about it.. union data type is the way to go