Overview Like any other variable, an interface variable is represented by a type and value. Interface value, in turn under the hood consists of two tuple Underlying Type Underlying Value See below…
Author: admin
Print underlying type and value of an interface in Go (Golang)
Overview Golang provides format identifiers to print the underlying type and underlying value represented by the interface value. %T can be used to print the concrete type of the interface value %v…
Type Implementing multiple interfaces in Go (Golang)
Overview A type implements an interface if it defines all methods of an interface. If that type defines all methods of another interface then it implements that interface. In essence, a type…
Interfaces are implemented implicitly in Go (Golang)
There is no explicit declaration that a type implements an interface. Infact, in Go there doesn’t exist any “implements” keyword similar to Java. A type implements an interface if it implements all…
Declaring and Implementing an interface in Go (Golang)
Overview Interface is a type in Go which is a collection of method signatures. These collection of method signatures are meant to represent a behaviour. The interface declares only the method set…
Pointer vs Value Receiver in methods while implementing an interface in Go (Golang)
A method of a type can either have a pointer receiver or a value receiver. There is a caveat while pointer vs value receiver for methods of a type when that type…
Benefits of Interface in Go (Golang)
Below are some benefits of using interface. Helps write more modular and decoupled code between different parts of the codebase – It can help reduce dependency between different parts of the codebase…
Interface Comparison in Go (Golang)
For understanding whether two interface variables are equal or not, we first need to understand the internal representation of an interface. Like any other variable, an interface variable is represented by a…
Embedding Interfaces in Go (Golang)
An interface can be embedded in another interface as well as it can be embedded in a struct. Let’s look at each one by one Embedding interface in another interface An interface…
Interface in Go (Golang)
This is the chapter 21 of the golang comprehensive tutorial series. Refer to this link for other chapters of the series – Golang Comprehensive Tutorial Series Next Tutorial – IotaPrevious Tutorial – Method Now let’s check…