codex

command module
v0.0.0-...-d21667e Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2022 License: MIT Imports: 18 Imported by: 0

README

codex

Generate binary encoder/decoders for structs

Documentation

Overview

dbgen is a tool to automate the creation of create/update/delete methods that satisfy the github.com/paulstuart/dbobj.DBObject interface.

For example, given this snippet,

package dbobjs
type User struct {
	ID       int64		`sql:"id" key:"true" table:"users"`
	Username string		`sql:"username"`
	First    string		`sql:"firstname"`
	Last     string		`sql:"lastname"`
	Email    string		`sql:"email"`
	Role     int		`sql:"role"`
	UserID   int64		`sql:"userid"    audit:"user"`
	Modified time.Time  `sql:"modified"  audit:"time"`
	Created  time.Time  `sql:"created"  update="false"
}

running this command

dbgen

in the same directory will create the file db_generated.go, in package dbobjs, containing the definition:

Typically this process would be run using go generate, like this:

//go:generate dbgen

The -type flag accepts a comma-separated list of types so a single run can generate methods for multiple types. The default output file is db_generated.go, where t is the lower-cased name of the first type listed. It can be overridden with the -output flag.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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