How does Go achieve implicit interface implementation?
- By using type assertions.
- By using type conversion.
- By using type embedding.
- By using type inference.
Go achieves implicit interface implementation through type embedding. In Go, if a type contains another type as a field, it automatically implements the methods of that inner type. This allows for seamless interface implementation without explicitly declaring it.
Loading...
Related Quiz
- The _______ function in Go is used to panic, terminating the program immediately with a runtime error message.
- What format is commonly used for data interchange in Go?
- In a Go application, you encounter a circular import error. How would you refactor your code to resolve this issue?
- In a Gin application, to capture parameters from the URL, you would use the _____ placeholder in the route definition.
- In Go, the ________ interface allows you to define custom JSON marshaling and unmarshaling logic.