News for hackers. Stuff that matters.
Re:Ask HN: What do you like/dislike about Golang? by sidlls on Sunday November 27, 2022 @09:36PM (#33769229)
Generics as currently implemented in go are so limited that you may as well stick with interfaces for anything but trivial boilerplate or textbook data structure/algorithm implementations.

For example, it's currently impossible to define type constraints with user-defined interfaces embedded:

  ```
  // this is legal
  type MyConstraint interface {
    int64 | float
  }

  type SomeAPI interface {
    AMethod() error
  }

  // Nope
  type CantHaveThisConstraint interface {
    int64 | float | SomeAPI
  }

  // NOPE
  func SomeGeneric[T CantHaveThisConstraint](...) {
  }
  ```
Re:Ask HN: What do you like/dislike about Golang? by morelisp on Monday November 28, 2022 @02:29AM (#33770688)
It's true that doesn't work because you can't mix types with methods and types with no methods. But that's a far cry from "Go doesn't have generic types" or "may as well stick with interfaces for anything but trivial boilerplate".