Skip to content

Getting Started

Get up and running with datagen in just a few minutes. This guide will walk you through installing datagen and generating your first dataset.

Check your $PATH, and choose a directory you would like to place the datagenc compiler in.

Terminal window
echo $PATH
/Users/username/go/bin:/opt/homebrew/bin:/opt/homebrew/sbin

Say, you wish to place the binary in /opt/homebrew/bin;

Terminal window
export GOBIN=/opt/homebrew/bin
go install github.com/ds-horizon/datagen/cmd/datagenc@latest
Terminal window
datagenc --help
Terminal window
git clone github.com/ds-horizon/datagen
Terminal window
make build-compiler

Now, source the rc files or fire up a new terminal window for the changes to take effect.

Terminal window
datagenc --help

Let’s create a simple user model to generate some test data.

users.dg
model users {
fields {
name() string
age() int
}
gens {
func name() {
return "Arthur Dent"
}
func age() {
return IntBetween(18, 65)
}
}
}

Now let’s generate some data from this model:

Terminal window
datagenc gen users.dg

Output:

Terminal window
users{name:Arthur Dent age:42}