github.com/anthonyme00/gomarkdoc@v1.0.0/testData/generics/generics.go (about)

     1  package generics
     2  
     3  // Generic is a generic struct.
     4  type Generic[T any] struct {
     5  	Field T
     6  }
     7  
     8  // NewGeneric produces a new [Generic] struct.
     9  func NewGeneric[T any](param T) Generic[T] {
    10  	return Generic[T]{Field: param}
    11  }
    12  
    13  // Method is a method of a generic type.
    14  func (g Generic[T]) Method() {}
    15  
    16  // Func is a generic function.
    17  func Func[S int | float64](s S) S {
    18  	return s
    19  }