Hacker News new | ask | show | jobs
by utahcon 2510 days ago
Honestly asking what "generics" offers over passing and handling interface{}.

  func myBlah(thing interface{}){
    switch thing.(type) {
      case int:
        // handle my int
      case string:
        // handle my string
      default:
        // default handling
    }
  }
1 comments

See [0] which is a code generated piece of the ActivityStreams spec. As it is RDF based, it is an open ended set. Not worth doing by hand.

[0] https://github.com/go-fed/activity/blob/master/streams/gen_t...