Help us shape the future of Go! Take the 2026 Go Developer Survey

datastore

package
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2026 License: ISC Imports: 5 Imported by: 0

Documentation

Overview

Package datastore holds the data store sources the generated DAO rely on: one variant per database (pg, mysql, sqlite, mssql) and framework (no_orm, sqlx, gorm), datastore/<db>/<orm>/. They are in the repository as is, so that they can be downloaded by hand; sdmc init takes them from here too. Under "//go:build ignore": the sdmc module needs no drivers, sqlx or gorm.

The variants are built from the shared templates templates/*.go.txt (Generate, cli/dsgen): lines between "//sdm:if pg mysql" and "//sdm:end" stay only for the listed databases, "//sdm:else" is for the rest. The template is edited, the variants are regenerated; a test makes sure they do not diverge.

templates/data_store_no_orm.go.txt comes from src/resources/data_store_no_orm.go of sdm-plugins (without Oracle).

Python has no ORM: one variant per database, python/<db>/data_store_no_orm.py, from templates/data_store_no_orm.py.txt (src/resources/data_store_no_orm.py of sdm-plugins) with the markers "#sdm:if", "#sdm:else", "#sdm:end".

C++ (Qt) has no ORM either: cpp/<db>/DataStore.h and DataStore.cpp, from templates/DataStore.*.txt (DataStore_Qt5 of sdm-plugins) with the markers of Go.

Index

Constants

View Source
const PythonFile = "data_store_no_orm.py"

PythonFile is the data store of a Python DAO folder: no ORM, one file, no "_ex".

Variables

View Source
var CppFiles = []string{"DataStore.h", "DataStore.cpp"}

CppFiles are the data store of a C++ DAO folder: no ORM, no "_ex".

View Source
var DBs = []string{"pg", "mysql", "sqlite", "mssql"}

DBs are the databases, the first is the default.

View Source
var Variants = []string{"no_orm", "sqlx", "gorm"}

Variants are the values of sdmc init -orm, the first is the default.

Functions

func CppText

func CppText(db string) (map[string]string, error)

CppText is the C++ data store of db as it goes to the DAO folder: file name -> text, with LF.

func Files

func Files(variant, db, pkg string) (map[string]string, error)

Files maps a file name to its text for the DAO folder with package pkg: without "//go:build ignore" and the header.

func Generate

func Generate(variant, db string) (map[string][]byte, error)

Generate returns the files of variant db/variant from the templates: file name -> text.

func GenerateCpp

func GenerateCpp(db string) (map[string][]byte, error)

GenerateCpp returns the C++ data store of db from its templates: file name -> text.

func GeneratePython

func GeneratePython(db string) ([]byte, error)

GeneratePython returns the Python data store of db from its template.

func PythonText

func PythonText(db string) (string, error)

PythonText is the Python data store of db as it goes to the DAO folder, with LF.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL