Created
December 23, 2018 19:00
-
-
Save tokubass/5be743e5921685bbb2504c6ae74a5b69 to your computer and use it in GitHub Desktop.
quick sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"math/rand" | |
"reflect" | |
"testing/quick" | |
"time" | |
) | |
type Foo struct { | |
Int int8 | |
} | |
func (f *Foo) Generate(rand *rand.Rand, size int) reflect.Value { | |
return reflect.ValueOf(Foo{Int: 1}) | |
} | |
var r *rand.Rand | |
func init() { | |
r = rand.New(rand.NewSource(time.Now().UnixNano())) | |
} | |
func main() { | |
var foo = Foo{} | |
v, _ := quick.Value(reflect.TypeOf(foo), r) | |
fmt.Printf("result = %#v\n", v) | |
var fooPointer = &Foo{} | |
v, _ = quick.Value(reflect.TypeOf(fooPointer), r) | |
fmt.Printf("result = %#v\n", v) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment