ByteNinja
ByteNinja
  • 8
  • 8 058
Handling errors in GoLang, Tips and Tricks!
In this comprehensive video, we dive deep into error handling in Go, exploring its unique approach to treating errors as values. Whether you're a beginner or an experienced developer, you'll learn everything you need to know about handling errors effectively in your Go applications.
What You'll Learn:
The basics of the built-in error interface in Go.
How to create errors using errors.New() and fmt.Errorf().
Best practices for returning and handling errors in your functions.
The power of error wrapping introduced in Go 1.13.
Using errors.As() and errors.Is() for robust error handling.
Understanding panic and recover to manage exceptional situations.
How to create custom error types for more descriptive error messages.
👉 Don't miss out on the chance to enhance your Go programming skills! If you find this content helpful, please like the video and subscribe for more insightful programming tutorials.
Переглядів: 108

Відео

How Functional Programming Changes Your Coding Mindset
Переглядів 1,6 тис.День тому
In this video, we dive into the world of Functional Programming and how it compares to Object-Oriented and Procedural paradigms. I used to be a strong advocate for OOP, but exploring functional programming has shown me a cleaner, more elegant way to write code. We'll cover key concepts like: Programming paradigms: Procedural, Object-Oriented, and Functional Pure functions, immutability, and rec...
Create REST API with go standard library
Переглядів 36814 днів тому
In this video, I'll be diving into the new features introduced with Go 1.22. We'll explore how to use the standard Go library to work with HTTP methods, implement middlewares, and handle path parameters. If you're looking to enhance your Go web development skills or just curious about the latest updates, this video is perfect for you! I'll walk you through practical examples and demonstrate how...
Is Neovim better than VSCode?
Переглядів 2,7 тис.21 день тому
Hey fellow coders! 🎉 In this video, I’m walking you through my switch from VSCode to Neovim - and trust me, it’s been a journey! 😅 I’ll show you how I went from a half-baked config to writing my own from scratch (with a LOT of help from Lua). I’ll also break down some of the must-have plugins that transformed my setup and made Neovim my new best friend. Whether you're thinking of switching or j...
GoLang v. JavaScript and why go is better
Переглядів 3 тис.Місяць тому
In this video, I demonstrate how Golang's strong typing prevents common runtime errors found in JavaScript. We'll compare code examples in both languages, showing how JavaScript’s flexibility can lead to unexpected issues, while Go catches these errors at compile time. Watch to see why I switched to Go for backend development! #golang #go #javascript #GoVsJavaScript #backend #programming #softw...
Concurrency vs Parallelism in Go: What Every Developer Should Know
Переглядів 172Місяць тому
Welcome to Byteninja! In today's video, we're diving deep into Concurrency in Golang. You'll learn the key concepts of parallelism vs concurrency and understand the difference between them. We'll also cover the following topics: How to use goroutines and their non-blocking nature Proper usage of WaitGroups for synchronization Introduction to channels for inter-goroutine communication Examples o...

