example

command
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2021 License: Apache-2.0 Imports: 10 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. The generation is configured by placing a //go:generate comment in models.go.

To run the generation, execute

$ go generate ./models

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

Documentation

Overview

Package main contains a cli demonstrating the generated repo's usage.

Directories

Path Synopsis
Package models contains the model definitions.
Package models contains the model definitions.

Jump to

Keyboard shortcuts

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