I\'ve created an API in Go that, upon being called, performs a query, creates an instance of a struct, and then encodes that struct as JSON before sending back to the caller
You can use tagging attribute "omitifempty" or make optional fields pointers and leave those you want skipped uninitialized.