Skip to content

Instantly share code, notes, and snippets.

@volkanozcan2
Created October 16, 2020 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save volkanozcan2/fa55a9c8e9d2bd8cbff7dc80a695646a to your computer and use it in GitHub Desktop.
Save volkanozcan2/fa55a9c8e9d2bd8cbff7dc80a695646a to your computer and use it in GitHub Desktop.
faker go library usage sample.
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