Go code
type Speaker interface {
Speak() string
}Line-by-line explanation
- Speaker is an interface type.
- Its contract requires one Speak method.
- That method must return a string.
Expected output
(no output)The interface defines a contract but performs no action.
Go uses implicit satisfaction: a type does not declare that it implements an interface. Having the required methods is enough.