Sqlt
A Go Template-Based SQL Builder and Struct Mapper.
Install / Use
/learn @go-sqlt/SqltREADME
A Go Template-Based SQL Builder and Struct Mapper
go get -u github.com/go-sqlt/sqlt
sqlt uses Go’s template engine to create a flexible, powerful, and type-safe SQL builder and struct mapper.
Struct mapping is handled by the structscan package. The Scan function (== structscan.Scan[Dest]()) provides a fluent API for field-based value extraction and transformation.
Example
package main
import (
"context"
"database/sql"
"fmt"
"math/big"
"net/url"
"time"
"github.com/go-sqlt/sqlt"
_ "modernc.org/sqlite"
)
type Data struct {
Int int64
String string
Bool bool
Time time.Time
Big *big.Int
URL *url.URL
Slice []string
JSON map[string]any
}
var query = sqlt.All[string, Data](sqlt.Parse(`
SELECT
100 {{ Scan.Int.To "Int" }}
, NULL {{ Scan.Nullable.String.To "String" }}
, true {{ Scan.Bool.To "Bool" }}
, {{ . }} {{ (Scan.String.ParseTime DateOnly).To "Time" }}
, '300' {{ Scan.Text.To "Big" }}
, 'https://example.com/path?query=yes' {{ Scan.Binary.To "URL" }}
, 'hello,world' {{ (Scan.String.Split ",").To "Slice" }}
, '{"hello":"world"}' {{ Scan.JSON.To "JSON" }}
`))
func main() {
db, err := sql.Open("sqlite", ":memory:")
if err != nil {
panic(err)
}
data, err := query.Exec(context.Background(), db, time.Now().Format(time.DateOnly))
if err != nil {
panic(err)
}
fmt.Println(data) // [{100 true 2025-07-22 00:00:00 +0000 UTC 300 https://example.com/path?query=yes [hello world] map[hello:world]}]
}
Related Skills
oracle
339.3kBest practices for using the oracle CLI (prompt + file bundling, engines, sessions, and file attachment patterns).
xurl
339.3kA CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.
prose
339.3kOpenProse VM skill pack. Activate on any `prose` command, .prose files, or OpenProse mentions; orchestrates multi-agent workflows.
Command Development
83.9kThis skill should be used when the user asks to "create a slash command", "add a command", "write a custom command", "define command arguments", "use command frontmatter", "organize commands", "create command with file references", "interactive command", "use AskUserQuestion in command", or needs guidance on slash command structure, YAML frontmatter fields, dynamic arguments, bash execution in commands, user interaction patterns, or command development best practices for Claude Code.
