Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 375 Bytes

json_tags.md

File metadata and controls

24 lines (19 loc) · 375 Bytes

JSON Struct tags

CREATE TABLE authors (
  id         SERIAL    PRIMARY KEY,
  created_at timestamp NOT NULL
);

sqlc can generate structs with JSON tags. The JSON name for a field matches the column name in the database.

package db

import (
	"time"
)

type Author struct {
	ID        int       `json:"id"`
	CreatedAt time.Time `json:"created_at"`
}