← Back to archive

Stdle #43 · interfaces · 2026-07-19

What does this Go snippet output?

A past puzzle — fully playable. 4 attempts, hints on wrong guesses.

package main
import "fmt"
type Greeter interface{ Hi() string }
type En struct{}
func (En) Hi() string { return "hello" }
func main() {
var g Greeter = En{}
var i interface{} = g
g2, ok := i.(Greeter)
fmt.Println(ok, g2.Hi())
}
Interfaces
4 attempts left

Answer & explanation