#1 India's Top IT Training Institute

×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
OOP Concepts

Mastering Interfaces in Go – Polymorphism with Real Examples

What is an Interface?

An interface defines a set of method signatures. Any type that implements those methods automatically satisfies the interface — no explicit declaration needed.

type Shape interface {
    Area() float64
}

type Circle struct {
    Radius float64
}

func (c Circle) Area() float64 {
    return 3.14 * c.Radius * c.Radius
}

Polymorphism with Interfaces

func printArea(s Shape) {
    fmt.Println("Area:", s.Area())
}

c := Circle{Radius: 5}
printArea(c) // works because Circle implements Shape

The Empty Interface

interface{} (or any in newer Go versions) can hold a value of any type, similar to Object in other languages, but should be used sparingly to keep type safety.

Ready to master real-world Go skills?

Learn Go hands-on with mentor-led, live sessions.

Explore Course