It's certainly possible, I'm not sure why you want a flat
file though? Are you interested in doing this because
you want to keep the data files simple for access from
programs other than your own?
If the latter, if cross-program access is important to you,
you might consider just using an embedded database
like sqlite instead.
That said, I was just working on some stuff where I
needed to maintain a key/value index into a multi-gigabyte
file, and I decided to use a TSV file as the lowest common
denominator, reading it into a persistent binary KV store
on startup but writing it back out to TSV on close.
For inspiration in implementing a Go version of a relational
database program, you could take a look at the 'qawk'
database implementation in The AWK Programming
Language.