
Go Interfaces
Interfaces, type assertions, type switches, empty interface, error interface
1What is an interface in Go?
What is an interface in Go?
Jawaban
An interface in Go is a type that defines a set of method signatures. A type implements an interface implicitly by defining all its methods, without explicit declaration. This enables strong decoupling and flexibility in Go program design.
2How does a type implement an interface in Go?
How does a type implement an interface in Go?
Jawaban
In Go, interface implementation is implicit: a type just needs to define all the methods of the interface. No explicit declaration (like 'implements' in Java) is needed. This allows adding interfaces to existing types without modifying their source code.
3What is special about the empty interface (interface{}) in Go?
What is special about the empty interface (interface{}) in Go?
Jawaban
The empty interface (interface{}) defines no methods, which means all types automatically implement it. It can therefore hold a value of any type. Since Go 1.18, it is aliased by the predeclared type 'any' for better clarity.
Since Go 1.18, what is the alias for the interface{} type?
What is the syntax for a type assertion in Go?
+15 pertanyaan wawancara
Topik wawancara Go lainnya
Go Basics
Go Data Structures
Error Handling
Goroutines Basics
Channels
Go Modules
HTTP Server
HTTP Client
JSON Encoding
database/sql
Context Package
Testing
Concurrency Patterns
Sync Primitives
Go Web Frameworks
REST API Design
gRPC
Reflection
Memory Management
Performance Optimization
Generics
Go Design Patterns
Microservices
Security & Authentication
Docker & Containerization
Kubernetes Basics
Advanced Go
CLI Development
Kuasai Go untuk wawancara berikutnya
Akses semua pertanyaan, flashcards, tes teknis, latihan code review dan simulator wawancara.
Mulai gratis