Extending with Go code

Is there documentation how to extend Hugo with own Go code? I need driver for database and template enhanced with support for SQL.

Do I need to build own binary or Go can load dynamic modules?

You might take a look at this thread: Go Plugins to extend Hugo