In the following code I have a token type that contains a literal value. By using an empty interface I can create a slice of tokens and append tokens that have different types. I don't think it's possible to accomplish the same using generics since we wouldn't be able to infer a type for the Slice of tokens. Is this assumption correct?
type Token struct {
TokenType string
Literal interface{}
}
func main(){
tok1 := &Token{TokenType: "string", Literal: "foo"}
tok2 := &Token{TokenType: "integer", Literal: 10}
tokS := []*Token{tok1, tok2}
}