PostgreSQL CREATE TABLE to Go struct
Paste a PostgreSQL CREATE TABLE and get a Go struct with json tags matching the column names. Nullable columns become pointers with ,omitempty, timestamps become time.Time, and NUMERIC maps to string (Go has no stdlib decimal and float64 corrupts money math).
Mapped from your real DDL, on the server, discarded after the response.
Example
CREATE TABLE product (
id BIGSERIAL PRIMARY KEY,
sku VARCHAR(40) UNIQUE NOT NULL,
name VARCHAR(200) NOT NULL,
price NUMERIC(12, 2) NOT NULL,
in_stock BOOLEAN NOT NULL DEFAULT true,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
package models
import (
"time"
)
type Product struct {
Id int64 `json:"id"`
Sku string `json:"sku"`
Name string `json:"name"`
Price string `json:"price"`
InStock bool `json:"in_stock"`
CreatedAt time.Time `json:"created_at"`
}