gotsql

package module
v0.0.0-...-ed9a77b Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: MIT Imports: 5 Imported by: 0

README

GoTSQL - A Better Way to Organize SQL codebase using Templates in Golang

  1. Installation through Go Get command

    $ go get github.com/migopsrepos/gotsql
    
  2. Initialize the GoTSQL object

    import "github.com/migopsrepos/gotsql"
    ...
    g := gotsql.GoTSQL{}
    
  3. Load the template file or directory with template files. (Templates are discussed in detail in next section)

    g.Load("library/")
    ...
    g.Load("library_dev/")
    
  4. Get the query using namespace and use it in Golang

    query, err := g.Get("library/books/crud/getAllBooks", nil)
    ...
    rows, err := db.Query(query, ...)
    
    
    

You can find the usage and more examples in this article

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GoTSQL

type GoTSQL struct {
	Templates map[string]*template.Template
}

func (*GoTSQL) Get

func (g *GoTSQL) Get(commandName string, data interface{}) (string, error)

func (*GoTSQL) Load

func (g *GoTSQL) Load(filedir string)

Jump to

Keyboard shortcuts

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