Created
October 16, 2020 18:09
-
-
Save volkanozcan2/fa55a9c8e9d2bd8cbff7dc80a695646a to your computer and use it in GitHub Desktop.
faker go library usage 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" | |
"github.com/bxcodec/faker" | |
) | |
type pixel struct { | |
R, G, B uint8 | |
A uint8 `faker:"oneof: 254, 255"` | |
} | |
func (p *pixel) lesser(q pixel) bool { | |
if p.A == 255 && p.R < q.R && p.G < q.G && p.B < q.B { | |
fmt.Println(p) | |
return true | |
} | |
return false | |
} | |
func main() { | |
foo := [1e3]pixel{} | |
err := faker.FakeData(&foo) | |
if err != nil { | |
panic(err) | |
} | |
for _, x := range foo { | |
t := pixel{22, 22, 22, 22} | |
if x.lesser(t) { | |
fmt.Println("ok") | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment