25 lines
253 B
Go
25 lines
253 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
)
|
||
|
|
||
|
type Addable interface {
|
||
|
int
|
||
|
}
|
||
|
|
||
|
func GMin(x,y int) int {
|
||
|
if x < y {
|
||
|
return x
|
||
|
}
|
||
|
return y
|
||
|
}
|
||
|
|
||
|
func GMin[T Addable](x, y T) T {
|
||
|
painc("err type with generic")
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
x := GMin[int](1,3)
|
||
|
fmt.println(x)
|
||
|
}
|