func (c *RevokedCertificate) PostGet(exe gorp.SqlExecutor) error {
	var (
		obj interface{}
		err error
	)
	if c.CertificateId != 0 {
		obj, err = exe.Get(Certificate{}, c.CertificateId)
		if err != nil {
			return fmt.Errorf("Error loading a certificate (%d): %s", c.CertificateId, err)
		}
		c.Certificate = obj.(*Certificate)
	}
	return nil
}
After getting a Revoked Certificate from db, set Certificate
package models
import (
	"fmt"
	"github.com/coopernurse/gorp"
)
type FullCertificate struct {
	Country, State, City           string
	Organization, OrganizationUnit string
	CommonName                     string
	Expires                        string
	PrivateKeyType                 string
	IsCA                           bool
	KeyUses, ExtKeyUses            []string
	SignedBy                       int
	EncryptionKey   string
	CAEncryptionKey string
}
type KeyType int
const (
	RSA KeyType = iota
	ECDSA
)
type Certificate struct {
	Id int
	PEM, PrivateKey []byte
	CommonName string
	KeyType
	SerialNumber int
	CA, Encrypted bool
	ProjectId int
	Project *Project
}
type CACount struct {
	Id int
	CertificateId int
	Certificate   *Certificate
	SerialNumber int
}
type CertificateTemplate struct {
	Id   int
	Name string
	Country, State, City           string
	Organization, OrganizationUnit string
	Expires                        string
	PrivateKeyType                 string
	IsCA                           bool
	KeyUses, ExtKeyUses            string
	SignedBy                       int
	ProjectId int
	Project *Project
}
type CertificateRequest struct {
	Id int
	CSR []byte
	RequestedCAId int
	RequestedCA *Certificate
	ProjectId int
	Project *Project
	UserId int
	User   *User
}
type CertificateOwnership struct {
	Id                    int
	CertificateId, UserId int
	Certificate *Certificate
	User        *User
}
type CertificateOneTimeDownload struct {
	Id            int
	CertificateId int
	Hash          string
	Certificate *Certificate
}
type RevokedCertificate struct {
	Id            int
	CertificateId int
	Certificate *Certificate
}
func (c *Certificate) PreInsert(_ gorp.SqlExecutor) error {
	if c.Project != nil {
		c.ProjectId = c.Project.Id
	}
	return nil
}
func (c *Certificate) PostGet(exe gorp.SqlExecutor) error {
	var (
		obj interface{}
		err error
	)
	if c.ProjectId != 0 {
		obj, err = exe.Get(Project{}, c.ProjectId)
		if err != nil {
			return fmt.Errorf("Error loading a certificate's project (%d): %s", c.ProjectId, err)
		}
		c.Project = obj.(*Project)
	}
	return nil
}
func (c *CertificateTemplate) PreInsert(_ gorp.SqlExecutor) error {
	if c.Project != nil {
		c.ProjectId = c.Project.Id
	}
	return nil
}
func (c *CertificateTemplate) PostGet(exe gorp.SqlExecutor) error {
	var (
		obj interface{}
		err error
	)
	if c.ProjectId != 0 {
		obj, err = exe.Get(Project{}, c.ProjectId)
		if err != nil {
			return fmt.Errorf("Error loading a certificate's project (%d): %s", c.ProjectId, err)
		}
		c.Project = obj.(*Project)
	}
	return nil
}
func (c *CertificateRequest) PreInsert(_ gorp.SqlExecutor) error {
	if c.Project != nil {
		c.ProjectId = c.Project.Id
	}
	if c.RequestedCA != nil {
		c.RequestedCAId = c.RequestedCA.Id
	}
	if c.User != nil {
		c.UserId = c.User.Id
	}
	return nil
}
func (c *CertificateRequest) PostGet(exe gorp.SqlExecutor) error {
	var (
		obj interface{}
		err error
	)
	if c.ProjectId != 0 {
		obj, err = exe.Get(Project{}, c.ProjectId)
		if err != nil {
			return fmt.Errorf("Error loading a certificate's project (%d): %s", c.ProjectId, err)
		}
		c.Project = obj.(*Project)
	}
	if c.RequestedCAId != 0 {
		obj, err = exe.Get(Certificate{}, c.RequestedCAId)
		if err != nil {
			return fmt.Errorf("Error loading a csr's requested CA (%d): %s", c.RequestedCAId, err)
		}
		c.RequestedCA = obj.(*Certificate)
	}
	if c.UserId != 0 {
		obj, err = exe.Get(User{}, c.UserId)
		if err != nil {
			return fmt.Errorf("Error loading a csr's requesting user (%d): %s", c.UserId, err)
		}
		c.User = obj.(*User)
	}
	return nil
}
func (c *CertificateOwnership) PreInsert(_ gorp.SqlExecutor) error {
	if c.User != nil {
		c.UserId = c.User.Id
	}
	if c.Certificate != nil {
		c.CertificateId = c.Certificate.Id
	}
	return nil
}
func (c *CertificateOwnership) PostGet(exe gorp.SqlExecutor) error {
	var (
		obj interface{}
		err error
	)
	if c.UserId != 0 {
		obj, err = exe.Get(User{}, c.UserId)
		if err != nil {
			return fmt.Errorf("Error loading a certificate's user (%d): %s", c.UserId, err)
		}
		c.User = obj.(*User)
	}
	if c.CertificateId != 0 {
		obj, err = exe.Get(Certificate{}, c.CertificateId)
		if err != nil {
			return fmt.Errorf("Error loading a certificate (%d): %s", c.CertificateId, err)
		}
		c.Certificate = obj.(*Certificate)
	}
	return nil
}
func (c *CertificateOneTimeDownload) PreInsert(_ gorp.SqlExecutor) error {
	if c.Certificate != nil {
		c.CertificateId = c.Certificate.Id
	}
	return nil
}
func (c *CertificateOneTimeDownload) PostGet(exe gorp.SqlExecutor) error {
	var (
		obj interface{}
		err error
	)
	if c.CertificateId != 0 {
		obj, err = exe.Get(Certificate{}, c.CertificateId)
		if err != nil {
			return fmt.Errorf("Error loading a certificate (%d): %s", c.CertificateId, err)
		}
		c.Certificate = obj.(*Certificate)
	}
	return nil
}
func (c *RevokedCertificate) PreInsert(_ gorp.SqlExecutor) error {
	if c.Certificate != nil {
		c.CertificateId = c.Certificate.Id
	}
	return nil
}