A generic interface defines a contract in terms of a type parameter. In Go, List[T] can specify operations on T without committing callers to one storage structure. Instantiations such as List[int] and List[User] keep those operations type-specific while sharing the same design. section 6.3
Listing 6.12 Defining a generic List interface
type List[T any] interface {
Collection[T]
Get(index int) (T, error)
Set(index int, item T) error
Insert(index int, item T) error
RemoveAt(index int) (T, error)
}
List[T any] embeds Collection[T] and adds indexed operations. An implementation must supply the embedded collection methods as well as Get, Set, Insert, and RemoveAt for the same T. section 6.3
A LinkedList[T comparable] provides a concrete implementation using node[T]. Its narrower constraint permits equality checks in Remove and Contains. Add links a new node and updates the size; indexed methods traverse nodes and check bounds. Get returns the zero value of T alongside an error when the index is invalid. Implementing every method completes the contract rather than merely declaring it. section 6.3
Write an operation against the interface
ReverseList[T comparable](l List[T]) uses Size and swaps values obtained with Get through Set. It depends on the list contract, not on linked-list nodes. A LinkedList[int] can therefore be passed to it after construction and ordinary list operations. section 6.3
Keep type arguments aligned when working with an instantiated interface. A Collection[int] holding a *LinkedList[int] can be asserted to that concrete instantiation if its dynamic type matches. An assertion to *LinkedList[string] is rejected by the compiler because that instantiation cannot implement Collection[int]. Separately, when an interface constrains a type parameter, only methods in its method set are available through that parameter. section 6.5.3

