Dependency Injection in Go

Поделиться
HTML-код
  • Опубликовано: 5 фев 2025
  • Dependency Injection in Golang
    Neovim config: github.com/adi...
    Twitter: / adib_hanna

Комментарии • 24

  • @theedgardev
    @theedgardev 25 дней назад +1

    This is the best explanation I've seen so far! I understood DI, thanks!

    • @adibhanna
      @adibhanna  25 дней назад

      Glad it was helpful!

  • @michelsmith6835
    @michelsmith6835 2 месяца назад +1

    thank you very much for a such simple explanation, I couldn't believe I watched too many videos before and they all failed to explain what dependency injection is, coming from another programming language I was really frustrated, you saved my day :) keep the great work, and keep your videos simple 💫❤

  • @fixer8173
    @fixer8173 9 месяцев назад +2

    In case you wonder if it is worth creating videos regularily, thanks for that a lot, your videos are super helpful and instructive, hope for many more ;)

    • @adibhanna
      @adibhanna  9 месяцев назад +1

      Thank you! It’s been difficult to stay consistent, but im glad to be back at it

  • @joselima7655
    @joselima7655 2 месяца назад

    Wow very nice explanation. And great vim skills. I ended up here because of your zed videos. Are you still using zed? I’m working to transition but it’s taking a while. Thanks for the videos +sub . What colorscheme is this ?

    • @adibhanna
      @adibhanna  2 месяца назад

      thank you! I'm not using Zed, still using Neovim. they both use the same open-source LSPs, so the experience regarding code intelligence is pretty much the same. Neovim offers more options for customizability!

  • @hma8244
    @hma8244 3 месяца назад

    Clean! Thanks man

  • @Suraj-tz3oq
    @Suraj-tz3oq 7 месяцев назад

    What if i have multiple dependencies like db, external service, ... other dependencies and they are dependent interdependent as well

  • @TheMouseJerry-du1md
    @TheMouseJerry-du1md 9 месяцев назад

    Brilliant Video. Pls share more golang videos and most used patterns in real time production code and also how one can use external packages that contains interfaces and struct types and what and when we can initialise or embed the in our code? U got me subscribed with this one video and hoping to see more...

    • @adibhanna
      @adibhanna  9 месяцев назад

      thank you! planning to release a lot of Go videos

  • @martinndegwa7155
    @martinndegwa7155 5 месяцев назад

    Best explanation. Thank you for this.

  • @mahdertekola6932
    @mahdertekola6932 2 месяца назад

    Golden!

  • @ayoubelmhamdi7920
    @ayoubelmhamdi7920 9 месяцев назад

    you show us some codes, but the intuition is start from hello word to wrote all words, without autocompletions lile copilot....
    using copilot ia the the teacher that use paper to vopy past in broad.

  • @KuzyoYaroslav
    @KuzyoYaroslav 9 месяцев назад

    Great video. Could you explain please why constructor function always returns pointer ?

    • @EverRusting
      @EverRusting 9 месяцев назад

      I want to answer if I can, first of all, those are more like factory or generator functions, not constructors.
      Second, idk about Go but in C++ when you work with objects (or non primitive types), you usually want to pass the reference instead of the whole object.
      One reason for this is pass by value clones the entire object and also it's a different object every time because it's a clone.
      When you pass the pointer, it's the same object every time and in this case this is the desired outcome.

    • @gggalahad
      @gggalahad 9 месяцев назад +1

      ​@@EverRusting Yeah but when I return pointer from function (method, constructor, whatever), doesn't it goes to heap? When I'm turning on gc in vscode or goland, it says that returned pointer goes to heap every time. And doesn't it means that garbage collector will do some work in the future, and doesn't it much bigger work than copy value from one stack frame to another?

    • @MyroslavSuprun
      @MyroslavSuprun 9 месяцев назад

      @@gggalahad I have started reading Learning Go v2 recently and the author says the same thing. If you pass a pointer, it goes to the heap, and most times it's better to pass value instead of a pointer.
      Unless it's a struct with a lot of values.
      A quote from the book: "Most of the time, you should use a value. Values make it easier to understand how and when your data is modified. A secondary benefit is that using values reduces the amount of work that the garbage collector has to do."
      But I still see that most built-in go packages return pointer instead of a value. Like gzip.NewReader, errors.New etc.

  • @Suraj-tz3oq
    @Suraj-tz3oq 7 месяцев назад

    Ide?

  • @Lohan_Guedes
    @Lohan_Guedes 9 месяцев назад

    font name?

    • @Tarekconqueso
      @Tarekconqueso 9 месяцев назад

      I believe that's jetbrains mono

    • @adibhanna
      @adibhanna  9 месяцев назад

      berkeleygraphics.com/typefaces/berkeley-mono/

  • @NullMcNull
    @NullMcNull 5 месяцев назад

    This video is a nice explanation how to use interfaces instead of concrete instances, but it does not explain dependency injection at all. With dependency injection you build a provider (ioc container) that provides (injects) the concrete instances to methods.