Dependency Injection in Go

Поделиться
HTML-код
  • Опубликовано: 4 ноя 2024

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

  • @fixer8173
    @fixer8173 6 месяцев назад +1

    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  6 месяцев назад +1

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

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

    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.

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

    Best explanation. Thank you for this.

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

    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  6 месяцев назад

      thank you! planning to release a lot of Go videos

  • @hma8244
    @hma8244 12 дней назад

    Clean! Thanks man

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

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

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

    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 6 месяцев назад

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

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

      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 6 месяцев назад +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 6 месяцев назад

      @@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 4 месяца назад

    Ide?

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

    font name?

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

      I believe that's jetbrains mono

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

      berkeleygraphics.com/typefaces/berkeley-mono/