Skip to content

Multi Field Model

This example demonstrates a model with multiple fields of different types, showcasing datagen’s support for various data types.

Create a file named user_profile.dg:

user_profile.dg
model user_profile {
fields {
id() int
name() string
is_active() bool
rating() float64
created_at() time.Time
}
gens {
func id() {
return iter + 1
}
func name() {
return Name()
}
func is_active() {
return Boolean()
}
func rating() {
return FloatBetween(1, 5)
}
func created_at() {
return time.Now()
}
}
}
Terminal window
$ datagenc gen . -f csv -n 3
Terminal window
$ cat user_profile.csv
id,name,is_active,rating,created_at
1,Estrella Donnelly,true,4.4,2025-10-29 13:05:08.297628 +0530 IST m=+0.026148126
2,Stone Mosciski,false,3.62,2025-10-29 13:05:08.29763 +0530 IST m=+0.026150210
3,Bessie Gutkowski,false,1.05,2025-10-29 13:05:08.297631 +0530 IST m=+0.026151668