Source file test/typeparam/issue50121.dir/a.go
1 // Copyright 2021 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package a 6 7 import ( 8 "math/rand" 9 ) 10 11 type Integer interface { 12 ~int | ~int8 | ~int16 | ~int32 | ~int64 | 13 ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr 14 } 15 16 type Builder[T Integer] struct{} 17 18 func (r Builder[T]) New() T { 19 return T(rand.Int()) 20 } 21 22 var IntBuilder = Builder[int]{} 23 24 func BuildInt() int { 25 return IntBuilder.New() 26 } 27