example

command
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2021 License: Apache-2.0 Imports: 9 Imported by: 0

README

depot example

This repository contains a working example using depot's code generation facility to generate a repository for a simple persistent struct.

Code Elements

Model

The file models/models.go contains a single type definition for a struct name Message:

type Message struct {
    ID         string    `depot:"id,id"`
    Text       string    `depot:"text"`
    OrderIndex int       `depot:"order_index"`
    Length     float32   `depot:"len"`
    Attachment []byte    `depot:"attachment"`
    Created    time.Time `depot:"created"`
}

The fields contain tags that define the column names as well as the id field.

Based on that definition, depot generates a repository type using the command line

$ depot -table messages -repo-package repo ./models/models.go Message > ./repo/gen-messagerepo.go 

The result is also part of this git repo: repo/gen-messagerepo.go.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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