func (p *PgDump) GetStructure() (string, error) {
	logger := log.WithField("command", p.command)
	cmd := exec.Command(
		p.command,
		"--dbname", p.dsn,
		"--schema-only",
		"--no-privileges",
		"--no-owner",
		"--no-comments",
	)
	logger.Debug("loading schema for table")
	cmdErr := logger.WriterLevel(log.WarnLevel)
	defer cmdErr.Close()
	buf := new(bytes.Buffer)
	cmd.Stdin = nil
	cmd.Stderr = cmdErr
	cmd.Stdout = buf
	if err := cmd.Run(); err != nil {
		logger.Error("failed to load schema for table")
	}
	return buf.String(), nil
}
GetStructure executes the pg dump command.
package postgres
import (
	"bytes"
	"os/exec"
	log "github.com/sirupsen/logrus"
)
type (
	PgDump struct {
		command string
		dsn     string
	}
)
func NewPgDump(dsn string) (*PgDump, error) {
	path, err := exec.LookPath("pg_dump")
	if err != nil {
		return nil, err
	}
	return &PgDump{
		command: path,
		dsn:     dsn,
	}, nil
}