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:
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() } }}How to Run
Section titled “How to Run”$ datagenc gen . -f csv -n 3Output
Section titled “Output”$ cat user_profile.csvid,name,is_active,rating,created_at1,Estrella Donnelly,true,4.4,2025-10-29 13:05:08.297628 +0530 IST m=+0.0261481262,Stone Mosciski,false,3.62,2025-10-29 13:05:08.29763 +0530 IST m=+0.0261502103,Bessie Gutkowski,false,1.05,2025-10-29 13:05:08.297631 +0530 IST m=+0.026151668