Golang Interface Basics You MUST Know!!

Поделиться
HTML-код
  • Опубликовано: 28 май 2024
  • Golang Interfaces - ULTIMATE Golang Basics Tutorial
    In today's Golang tutorial video, we will talk about the Interfaces in Go. We will go through how to implement interfaces in the Go programming language, along with some comparisons with more traditional OOP languages like Java, and everything you need to know to fully understand Interfaces in Go/Golang. Enjoy!
    --
    Golang Dojo is all about becoming Golang Ninjas together. You can expect all kinds of Golang tutorials, news, tips & tricks, and my daily struggles as a Golang developer. Make sure to subscribe if you look forward to such content!
    Get Your Golang Cheat Sheet! - golangdojo.com/cheatsheet
    Git repos & notes - golangdojo.com/resources
    Golang Basics - www.youtube.com/watch?v=VTJ8q...
    Timestamps
    0:00 Intro
    0:24 Code Setup
    2:42 Implementing Interfaces
    3:45 Duck Typing
    6:15 Outro
    --
    #golang #goprogramming #golangdojo
  • НаукаНаука

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

  • @GolangDojo
    @GolangDojo  2 года назад +1

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

  • @francescodestefano4609
    @francescodestefano4609 2 года назад +11

    Honestly one of the best explanations of interfaces. This channel is quickly becoming my go-to for golang!

    • @genjishimada4308
      @genjishimada4308 2 года назад

      True
      rly good explanation, without abstract shit

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

      This channel became my instant go-to for Golang 🤣

  • @c__beck
    @c__beck 2 года назад +6

    This topic is the most confusing for me as a new Go programmer, but you helped make it make (a bit more) sense. Thanks!

  • @weirdwildwackyz
    @weirdwildwackyz Год назад +2

    it's simple yet easy to understand. WHY IN THE WORLD others showing interfaces along with crazy math on how to calculate square + circle. KISS

  • @baw7198
    @baw7198 2 года назад +1

    I saw videos i also read many articles and didn't understand a thing, but i swear you just made it looks so easy to understand Thank you!

  • @shaileshb8417
    @shaileshb8417 2 года назад +3

    Greate video man you really simplify things and make it easy to understand.

    • @GolangDojo
      @GolangDojo  2 года назад +1

      Thank you! More to come!

  • @gdgo6166
    @gdgo6166 Год назад +1

    Thanks for the great tutorial, I have a quick question on declaring function 🤔🤔
    Is there a reason why you didn't call weapon.attack() directly inside the loop? What's the best practice there?

  • @sweet_fentanyl
    @sweet_fentanyl 2 года назад +3

    Thank you Sensei

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

    can a function belong to 2 interfaces / struct ?

  • @bhupeshthakur9830
    @bhupeshthakur9830 Год назад

    where did you get this keyboard? is it smooth? can you share the link?

  • @kamilziemian995
    @kamilziemian995 4 месяца назад

    Good video.

  • @ernestoaguilera3417
    @ernestoaguilera3417 2 года назад +1

    Great tutorial, I like your channel :)

  • @cychoboy
    @cychoboy Год назад

    How would you write an interface to the Record function shown below?
    type Total1 struct {
    tot1 float64
    }
    func (t *Total1) Record(x float64) {
    t.tot1 += x
    }

    • @dipsrips
      @dipsrips Год назад

      type addition interface{
      record()
      }
      // accepts values of type addition interface and num to call record
      func calculateTotal(t addition, num float64) {
      t.record(num)
      }
      func main() {
      t := total1{ 1.2 }
      calculateTotal( &t, 3.3)
      }
      Hope this helps ☺
      @cychoboy

  • @gwnbw
    @gwnbw Год назад

    How would you print out the names of the Ninja's that use the weapon in this code example?

    • @gwnbw
      @gwnbw Год назад

      Ah got it:
      for _, weapon := range weapons {
      a := fmt.Sprintf("%s", weapon)
      fmt.Printf("%s ", strings.Trim(a, "{}"))
      attack(weapon)
      } // Output: Wallace uses sword

    • @gwnbw
      @gwnbw Год назад

      Figured I could just do weapon.owner too.

    • @JustValxntine
      @JustValxntine Год назад

      @@gwnbw I know you posted this a couple of month ago, but you can do that. if your struct method is like this:
      func (n ninjaStar) attack() {
      fmt.Printf("%s uses ninja star
      ", n.owner)
      }
      Then that should print out with the owners name

  • @vishwaratna
    @vishwaratna Год назад

    your voice is not ok.

  • @user-lw5wm2hg7s
    @user-lw5wm2hg7s 3 месяца назад

    I want to be Ninja!