КОМЕНТАРІ

  • @howuseehim
    @howuseehim 13 годин тому

    HMR

  • @bjarne431
    @bjarne431 День тому

    everything with a decent standard library is better than JavaScript - meaning literally everything

  • @ktappdev
    @ktappdev 2 дні тому

    packer? Lazy wasn't even on the screen, what am I missing here?

  • @assamtv2222
    @assamtv2222 2 дні тому

    It's good and meaningful

  • @matangisangitalaya
    @matangisangitalaya 3 дні тому

    It's very useful.

  • @itzaryaanyt2003
    @itzaryaanyt2003 4 дні тому

    Credit goes yo teej core maintainer of neovim and telescope 🔭

  • @mbwilding
    @mbwilding 5 днів тому

    I am glad you hand rolled your config. One of us. Packer is quite dated, I recommend lazy.nvim as a package manager. It lazy loads.

  • @abiiranathan
    @abiiranathan 5 днів тому

    I love the humor. Subscribe 🎉🎉🎉

  • @fuzzypenguinams3207
    @fuzzypenguinams3207 7 днів тому

    Seems promising, I might take a second look at it soon. I'm bookmarking this video!

  • @IvanToshkov
    @IvanToshkov 7 днів тому

    3:50 - this is NOT a side effect. A side effect would be to change something. In this case, if `limit` is a constant then `add is a pure function. If `limit` can change then `add` isn't pure as it depends on an external state. But it does not change the state itself, so it doesn't have side effects. If you write a function max like this: maximum = -12345 # Replace this with the actual smallest number def max(a, b): if a > b: maximum = a else: maximum = b This is a function with side effects. I/O functions are also functions with side effects. I also wanted to mention, that most functional programming languages use an optimization called tail-call optimization (TCO). It basically says that some function calls are really cheap and don't grow the call stack. Here is an example: def a(): print("hi") # Not a tail call return b(1) # Tail call The call to `print` has to be done by adding stuff on the stack, because we need to do more when `print` returns. The call to `b` on the other hand is in a "tail" position. It can be implemented as a normal call, but we can also replace the current stack frame with the data needed by `b`. Then `b` will return directly to the caller of `a` instead of returning to `a` which would return to its caller. This is especially important with recursion, because without TCO recursion will be very inefficient. With TCO (and other optimizations) it's basically a loop. That is, as long as the recursive call is at tail position.

    • @IncisiveCreations
      @IncisiveCreations 3 дні тому

      No, it IS a side effect. Inside the add method, he's modifying the limit variable which is declared outside of that method's scope. Hence it is a side effect just as your example is. Wikipedia: "Example side effects include modifying a non-local variable, a static local variable or a mutable argument passed by reference; raising errors or exceptions; performing I/O; or calling other functions with side-effects.[1] In the presence of side effects, a program's behaviour may depend on history; that is, the order of evaluation matters."

    • @IvanToshkov
      @IvanToshkov 3 дні тому

      @@IncisiveCreations Damn! I was focusing on the highlighted part and totally missed the next line.

    • @IncisiveCreations
      @IncisiveCreations 3 дні тому

      @@IvanToshkov This whole example is fictitious. The code in question doesn't work because Python doesn't allow access to non-local (free) variables from inside of method scope. Hence, the limit variable cannot be modified and you just get an error.

  • @matangisangitalaya
    @matangisangitalaya 8 днів тому

    It's good

  • @amansagar4948
    @amansagar4948 8 днів тому

    Golang is a really good language for web2, i even started learning it but then dropped the plan and moved to rust instead, as i wanna stay in web3. With runtimes like bun, js is pretty fast for most things and the amount of investment that has been done in js ecosystem is just incredible and you’ll clearly observe it while working with other languages.

  • @spinFK
    @spinFK 8 днів тому

    NASA says recursion is more dangerous.

    • @NapoleonBorn2Party007
      @NapoleonBorn2Party007 8 днів тому

      Yes functional programming immediately gets disqualified for NASA since you can't have limiters for loops

    • @diadetediotedio6918
      @diadetediotedio6918 4 дні тому

      WOW, NASA says this so this should be a worry for 99.9999999999% of the programmers. It's not like they work in extremely resource constrained environments where they many times don't even have a stack to work with.

    • @NapoleonBorn2Party007
      @NapoleonBorn2Party007 4 дні тому

      @@diadetediotedio6918 no it shouldn't, NASA's constraints is specifically because they can't go physically to a far away satelite to fix something if it breaks. It shouldn't apply to other environments where dynamic hot loading is possible.

    • @NapoleonBorn2Party007
      @NapoleonBorn2Party007 4 дні тому

      @@diadetediotedio6918 also one other constraints is to never use heap memory to completely avoid memory leaks.

    • @diadetediotedio6918
      @diadetediotedio6918 3 дні тому

      ​@@NapoleonBorn2Party007 I was being sarcastic buddy, because I found the comment very bizarrely put, it came from nothing and said that "NASA says its dangerous" without any kind of reason at all. But you are right, they have their own constraints.

  • @R24-q6b
    @R24-q6b 9 днів тому

    It feels good to hear it from an Indian, knowing I am not alone who likes Neovim.

  • @guyloser2
    @guyloser2 10 днів тому

    4:00 i won't really reccomend recursion imo cuz of the stack

    • @ByteNinja-ym1nl
      @ByteNinja-ym1nl 9 днів тому

      Agreed, non-functional languages perform better with the iterative approach, but most of the functional languages are lazily evaluated and have optimisations for tail recursion, so it's not much of a problem there.

    • @diadetediotedio6918
      @diadetediotedio6918 4 дні тому

      This don't make sense, most of the times this is the least of your worries.

  • @coderFriend
    @coderFriend 10 днів тому

    please make a video on how to get started with functional programming. One more small request, if possible make a video on oops explaining the 4 concepts in details and with examples. Thankyou

    • @guyloser2
      @guyloser2 10 днів тому

      You can start away with doing/making things in JavaScript.

  • @assamtv2222
    @assamtv2222 10 днів тому

    So clear

  • @AlamKhan-yt9wd
    @AlamKhan-yt9wd 11 днів тому

    Lame video! Title doesn't justify the content.

  • @pearl911
    @pearl911 12 днів тому

    I love to see people switching over, please dont recommend nvchad or other frameworks, as you said its normally a mess. Kickstart.nvim is easily the best way to get into linux. Changing the config file is easy because it is filled with comments. It is designed in a way that is meant to be tweakable. Starting from scratch also has benifits but most people dont wan't to do all that. It takes a TON of time.

  • @guilhermewhite7274
    @guilhermewhite7274 14 днів тому

    good video!

  • @hashirventhodi
    @hashirventhodi 14 днів тому

    What about rust?

    • @ByteNinja-ym1nl
      @ByteNinja-ym1nl 14 днів тому

      Rust is indubitably faster when compared with go, the only thing going in favour of rust is its 'simplicity', imho you can pick either one.

  • @snatvb
    @snatvb 16 днів тому

    Go guarantees that everything will work after compilation - say it to null pointer exception))))) u even can't know optional or not is the field I'de prefer go where is cuncurrency is really necessary

    • @ByteNinja-ym1nl
      @ByteNinja-ym1nl 16 днів тому

      Agreed, go has its flaws, I'm planning a video where I'll cover the pain points, and how to get around them.

  • @assamtv2222
    @assamtv2222 16 днів тому

    Very clear and valuable.

  • @matangisangitalaya
    @matangisangitalaya 16 днів тому

    It's good and to the point.

  • @shellgecko
    @shellgecko 18 днів тому

    Consider switching to lazy package manager you won't regret Packer is deprecated in favor of lazy

  • @howto-xd6tq
    @howto-xd6tq 19 днів тому

    propaganda

  • @pawel_890
    @pawel_890 19 днів тому

    I have only one reason why Go is bad for backend - missing OpenApi 3.0 and lack of simple graphql library - because I am big fan of end to end type safe for Frontend. You can check that nodejs is not slow in real world: ua-cam.com/video/h2pCxj_Fkdc/v-deo.html

  • @cybernit3
    @cybernit3 20 днів тому

    I don't know much about golang, but yesterday I got golang to work with raylib and it worked. Just I read about golang having telemetry so google can spy on you, but telemetry isn't set by default, correct? I know C but golang is like C in some ways. Gemini AI tells me golang performance is between C++ (abit faster) and Rust(more robust memory safety) and Jai (I think maybe better for game programming); but golang might be easier and has those channel feature for concurrent parallel processing. Not 100% sure to go full into it, just was curious. I don't understand why with a simple hello world program golang with the go compiler produces 2 mb executable yet with gccgo I get 56k. I also tried flags -w -s and then used upx (packer) but go it down to like 200-500k just to print hello world. With C only 17k or so for hello world. With go compiler is there a way to set it to dymanic mode instead of static so you can further reduce executable filesize? Ok enough, thanks for the video.

  • @nabinsaud4688
    @nabinsaud4688 21 день тому

    Can you share your nvim config in github

    • @ByteNinja-ym1nl
      @ByteNinja-ym1nl 21 день тому

      Here you go github.com/byteninjayt/nvim-config

  • @matangisangitalaya
    @matangisangitalaya 23 дні тому

    It's so good...

  • @hashirventhodi
    @hashirventhodi 24 дні тому

    Great work!!!!

  • @Sam-lj9vj
    @Sam-lj9vj 25 днів тому

    Would love to get a total walkthrough vid. I also want to move to Neovim but I can't find any decent "guide" on it. p.s. I don't see the link in the description?

    • @ByteNinja-ym1nl
      @ByteNinja-ym1nl 25 днів тому

      I'm working on a detailed neovim guide and as for the GitHub link I'm just doing some final changes, will add it soon.

    • @asimplenameichose151
      @asimplenameichose151 23 дні тому

      There are many good guides for Neovim setup with different approaches. I have watched many of them and taken bits and pieces from each. Really enjoyed the Primeagen guide and TJ's one-video guide (which uses kickstart), but the configuration in the video series linked below from 'typecraft' (minus the colorscheme choice) is probably the one that resonated the most with me recently. (I have been a Vim user for ~20 years but converted most of my development tasks over to a Neovim workflow over the last couple of years.) ua-cam.com/video/zHTeCSVAFNY/v-deo.html

    • @davidallred991
      @davidallred991 12 днів тому

      I recently jumped into neovim because I needed to switch up as I have been coding all day everyday on a big project and my wrist was killing me by the end of the day from using the mouse and jumping back and forth. Not to promote someone else's channel, but just to help out I found Josean Martinez 2024 nvim video to be by far the best on YT. You will get a good setup but also learn enough to start doing things on your own which is what I did. I am sure this channel will do a pretty good one soon, the production quality of this video was really good. I'll even subscribe to help support. FYI, I also setup my VScode to use vim motions with the vscodevim plugin. I am loving neovim, but I am still much quicker for now in VScode because of the familiarity, so for main project work I am still using it but with vim motions installed and a bunch of configs for it to make it feel more like neovim. Good luck. It's a rabbit hole, but a fun and cool one if you are into this sort of thing. Using nvim reminds me how I felt going from PC to Mac a long long time ago, it's just more enjoyable to use from my perspective.

    • @asimplenameichose151
      @asimplenameichose151 12 днів тому

      @@davidallred991 Good recommendation, I also watched one or two of his neovim videos at some point (Martinez)

  • @astoryengineered
    @astoryengineered 25 днів тому

    out here supporting small channels, i will also start posting next month lol cool video tho i hope u blew up soon bro

  • @mugumugi911
    @mugumugi911 27 днів тому

    I think you need to increase your volume sound a bit

  • @assamtv2222
    @assamtv2222 Місяць тому

    It's great

  • @assamtv2222
    @assamtv2222 Місяць тому

    So good

  • @matangisangitalaya
    @matangisangitalaya Місяць тому

    It's so good

  • @assamtv2222
    @assamtv2222 Місяць тому

    Very useful.

  • @assamtv2222
    @assamtv2222 Місяць тому

    It's very good.

  • @codework7535
    @codework7535 Місяць тому

    Excellent work😎

  • @ByteNinja-ym1nl
    @ByteNinja-ym1nl Місяць тому

    Watch the full video on my channel

  • @assamtv2222
    @assamtv2222 Місяць тому

    Well done! Very clear speech and influential voice. It must be valuable for the learners.