I understand that Go does not support enums of the kind shown in the Rust example below. What would be the idiomatic way of achieving the same effect, i.e., perform matching on types, in Go? For example, would I use an empty struct or an interface?
enum WebEvent {
PageLoad,
KeyPress(char),
}
fn inspect(event: WebEvent) {
match event {
WebEvent::PageLoad => println!("page loaded"),
WebEvent::KeyPress(c) => println!("pressed '{}'.", c),
}
}
Example taken from Rust By Example.