template generation, rename project

pull/2/head
Brad Rydzewski 7 years ago
parent 6d2764d659
commit 388148c2d3

@ -6,8 +6,8 @@ import (
"github.com/urfave/cli"
"github.com/bradrydzewski/sqlbin/parser"
"github.com/bradrydzewski/sqlbin/template"
"github.com/bradrydzewski/togo/parser"
"github.com/bradrydzewski/togo/template"
)
type migration struct {
@ -92,7 +92,7 @@ func ddlAction(c *cli.Context) error {
}
wr := os.Stdout
if output := c.String("output"); output != "-" {
if output := c.String("output"); output != "" {
wr, err = os.Create(output)
if err != nil {
return err

@ -6,8 +6,8 @@ import (
"github.com/urfave/cli"
"github.com/bradrydzewski/sqlbin/parser"
"github.com/bradrydzewski/sqlbin/template"
"github.com/bradrydzewski/togo/parser"
"github.com/bradrydzewski/togo/template"
)
type sqlParams struct {
@ -66,7 +66,7 @@ func sqlAction(c *cli.Context) error {
}
wr := os.Stdout
if output := c.String("output"); output != "-" {
if output := c.String("output"); output != "" {
wr, err = os.Create(output)
if err != nil {
return err

@ -0,0 +1,103 @@
package main
import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/urfave/cli"
"github.com/bradrydzewski/togo/template"
)
type (
tmplParams struct {
Encode bool
Package string
Format string
Funcs string
Files []*tmplFile
}
tmplFile struct {
Base string
Name string
Path string
Ext string
Data string
}
)
var tmplCommand = cli.Command{
Name: "tmpl",
Usage: "embed template files",
Action: tmplAction,
Flags: []cli.Flag{
cli.StringFlag{
Name: "package",
Value: "template",
},
cli.StringFlag{
Name: "func",
},
cli.StringFlag{
Name: "input",
Value: "files/*.tmpl",
},
cli.StringFlag{
Name: "output",
Value: "template_gen.go",
},
cli.StringFlag{
Name: "format",
Value: "text",
},
cli.BoolFlag{
Name: "encode",
},
},
}
func tmplAction(c *cli.Context) error {
pattern := c.Args().First()
if pattern == "" {
pattern = c.String("input")
}
matches, err := filepath.Glob(pattern)
if err != nil {
return err
}
params := tmplParams{
Encode: c.Bool("encode"),
Package: c.String("package"),
Format: c.String("format"),
Funcs: c.String("func"),
}
for _, match := range matches {
raw, ioerr := ioutil.ReadFile(match)
if ioerr != nil {
return ioerr
}
params.Files = append(params.Files, &tmplFile{
Path: match,
Name: filepath.Base(match),
Base: strings.TrimSuffix(filepath.Base(match), filepath.Ext(match)),
Ext: filepath.Ext(match),
Data: string(raw),
})
}
wr := os.Stdout
if output := c.String("output"); output != "" {
wr, err = os.Create(output)
if err != nil {
return err
}
defer wr.Close()
}
return template.Execute(wr, "tmpl.tmpl", params)
}

@ -1,12 +0,0 @@
package main
import "github.com/urfave/cli"
var embedCommand = cli.Command{
Name: "embed",
Usage: "embed commands",
Subcommands: []cli.Command{
ddlCommand,
sqlCommand,
},
}

@ -9,13 +9,14 @@ import (
func main() {
app := cli.NewApp()
app.Name = "sqlbin"
app.Usage = "sqlbin provides too for embedding sql opterations in your binary"
app.Name = "togo"
app.Usage = "togo provides tools to convert files to go"
app.Version = "1.0.0"
app.Author = "bradrydzewski"
app.Commands = []cli.Command{
ddlCommand,
sqlCommand,
tmplCommand,
}
if err := app.Run(os.Args); err != nil {
fmt.Println(err)

@ -1,3 +1,3 @@
package ddl
//go:generate sqlbin ddl
//go:generate togo ddl

@ -1,3 +1,3 @@
package sql
//go:generate sqlbin sql
//go:generate togo sql

@ -0,0 +1,5 @@
<html>
<body>
Hello world
</body>
</html>

@ -0,0 +1,5 @@
<html>
<body>
Hola Mundo
</body>
</html>

@ -0,0 +1,10 @@
package template
import "strings"
//go:generate togo tmpl -func funcMap -format html
var funcMap = map[string]interface{}{
"uppercase": strings.ToUpper,
"lowercase": strings.ToLower,
}

@ -0,0 +1,51 @@
package template
import "html/template"
// list of embedded template files.
var files = []struct {
name string
data string
}{
{
name: "en.tmpl",
data: en,
}, {
name: "es.tmpl",
data: es,
},
}
// T exposes the embedded templates.
var T *template.Template
func init() {
T = template.New("_").Funcs(funcMap)
for _, file := range files {
T = template.Must(
T.New(file.name).Parse(file.data),
)
}
}
//
// embedded template files.
//
// files/en.tmpl
var en = `<html>
<body>
Hello world
</body>
</html>
`
// files/es.tmpl
var es = `<html>
<body>
Hola Mundo
</body>
</html>
`

@ -0,0 +1,49 @@
package {{ .Package }}
import "{{ .Format }}/template"
{{- $encoded := .Encode }}
// list of embedded template files.
var files = []struct{
name string
data string
} {
{{ range .Files -}}
{
name: {{ printf "%q" .Name }},
{{ if $encoded -}}
data: string({{ .Base | camelize }}),
{{- else -}}
data: {{ .Base | camelize }},
{{- end }}
},
{{- end }}
}
// T exposes the embedded templates.
var T *template.Template
func init() {
T = template.New("_"){{ if .Funcs }}.Funcs({{ .Funcs }}){{ end }}
for _, file := range files {
T = template.Must(
T.New(file.name).Parse(file.data),
)
}
}
//
// embedded template files.
//
{{ range .Files }}
// {{ .Path }}
{{ if $encoded }}
var {{ .Base | camelize }} = []byte{
{{ .Data | hexdump }}
}
{{ else }}
var {{ .Base | camelize }} = `{{ .Data }}`
{{ end }}
{{ end }}

@ -0,0 +1,48 @@
package template
import "bytes"
// hexdump is a template function that creates a hux dump
// similar to xxd -i.
func hexdump(v interface{}) string {
var data []byte
switch vv := v.(type) {
case []byte:
data = vv
case string:
data = []byte(vv)
default:
return ""
}
var buf bytes.Buffer
for i, b := range data {
dst := make([]byte, 4)
src := []byte{b}
encode(dst, src, ldigits)
buf.Write(dst)
buf.WriteString(",")
if (i+1)%cols == 0 {
buf.WriteString("\n")
}
}
return buf.String()
}
// default number of columns
const cols = 12
// hex lookup table for hex encoding
const (
ldigits = "0123456789abcdef"
udigits = "0123456789ABCDEF"
)
func encode(dst, src []byte, hextable string) {
dst[0] = '0'
dst[1] = 'x'
for i, v := range src {
dst[i+1*2] = hextable[v>>4]
dst[i+1*2+1] = hextable[v&0x0f]
}
}

@ -1,38 +1,21 @@
package template
//go:generate go-bindata -pkg template -o template_gen.go files/
//go:generate togo tmpl -func FuncMap -format text -encode
import (
"bytes"
"io"
"path/filepath"
"strings"
"text/template"
"unicode"
)
// parsed template
var tmpl *template.Template
// init loads the templates from the embedded file map. This function will not
// compile if go generate is not executed before.
func init() {
dir, _ := AssetDir("files")
tmpl = template.New("_").Funcs(FuncMap)
for _, name := range dir {
path := filepath.Join("files", name)
src := MustAsset(path)
tmpl = template.Must(
tmpl.New(name).Parse(string(src)),
)
}
}
// Execute renders the named template and writes to io.Writer wr.
func Execute(wr io.Writer, name string, data interface{}) error {
buf := new(bytes.Buffer)
err := tmpl.ExecuteTemplate(buf, name, data)
err := T.ExecuteTemplate(buf, name, data)
if err != nil {
return nil
return err
}
src, err := format(buf)
if err != nil {
@ -46,6 +29,7 @@ func Execute(wr io.Writer, name string, data interface{}) error {
var FuncMap = template.FuncMap{
"substr": substr,
"camelize": camelize,
"hexdump": hexdump,
}
func substr(s string, i int) string {
@ -55,6 +39,9 @@ func substr(s string, i int) string {
func camelize(kebab string) (camelCase string) {
isToUpper := false
for _, runeValue := range kebab {
if !isCamelCase(runeValue) {
continue
}
if isToUpper {
camelCase += strings.ToUpper(string(runeValue))
isToUpper = false
@ -68,3 +55,7 @@ func camelize(kebab string) (camelCase string) {
}
return
}
func isCamelCase(r rune) bool {
return r == '-' || unicode.IsLetter(r) || unicode.IsDigit(r)
}

@ -1,260 +1,357 @@
// Code generated by go-bindata.
// sources:
// files/ddl.tmpl
// files/sql.tmpl
// DO NOT EDIT!
package template
import (
"bytes"
"compress/gzip"
"fmt"
"io"
"io/ioutil"
"os"
"path/filepath"
"strings"
"time"
)
func bindataRead(data []byte, name string) ([]byte, error) {
gz, err := gzip.NewReader(bytes.NewBuffer(data))
if err != nil {
return nil, fmt.Errorf("Read %q: %v", name, err)
}
var buf bytes.Buffer
_, err = io.Copy(&buf, gz)
clErr := gz.Close()
if err != nil {
return nil, fmt.Errorf("Read %q: %v", name, err)
}
if clErr != nil {
return nil, err
}
return buf.Bytes(), nil
}
type asset struct {
bytes []byte
info os.FileInfo
}
type bindataFileInfo struct {
name string
size int64
mode os.FileMode
modTime time.Time
}
func (fi bindataFileInfo) Name() string {
return fi.name
}
func (fi bindataFileInfo) Size() int64 {
return fi.size
}
func (fi bindataFileInfo) Mode() os.FileMode {
return fi.mode
}
func (fi bindataFileInfo) ModTime() time.Time {
return fi.modTime
}
func (fi bindataFileInfo) IsDir() bool {
return false
}
func (fi bindataFileInfo) Sys() interface{} {
return nil
}
var _filesDdlTmpl = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xa4\x56\x6d\x6f\xdb\x36\x10\xfe\x2c\xfd\x8a\x9b\xb0\x06\xd2\xe6\xca\xe8\x80\x7d\xf1\x10\x0c\xa9\xab\x62\x06\x52\xa7\xb5\x9d\x62\x40\x50\x2c\xb4\x44\xa9\x42\xf4\x16\x92\xde\xb2\x09\xfa\xef\xbb\x23\x25\x8b\x9e\x1c\x2c\xc3\x3e\x18\x30\x4f\x77\xcf\x73\xef\x64\xc3\xe2\x07\x96\x71\x68\x5b\x08\x3f\xf6\xff\xbb\xce\x75\xf3\xb2\xa9\x85\x02\xdf\x75\xbc\x84\x29\xb6\x67\x92\xcf\xe5\x63\xe1\xb9\x4e\xdb\xbe\x86\x3c\x85\xf0\xba\xce\x32\x2e\xc2\xa8\x62\xfb\x82\x27\x64\xe4\x78\x45\x9d\xf5\x1a\xbc\xd2\xa2\xc0\x75\x7f\x67\x02\xca\x3c\x13\x4c\xe5\x75\x25\xe1\x12\xee\xbe\x48\x25\x0e\xb1\x82\xd6\x75\x2a\x56\x72\xc0\x63\x5e\x65\xae\x23\x55\xa9\xcc\x57\x3a\x76\xad\x41\x12\xac\x42\x9f\xc2\x0f\x23\x04\x51\xe1\x47\x6d\xbc\x20\xcf\x1b\x34\x50\x29\x78\xaf\x1e\x3d\x08\xd7\x04\xd9\x75\x33\x54\x20\xc0\xc5\x11\x91\x4c\x6c\xc4\xad\x62\x8a\x97\xbc\x52\x06\x91\xbe\x41\x8c\xc6\x45\xfe\x17\x3f\x81\xb1\x03\x72\x1c\x12\xd1\xcf\x12\x62\xbe\xe6\x73\x30\x1e\x72\x68\xb8\x48\x6b\x51\x4a\x50\x5f\x39\x0c\xc9\x1b\x53\x10\xc2\x2a\xd5\x9f\x8e\x12\x48\x59\x5e\x48\x82\x60\x88\xc7\x85\xa8\x05\xe4\x12\x04\x57\x07\x51\xf1\x24\x74\xd3\x43\x15\x0f\xf0\x7e\xb2\x87\xef\xb0\x12\xe1\xbb\xb7\x41\xaf\x8b\x81\x61\x41\xf0\x3f\x2c\x2e\x21\x16\x1c\xb5\x76\x54\x14\x54\x0d\x7e\xd2\xf2\x6f\x2e\xa1\xca\x0b\x52\x74\x0c\x2a\x49\x31\x0c\xd7\x89\xeb\xb2\x29\xb8\xe2\xc9\x6c\x00\x90\xbc\xe0\xb1\x5a\x0e\x72\x02\x39\xe2\xf7\x38\x17\x17\xc3\x89\x1c\x89\x84\x58\xd7\x9b\xfa\x0f\x79\x0e\x1f\x33\x01\xbf\xcd\xac\x58\x91\xc1\xe4\xdf\xea\x09\xb2\x43\xa5\xfa\x41\x07\x30\x30\xdf\x8d\x29\xa3\x4a\x7f\x41\x25\x74\x03\x95\x8e\x85\x7c\xa6\x0d\x1d\x27\xe1\xfb\x43\xe6\x7b\x23\xab\x7c\xc8\x9b\x86\x27\x0b\x78\x25\x3d\xcb\x1b\x0d\x1c\x4c\x4a\x8c\x59\xa9\x54\x5e\x1d\x38\x95\x1b\x7f\x7d\x10\xba\x3f\xa7\xfe\x87\x5a\xfe\xef\x4e\xe5\x55\x5a\x9f\xf8\xa4\x98\x50\xcf\xfa\xd4\x37\x24\xf9\xf4\xba\xb7\x4f\xc9\x89\xbe\x4a\xc9\x3e\x8c\x9e\x78\xec\x13\xf7\xb4\xc8\xa7\x65\x30\x41\x58\x3d\x92\x57\x92\x0b\x75\x9c\x28\x2c\xf1\x84\xff\x05\x90\xff\x39\xe0\x34\xaf\x72\xf9\xf5\xc5\x55\xe8\x74\x03\xf5\xac\xe8\x06\x8d\x99\x9e\x84\xd3\x16\x3f\x33\x0d\xd3\x34\x1d\xb9\xb4\xd5\x52\x03\x04\xae\x1d\xd2\x00\x3e\xcd\xcd\x40\x30\x03\x6b\x5b\xbd\x8c\x6d\xa5\xc1\x8c\xe1\x79\xba\xe9\xb4\x8d\xf1\xf8\x25\x6b\xee\x0c\x5d\xbf\x32\xdb\x6e\x66\x78\x03\x22\xb6\x26\x08\xc9\xcf\x28\xb7\x94\x3f\x1c\x4c\xdb\xc1\x4f\x07\x2e\xfe\x1c\x3d\xdc\x6a\xfe\xc9\x84\x5b\x93\x8c\xc7\xd9\x71\x9c\x13\x9e\x72\x01\x84\x19\x2e\x8b\x5a\x72\x3f\x30\x23\xae\x25\x6b\xfe\xa4\x7c\xed\x99\x43\x4b\xff\x64\xb7\x5b\xdd\xa7\x75\xb7\x31\xab\xfc\x8b\x67\x5a\x6d\xc2\xac\x1b\x78\x0c\xf7\x4e\xef\x03\xbc\x4a\xec\x40\xc7\x5e\x19\x15\x67\x43\xdf\xe0\x24\x9d\x6f\xd3\xf9\x9c\xf6\x2e\xde\x5b\x19\xba\x09\x54\x12\x6d\x48\x72\x53\x20\xb3\x4a\x4a\x2e\x25\x5d\x8d\x26\x9c\x19\x34\x4c\x30\xdc\xf0\x61\x18\xe2\xcd\x83\xfb\x9e\xc5\xbc\xed\x74\xe8\x08\x15\x7e\xd4\xf7\x91\xd5\xfa\x0b\x03\xb3\x00\xef\xfb\x1e\x69\x80\x40\x84\xc0\xea\x3d\x1c\x98\xff\x4d\x45\x28\xcf\x33\xf5\x3b\xa5\xd3\x77\x16\xc5\x3e\xce\xa7\xa2\xac\x40\x92\x14\xfa\x1e\xc2\x2e\xd4\x59\x38\xb9\xbf\xad\xf1\xc1\xf4\xdf\xbb\xcb\x4d\x74\xb5\x8b\x60\x77\xf5\xf6\x3a\x82\xd5\x7b\x58\xdf\xec\x20\xfa\x75\xb5\xdd\x6d\xed\xfd\xee\xbb\xa6\x19\x3e\x5f\x6d\x96\xbf\x5c\x6d\xfc\x1f\xdf\xfc\x10\xb8\xb3\xdb\xf5\xea\xd3\x6d\xe4\x9b\xd9\x08\xdc\xfb\x7f\x50\x99\xd9\xd1\x2c\xab\xf5\x36\xda\xec\x60\xb5\xde\xdd\x9c\xc0\x6a\x53\x44\xbd\xbe\x8d\xb6\xe0\x9b\x1a\xf3\x47\x08\xdf\xe5\x8c\xba\x1a\xbc\xa6\x96\x2a\x13\x5c\x7a\xb4\x43\xe1\xdb\x37\xa0\x17\x4c\x81\xd7\x31\x9d\x7f\xd6\xc7\x3e\x1d\x53\x07\xcc\x68\x68\x07\xb6\xd1\x75\xb4\xdc\x99\x20\xde\x6f\x6e\x3e\x58\x5e\x90\x19\x32\x9f\x7d\xa5\x98\x04\xd3\xd3\xaa\x7f\x4d\x90\x64\x54\x3e\x7d\x80\x68\xf2\x73\x4f\x10\xed\x01\x81\x7c\x66\xc5\x41\xa3\xdc\x5b\x55\x1c\xff\xfd\x1d\x00\x00\xff\xff\x9f\xa5\x9f\x1c\xcb\x09\x00\x00")
func filesDdlTmplBytes() ([]byte, error) {
return bindataRead(
_filesDdlTmpl,
"files/ddl.tmpl",
)
}
func filesDdlTmpl() (*asset, error) {
bytes, err := filesDdlTmplBytes()
if err != nil {
return nil, err
}
info := bindataFileInfo{name: "files/ddl.tmpl", size: 2507, mode: os.FileMode(420), modTime: time.Unix(1490514174, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
var _filesSqlTmpl = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\x6c\x50\xcd\x4a\xc7\x30\x0c\x3f\xdb\xa7\x08\x7f\x10\x14\xb4\xbb\x0b\xbe\x81\x88\x20\x78\x19\x03\xc3\x96\xcd\xb1\x2d\xab\x5d\x2b\xe2\xe8\xbb\x9b\xb4\xd3\xd3\x4e\xc9\xf2\xfb\x5c\x1d\xb6\x13\x0e\x04\xfb\x0e\xf6\xe5\xd8\x53\x32\xa6\xaa\xe0\x69\x5d\xa7\xe8\xc0\x53\x88\x9e\x37\x08\x1f\x04\x8c\x0b\x75\xb0\x05\x0c\xb4\x10\x07\x6b\xfa\xc8\xed\x41\xbc\x51\x50\x30\x3f\xf2\x70\x7b\x4c\xd8\xcd\x55\xd1\xc3\xc8\x1d\x7d\xd7\xca\x69\x8c\xf8\x7f\xa1\x2f\x27\x78\x84\x05\x5d\x5d\xf8\x4d\x19\xa2\x92\x3e\x1e\x59\xca\xd8\xd7\xbf\xb4\x0d\xee\xa5\x99\x22\x4e\x48\xa1\x87\xcb\xf5\xe7\x05\xec\xb3\xc6\xa6\xf4\xa0\xbf\xd0\xca\x3e\x8f\x3f\xf4\x7f\xbd\xcb\x7c\xe2\x2e\x6b\x25\xf7\xd4\x57\x20\xed\x73\x66\x20\xf5\xde\x55\x64\xdf\x70\x8e\xf9\x69\xf2\xa7\x3a\xca\xfe\x1b\x00\x00\xff\xff\xa2\x6f\x57\x8d\x3e\x01\x00\x00")
import "text/template"
func filesSqlTmplBytes() ([]byte, error) {
return bindataRead(
_filesSqlTmpl,
"files/sql.tmpl",
)
// list of embedded template files.
var files = []struct {
name string
data string
}{
{
name: "ddl.tmpl",
data: string(ddl),
}, {
name: "sql.tmpl",
data: string(sql),
}, {
name: "tmpl.tmpl",
data: string(tmpl),
},
}
func filesSqlTmpl() (*asset, error) {
bytes, err := filesSqlTmplBytes()
if err != nil {
return nil, err
}
info := bindataFileInfo{name: "files/sql.tmpl", size: 318, mode: os.FileMode(420), modTime: time.Unix(1490544026, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
// T exposes the embedded templates.
var T *template.Template
// Asset loads and returns the asset for the given name.
// It returns an error if the asset could not be found or
// could not be loaded.
func Asset(name string) ([]byte, error) {
cannonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[cannonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("Asset %s can't read by error: %v", name, err)
}
return a.bytes, nil
func init() {
T = template.New("_").Funcs(FuncMap)
for _, file := range files {
T = template.Must(
T.New(file.name).Parse(file.data),
)
}
return nil, fmt.Errorf("Asset %s not found", name)
}
// MustAsset is like Asset but panics when Asset would return an error.
// It simplifies safe initialization of global variables.
func MustAsset(name string) []byte {
a, err := Asset(name)
if err != nil {
panic("asset: Asset(" + name + "): " + err.Error())
}
return a
}
//
// embedded template files.
//
// AssetInfo loads and returns the asset info for the given name.
// It returns an error if the asset could not be found or
// could not be loaded.
func AssetInfo(name string) (os.FileInfo, error) {
cannonicalName := strings.Replace(name, "\\", "/", -1)
if f, ok := _bindata[cannonicalName]; ok {
a, err := f()
if err != nil {
return nil, fmt.Errorf("AssetInfo %s can't read by error: %v", name, err)
}
return a.info, nil
}
return nil, fmt.Errorf("AssetInfo %s not found", name)
}
// AssetNames returns the names of the assets.
func AssetNames() []string {
names := make([]string, 0, len(_bindata))
for name := range _bindata {
names = append(names, name)
}
return names
}
// files/ddl.tmpl
// _bindata is a table, holding each asset generator, mapped to its name.
var _bindata = map[string]func() (*asset, error){
"files/ddl.tmpl": filesDdlTmpl,
"files/sql.tmpl": filesSqlTmpl,
var ddl = []byte{
0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x20, 0x7b, 0x7b, 0x20, 0x2e,
0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x20, 0x7d, 0x7d, 0x0a, 0x0a,
0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x20, 0x28, 0x0a, 0x09, 0x22, 0x64,
0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65, 0x2f, 0x73, 0x71, 0x6c, 0x22,
0x0a, 0x09, 0x7b, 0x7b, 0x2d, 0x20, 0x69, 0x66, 0x20, 0x2e, 0x4c, 0x6f,
0x67, 0x67, 0x65, 0x72, 0x2e, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64,
0x20, 0x7d, 0x7d, 0x0a, 0x09, 0x22, 0x6c, 0x6f, 0x67, 0x22, 0x0a, 0x09,
0x7b, 0x7b, 0x2d, 0x20, 0x65, 0x6e, 0x64, 0x20, 0x7d, 0x7d, 0x0a, 0x29,
0x0a, 0x0a, 0x76, 0x61, 0x72, 0x20, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x73, 0x20, 0x3d, 0x20, 0x5b, 0x5d, 0x73, 0x74, 0x72,
0x75, 0x63, 0x74, 0x20, 0x7b, 0x0a, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x20,
0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x0a, 0x09, 0x73, 0x74, 0x6d, 0x74,
0x20, 0x5b, 0x5d, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x0a, 0x7d, 0x7b,
0x0a, 0x09, 0x7b, 0x7b, 0x2d, 0x20, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x20,
0x2e, 0x4d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20,
0x7d, 0x7d, 0x0a, 0x09, 0x7b, 0x0a, 0x09, 0x09, 0x6e, 0x61, 0x6d, 0x65,
0x3a, 0x20, 0x7b, 0x7b, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x66, 0x20,
0x22, 0x25, 0x71, 0x22, 0x20, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x20, 0x7d,
0x7d, 0x2c, 0x0a, 0x09, 0x09, 0x73, 0x74, 0x6d, 0x74, 0x3a, 0x20, 0x5b,
0x5d, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x7b, 0x0a, 0x09, 0x09, 0x09,
0x7b, 0x7b, 0x2d, 0x20, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x20, 0x2e, 0x53,
0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x7d, 0x7d,
0x0a, 0x09, 0x09, 0x09, 0x7b, 0x7b, 0x20, 0x63, 0x61, 0x6d, 0x65, 0x6c,
0x69, 0x7a, 0x65, 0x20, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x20, 0x7d, 0x7d,
0x2c, 0x0a, 0x09, 0x09, 0x09, 0x7b, 0x7b, 0x2d, 0x20, 0x65, 0x6e, 0x64,
0x20, 0x7d, 0x7d, 0x0a, 0x09, 0x09, 0x7d, 0x2c, 0x0a, 0x09, 0x7d, 0x2c,
0x0a, 0x09, 0x7b, 0x7b, 0x2d, 0x20, 0x65, 0x6e, 0x64, 0x20, 0x7d, 0x7d,
0x0a, 0x7d, 0x0a, 0x0a, 0x2f, 0x2f, 0x20, 0x4d, 0x69, 0x67, 0x72, 0x61,
0x74, 0x65, 0x20, 0x70, 0x65, 0x72, 0x66, 0x6f, 0x72, 0x6d, 0x73, 0x20,
0x74, 0x68, 0x65, 0x20, 0x64, 0x61, 0x74, 0x61, 0x62, 0x61, 0x73, 0x65,
0x20, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x20,
0x49, 0x66, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6d, 0x69, 0x67, 0x72, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x20, 0x66, 0x61, 0x69, 0x6c, 0x73, 0x0a, 0x2f,
0x2f, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x20,
0x69, 0x73, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x2e,
0x0a, 0x66, 0x75, 0x6e, 0x63, 0x20, 0x4d, 0x69, 0x67, 0x72, 0x61, 0x74,
0x65, 0x28, 0x64, 0x62, 0x20, 0x2a, 0x73, 0x71, 0x6c, 0x2e, 0x44, 0x42,
0x29, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x20, 0x7b, 0x0a, 0x09, 0x69,
0x66, 0x20, 0x65, 0x72, 0x72, 0x20, 0x3a, 0x3d, 0x20, 0x63, 0x72, 0x65,
0x61, 0x74, 0x65, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x28, 0x64, 0x62, 0x29,
0x3b, 0x20, 0x65, 0x72, 0x72, 0x20, 0x21, 0x3d, 0x20, 0x6e, 0x69, 0x6c,
0x20, 0x7b, 0x0a, 0x09, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
0x65, 0x72, 0x72, 0x0a, 0x09, 0x7d, 0x0a, 0x09, 0x63, 0x6f, 0x6d, 0x70,
0x6c, 0x65, 0x74, 0x65, 0x64, 0x2c, 0x20, 0x65, 0x72, 0x72, 0x20, 0x3a,
0x3d, 0x20, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x43, 0x6f, 0x6d, 0x70,
0x6c, 0x65, 0x74, 0x65, 0x64, 0x28, 0x64, 0x62, 0x29, 0x0a, 0x09, 0x69,
0x66, 0x20, 0x65, 0x72, 0x72, 0x20, 0x21, 0x3d, 0x20, 0x6e, 0x69, 0x6c,
0x20, 0x26, 0x26, 0x20, 0x65, 0x72, 0x72, 0x20, 0x21, 0x3d, 0x20, 0x73,
0x71, 0x6c, 0x2e, 0x45, 0x72, 0x72, 0x4e, 0x6f, 0x52, 0x6f, 0x77, 0x73,
0x20, 0x7b, 0x0a, 0x09, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
0x65, 0x72, 0x72, 0x0a, 0x09, 0x7d, 0x0a, 0x09, 0x66, 0x6f, 0x72, 0x20,
0x5f, 0x2c, 0x20, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x20, 0x3a, 0x3d, 0x20, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x20, 0x6d, 0x69,
0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x7b, 0x0a, 0x09,
0x09, 0x5f, 0x2c, 0x20, 0x6f, 0x6b, 0x20, 0x3a, 0x3d, 0x20, 0x63, 0x6f,
0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x5b, 0x6d, 0x69, 0x67, 0x72,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x5d, 0x0a,
0x09, 0x09, 0x69, 0x66, 0x20, 0x6f, 0x6b, 0x20, 0x7b, 0x0a, 0x09, 0x09,
0x09, 0x7b, 0x7b, 0x2d, 0x20, 0x69, 0x66, 0x20, 0x2e, 0x4c, 0x6f, 0x67,
0x67, 0x65, 0x72, 0x2e, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64, 0x20,
0x7d, 0x7d, 0x0a, 0x09, 0x09, 0x09, 0x64, 0x65, 0x62, 0x75, 0x67, 0x28,
0x22, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x73,
0x6b, 0x69, 0x70, 0x70, 0x65, 0x64, 0x3a, 0x20, 0x25, 0x73, 0x22, 0x2c,
0x20, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x6e,
0x61, 0x6d, 0x65, 0x29, 0x0a, 0x09, 0x09, 0x09, 0x7b, 0x7b, 0x2d, 0x20,
0x65, 0x6e, 0x64, 0x20, 0x7d, 0x7d, 0x0a, 0x09, 0x09, 0x09, 0x63, 0x6f,
0x6e, 0x74, 0x69, 0x6e, 0x75, 0x65, 0x0a, 0x09, 0x09, 0x7d, 0x0a, 0x09,
0x09, 0x66, 0x6f, 0x72, 0x20, 0x5f, 0x2c, 0x20, 0x73, 0x74, 0x6d, 0x74,
0x20, 0x3a, 0x3d, 0x20, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x20, 0x6d, 0x69,
0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x73, 0x74, 0x6d, 0x74,
0x20, 0x7b, 0x0a, 0x09, 0x09, 0x09, 0x7b, 0x7b, 0x2d, 0x20, 0x69, 0x66,
0x20, 0x2e, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x45, 0x6e, 0x61,
0x62, 0x6c, 0x65, 0x64, 0x20, 0x7d, 0x7d, 0x0a, 0x09, 0x09, 0x09, 0x69,
0x6e, 0x66, 0x6f, 0x28, 0x22, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x20, 0x73, 0x74, 0x61, 0x72, 0x74, 0x65, 0x64, 0x3a, 0x20,
0x25, 0x73, 0x22, 0x2c, 0x20, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x0a, 0x0a, 0x09, 0x09,
0x09, 0x7b, 0x7b, 0x20, 0x65, 0x6e, 0x64, 0x20, 0x2d, 0x7d, 0x7d, 0x0a,
0x09, 0x09, 0x09, 0x69, 0x66, 0x20, 0x5f, 0x2c, 0x20, 0x65, 0x72, 0x72,
0x20, 0x3a, 0x3d, 0x20, 0x64, 0x62, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x28,
0x73, 0x74, 0x6d, 0x74, 0x29, 0x3b, 0x20, 0x65, 0x72, 0x72, 0x20, 0x21,
0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x20, 0x7b, 0x0a, 0x09, 0x09, 0x09, 0x09,
0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x65, 0x72, 0x72, 0x0a, 0x09,
0x09, 0x09, 0x7d, 0x0a, 0x09, 0x09, 0x09, 0x69, 0x66, 0x20, 0x65, 0x72,
0x72, 0x20, 0x3a, 0x3d, 0x20, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x4d,
0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x28, 0x64, 0x62, 0x2c,
0x20, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x6e,
0x61, 0x6d, 0x65, 0x29, 0x3b, 0x20, 0x65, 0x72, 0x72, 0x20, 0x21, 0x3d,
0x20, 0x6e, 0x69, 0x6c, 0x20, 0x7b, 0x0a, 0x09, 0x09, 0x09, 0x09, 0x72,
0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x65, 0x72, 0x72, 0x0a, 0x09, 0x09,
0x09, 0x7d, 0x0a, 0x0a, 0x09, 0x09, 0x09, 0x7b, 0x7b, 0x2d, 0x20, 0x69,
0x66, 0x20, 0x2e, 0x4c, 0x6f, 0x67, 0x67, 0x65, 0x72, 0x2e, 0x45, 0x6e,
0x61, 0x62, 0x6c, 0x65, 0x64, 0x20, 0x7d, 0x7d, 0x0a, 0x09, 0x09, 0x09,
0x69, 0x6e, 0x66, 0x6f, 0x28, 0x22, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x20, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x65, 0x64,
0x3a, 0x20, 0x25, 0x73, 0x22, 0x2c, 0x20, 0x6d, 0x69, 0x67, 0x72, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x0a, 0x09,
0x09, 0x09, 0x7b, 0x7b, 0x2d, 0x20, 0x65, 0x6e, 0x64, 0x20, 0x7d, 0x7d,
0x0a, 0x09, 0x09, 0x7d, 0x0a, 0x09, 0x7d, 0x0a, 0x09, 0x72, 0x65, 0x74,
0x75, 0x72, 0x6e, 0x20, 0x6e, 0x69, 0x6c, 0x0a, 0x7d, 0x0a, 0x0a, 0x66,
0x75, 0x6e, 0x63, 0x20, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x61,
0x62, 0x6c, 0x65, 0x28, 0x64, 0x62, 0x20, 0x2a, 0x73, 0x71, 0x6c, 0x2e,
0x44, 0x42, 0x29, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x20, 0x7b, 0x0a,
0x09, 0x5f, 0x2c, 0x20, 0x65, 0x72, 0x72, 0x20, 0x3a, 0x3d, 0x20, 0x64,
0x62, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x28, 0x6d, 0x69, 0x67, 0x72, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x43, 0x72, 0x65,
0x61, 0x74, 0x65, 0x29, 0x0a, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e,
0x20, 0x65, 0x72, 0x72, 0x0a, 0x7d, 0x0a, 0x0a, 0x66, 0x75, 0x6e, 0x63,
0x20, 0x69, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x4d, 0x69, 0x67, 0x72, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x28, 0x64, 0x62, 0x20, 0x2a, 0x73, 0x71, 0x6c,
0x2e, 0x44, 0x42, 0x2c, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x73, 0x74,
0x72, 0x69, 0x6e, 0x67, 0x29, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x20,
0x7b, 0x0a, 0x09, 0x5f, 0x2c, 0x20, 0x65, 0x72, 0x72, 0x20, 0x3a, 0x3d,
0x20, 0x64, 0x62, 0x2e, 0x45, 0x78, 0x65, 0x63, 0x28, 0x6d, 0x69, 0x67,
0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74,
0x2c, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x0a, 0x09, 0x72, 0x65, 0x74,
0x75, 0x72, 0x6e, 0x20, 0x65, 0x72, 0x72, 0x0a, 0x7d, 0x0a, 0x0a, 0x66,
0x75, 0x6e, 0x63, 0x20, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x43, 0x6f,
0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x64, 0x28, 0x64, 0x62, 0x20, 0x2a,
0x73, 0x71, 0x6c, 0x2e, 0x44, 0x42, 0x29, 0x20, 0x28, 0x6d, 0x61, 0x70,
0x5b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5d, 0x73, 0x74, 0x72, 0x75,
0x63, 0x74, 0x7b, 0x7d, 0x2c, 0x20, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x29,
0x20, 0x7b, 0x0a, 0x09, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f,
0x6e, 0x73, 0x20, 0x3a, 0x3d, 0x20, 0x6d, 0x61, 0x70, 0x5b, 0x73, 0x74,
0x72, 0x69, 0x6e, 0x67, 0x5d, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x7b,
0x7d, 0x7b, 0x7d, 0x0a, 0x09, 0x72, 0x6f, 0x77, 0x73, 0x2c, 0x20, 0x65,
0x72, 0x72, 0x20, 0x3a, 0x3d, 0x20, 0x64, 0x62, 0x2e, 0x51, 0x75, 0x65,
0x72, 0x79, 0x28, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x29, 0x0a, 0x09, 0x69, 0x66, 0x20,
0x65, 0x72, 0x72, 0x20, 0x21, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x20, 0x7b,
0x0a, 0x09, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6e, 0x69,
0x6c, 0x2c, 0x20, 0x65, 0x72, 0x72, 0x0a, 0x09, 0x7d, 0x0a, 0x09, 0x64,
0x65, 0x66, 0x65, 0x72, 0x20, 0x72, 0x6f, 0x77, 0x73, 0x2e, 0x43, 0x6c,
0x6f, 0x73, 0x65, 0x28, 0x29, 0x0a, 0x09, 0x66, 0x6f, 0x72, 0x20, 0x72,
0x6f, 0x77, 0x73, 0x2e, 0x4e, 0x65, 0x78, 0x74, 0x28, 0x29, 0x20, 0x7b,
0x0a, 0x09, 0x09, 0x76, 0x61, 0x72, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x20,
0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x0a, 0x09, 0x09, 0x69, 0x66, 0x20,
0x65, 0x72, 0x72, 0x20, 0x3a, 0x3d, 0x20, 0x72, 0x6f, 0x77, 0x73, 0x2e,
0x53, 0x63, 0x61, 0x6e, 0x28, 0x26, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x3b,
0x20, 0x65, 0x72, 0x72, 0x20, 0x21, 0x3d, 0x20, 0x6e, 0x69, 0x6c, 0x20,
0x7b, 0x0a, 0x09, 0x09, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20,
0x6e, 0x69, 0x6c, 0x2c, 0x20, 0x65, 0x72, 0x72, 0x0a, 0x09, 0x09, 0x7d,
0x0a, 0x09, 0x09, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e,
0x73, 0x5b, 0x6e, 0x61, 0x6d, 0x65, 0x5d, 0x20, 0x3d, 0x20, 0x73, 0x74,
0x72, 0x75, 0x63, 0x74, 0x7b, 0x7d, 0x7b, 0x7d, 0x0a, 0x09, 0x7d, 0x0a,
0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x6d, 0x69, 0x67, 0x72,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2c, 0x20, 0x6e, 0x69, 0x6c, 0x0a,
0x7d, 0x0a, 0x0a, 0x7b, 0x7b, 0x20, 0x69, 0x66, 0x20, 0x2e, 0x4c, 0x6f,
0x67, 0x67, 0x65, 0x72, 0x2e, 0x45, 0x6e, 0x61, 0x62, 0x6c, 0x65, 0x64,
0x20, 0x7d, 0x7d, 0x0a, 0x2f, 0x2f, 0x0a, 0x2f, 0x2f, 0x20, 0x6c, 0x6f,
0x67, 0x67, 0x69, 0x6e, 0x67, 0x20, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69,
0x6f, 0x6e, 0x73, 0x0a, 0x2f, 0x2f, 0x0a, 0x0a, 0x66, 0x75, 0x6e, 0x63,
0x20, 0x64, 0x65, 0x62, 0x75, 0x67, 0x28, 0x6d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2c, 0x20, 0x70,
0x61, 0x72, 0x61, 0x6d, 0x73, 0x20, 0x2e, 0x2e, 0x2e, 0x69, 0x6e, 0x74,
0x65, 0x72, 0x66, 0x61, 0x63, 0x65, 0x7b, 0x7d, 0x29, 0x20, 0x7b, 0x0a,
0x09, 0x6c, 0x6f, 0x67, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x66, 0x28,
0x22, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20,
0x64, 0x65, 0x62, 0x75, 0x67, 0x3a, 0x20, 0x22, 0x2b, 0x6d, 0x65, 0x73,
0x73, 0x61, 0x67, 0x65, 0x2c, 0x20, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73,
0x2e, 0x2e, 0x2e, 0x29, 0x0a, 0x7d, 0x0a, 0x0a, 0x66, 0x75, 0x6e, 0x63,
0x20, 0x69, 0x6e, 0x66, 0x6f, 0x28, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
0x65, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2c, 0x20, 0x70, 0x61,
0x72, 0x61, 0x6d, 0x73, 0x20, 0x2e, 0x2e, 0x2e, 0x69, 0x6e, 0x74, 0x65,
0x72, 0x66, 0x61, 0x63, 0x65, 0x7b, 0x7d, 0x29, 0x20, 0x7b, 0x0a, 0x09,
0x6c, 0x6f, 0x67, 0x2e, 0x50, 0x72, 0x69, 0x6e, 0x74, 0x66, 0x28, 0x22,
0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x69,
0x6e, 0x66, 0x6f, 0x3a, 0x20, 0x22, 0x2b, 0x6d, 0x65, 0x73, 0x73, 0x61,
0x67, 0x65, 0x2c, 0x20, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x2e,
0x2e, 0x29, 0x0a, 0x7d, 0x0a, 0x7b, 0x7b, 0x20, 0x65, 0x6e, 0x64, 0x20,
0x7d, 0x7d, 0x0a, 0x0a, 0x2f, 0x2f, 0x0a, 0x2f, 0x2f, 0x20, 0x6d, 0x69,
0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x74, 0x61, 0x62, 0x6c,
0x65, 0x20, 0x64, 0x64, 0x6c, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x73, 0x71,
0x6c, 0x0a, 0x2f, 0x2f, 0x0a, 0x0a, 0x76, 0x61, 0x72, 0x20, 0x6d, 0x69,
0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x54, 0x61, 0x62, 0x6c, 0x65,
0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x20, 0x3d, 0x20, 0x60, 0x0a, 0x43,
0x52, 0x45, 0x41, 0x54, 0x45, 0x20, 0x54, 0x41, 0x42, 0x4c, 0x45, 0x20,
0x49, 0x46, 0x20, 0x4e, 0x4f, 0x54, 0x20, 0x45, 0x58, 0x49, 0x53, 0x54,
0x53, 0x20, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73,
0x20, 0x28, 0x0a, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x56, 0x41, 0x52,
0x43, 0x48, 0x41, 0x52, 0x28, 0x35, 0x31, 0x32, 0x29, 0x0a, 0x2c, 0x55,
0x4e, 0x49, 0x51, 0x55, 0x45, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x0a,
0x29, 0x0a, 0x60, 0x0a, 0x0a, 0x76, 0x61, 0x72, 0x20, 0x6d, 0x69, 0x67,
0x72, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74,
0x20, 0x3d, 0x20, 0x60, 0x0a, 0x49, 0x4e, 0x53, 0x45, 0x52, 0x54, 0x20,
0x49, 0x4e, 0x54, 0x4f, 0x20, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74, 0x69,
0x6f, 0x6e, 0x73, 0x20, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x20, 0x56,
0x41, 0x4c, 0x55, 0x45, 0x53, 0x20, 0x28, 0x7b, 0x7b, 0x20, 0x69, 0x66,
0x20, 0x65, 0x71, 0x20, 0x2e, 0x44, 0x69, 0x61, 0x6c, 0x65, 0x63, 0x74,
0x20, 0x22, 0x70, 0x6f, 0x73, 0x74, 0x67, 0x72, 0x65, 0x73, 0x22, 0x20,
0x2d, 0x7d, 0x7d, 0x20, 0x24, 0x31, 0x20, 0x7b, 0x7b, 0x2d, 0x20, 0x65,
0x6c, 0x73, 0x65, 0x20, 0x2d, 0x7d, 0x7d, 0x20, 0x3f, 0x20, 0x7b, 0x7b,
0x2d, 0x20, 0x20, 0x65, 0x6e, 0x64, 0x20, 0x7d, 0x7d, 0x29, 0x0a, 0x60,
0x0a, 0x0a, 0x76, 0x61, 0x72, 0x20, 0x6d, 0x69, 0x67, 0x72, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x53, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x20, 0x3d, 0x20,
0x60, 0x0a, 0x53, 0x45, 0x4c, 0x45, 0x43, 0x54, 0x20, 0x6e, 0x61, 0x6d,
0x65, 0x20, 0x46, 0x52, 0x4f, 0x4d, 0x20, 0x6d, 0x69, 0x67, 0x72, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x0a, 0x60, 0x0a, 0x0a, 0x7b, 0x7b, 0x20,
0x72, 0x61, 0x6e, 0x67, 0x65, 0x20, 0x2e, 0x4d, 0x69, 0x67, 0x72, 0x61,
0x74, 0x69, 0x6f, 0x6e, 0x73, 0x20, 0x7d, 0x7d, 0x0a, 0x2f, 0x2f, 0x0a,
0x2f, 0x2f, 0x20, 0x7b, 0x7b, 0x20, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x20,
0x7d, 0x7d, 0x0a, 0x2f, 0x2f, 0x0a, 0x7b, 0x7b, 0x20, 0x72, 0x61, 0x6e,
0x67, 0x65, 0x20, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e,
0x74, 0x73, 0x20, 0x7d, 0x7d, 0x0a, 0x0a, 0x76, 0x61, 0x72, 0x20, 0x7b,
0x7b, 0x20, 0x63, 0x61, 0x6d, 0x65, 0x6c, 0x69, 0x7a, 0x65, 0x20, 0x2e,
0x4e, 0x61, 0x6d, 0x65, 0x20, 0x7d, 0x7d, 0x20, 0x3d, 0x20, 0x60, 0x0a,
0x7b, 0x7b, 0x20, 0x2e, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x20, 0x7d, 0x7d,
0x0a, 0x60, 0x0a, 0x7b, 0x7b, 0x20, 0x65, 0x6e, 0x64, 0x20, 0x7d, 0x7d,
0x0a, 0x7b, 0x7b, 0x20, 0x65, 0x6e, 0x64, 0x20, 0x7d, 0x7d, 0x0a,
}
// AssetDir returns the file names below a certain
// directory embedded in the file by go-bindata.
// For example if you run go-bindata on data/... and data contains the
// following hierarchy:
// data/
// foo.txt
// img/
// a.png
// b.png
// then AssetDir("data") would return []string{"foo.txt", "img"}
// AssetDir("data/img") would return []string{"a.png", "b.png"}
// AssetDir("foo.txt") and AssetDir("notexist") would return an error
// AssetDir("") will return []string{"data"}.
func AssetDir(name string) ([]string, error) {
node := _bintree
if len(name) != 0 {
cannonicalName := strings.Replace(name, "\\", "/", -1)
pathList := strings.Split(cannonicalName, "/")
for _, p := range pathList {
node = node.Children[p]
if node == nil {
return nil, fmt.Errorf("Asset %s not found", name)
}
}
}
if node.Func != nil {
return nil, fmt.Errorf("Asset %s not found", name)
}
rv := make([]string, 0, len(node.Children))
for childName := range node.Children {
rv = append(rv, childName)
}
return rv, nil
}
type bintree struct {
Func func() (*asset, error)
Children map[string]*bintree
}
var _bintree = &bintree{nil, map[string]*bintree{
"files": &bintree{nil, map[string]*bintree{
"ddl.tmpl": &bintree{filesDdlTmpl, map[string]*bintree{}},
"sql.tmpl": &bintree{filesSqlTmpl, map[string]*bintree{}},
}},
}}
// files/sql.tmpl
// RestoreAsset restores an asset under the given directory
func RestoreAsset(dir, name string) error {
data, err := Asset(name)
if err != nil {
return err
}
info, err := AssetInfo(name)
if err != nil {
return err
}
err = os.MkdirAll(_filePath(dir, filepath.Dir(name)), os.FileMode(0755))
if err != nil {
return err
}
err = ioutil.WriteFile(_filePath(dir, name), data, info.Mode())
if err != nil {
return err
}
err = os.Chtimes(_filePath(dir, name), info.ModTime(), info.ModTime())
if err != nil {
return err
}
return nil
var sql = []byte{
0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x20, 0x7b, 0x7b, 0x20, 0x2e,
0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x20, 0x7d, 0x7d, 0x0a, 0x0a,
0x2f, 0x2f, 0x20, 0x4c, 0x6f, 0x6f, 0x6b, 0x75, 0x70, 0x20, 0x72, 0x65,
0x74, 0x75, 0x72, 0x6e, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6e, 0x61,
0x6d, 0x65, 0x64, 0x20, 0x73, 0x74, 0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e,
0x74, 0x2e, 0x0a, 0x66, 0x75, 0x6e, 0x63, 0x20, 0x4c, 0x6f, 0x6f, 0x6b,
0x75, 0x70, 0x28, 0x6e, 0x61, 0x6d, 0x65, 0x20, 0x73, 0x74, 0x72, 0x69,
0x6e, 0x67, 0x29, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x7b,
0x0a, 0x09, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x69, 0x6e, 0x64,
0x65, 0x78, 0x5b, 0x6e, 0x61, 0x6d, 0x65, 0x5d, 0x0a, 0x7d, 0x0a, 0x0a,
0x76, 0x61, 0x72, 0x20, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x20, 0x3d, 0x20,
0x6d, 0x61, 0x70, 0x5b, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x5d, 0x73,
0x74, 0x72, 0x69, 0x6e, 0x67, 0x7b, 0x0a, 0x09, 0x7b, 0x7b, 0x20, 0x72,
0x61, 0x6e, 0x67, 0x65, 0x20, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x65, 0x6d,
0x65, 0x6e, 0x74, 0x73, 0x20, 0x2d, 0x7d, 0x7d, 0x0a, 0x09, 0x7b, 0x7b,
0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x66, 0x20, 0x22, 0x25, 0x71, 0x22,
0x20, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x20, 0x7d, 0x7d, 0x3a, 0x20, 0x7b,
0x7b, 0x20, 0x63, 0x61, 0x6d, 0x65, 0x6c, 0x69, 0x7a, 0x65, 0x20, 0x2e,
0x4e, 0x61, 0x6d, 0x65, 0x20, 0x7d, 0x7d, 0x2c, 0x0a, 0x09, 0x7b, 0x7b,
0x20, 0x65, 0x6e, 0x64, 0x20, 0x2d, 0x7d, 0x7d, 0x0a, 0x7d, 0x0a, 0x0a,
0x7b, 0x7b, 0x20, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x20, 0x2e, 0x53, 0x74,
0x61, 0x74, 0x65, 0x6d, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x7d, 0x7d, 0x0a,
0x76, 0x61, 0x72, 0x20, 0x7b, 0x7b, 0x20, 0x63, 0x61, 0x6d, 0x65, 0x6c,
0x69, 0x7a, 0x65, 0x20, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x20, 0x7d, 0x7d,
0x20, 0x3d, 0x20, 0x60, 0x0a, 0x7b, 0x7b, 0x20, 0x2e, 0x56, 0x61, 0x6c,
0x75, 0x65, 0x20, 0x7d, 0x7d, 0x0a, 0x60, 0x0a, 0x7b, 0x7b, 0x20, 0x65,
0x6e, 0x64, 0x20, 0x7d, 0x7d, 0x0a,
}
// RestoreAssets restores an asset under the given directory recursively
func RestoreAssets(dir, name string) error {
children, err := AssetDir(name)
// File
if err != nil {
return RestoreAsset(dir, name)
}
// Dir
for _, child := range children {
err = RestoreAssets(dir, filepath.Join(name, child))
if err != nil {
return err
}
}
return nil
}
// files/tmpl.tmpl
func _filePath(dir, name string) string {
cannonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
var tmpl = []byte{
0x70, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x20, 0x7b, 0x7b, 0x20, 0x2e,
0x50, 0x61, 0x63, 0x6b, 0x61, 0x67, 0x65, 0x20, 0x7d, 0x7d, 0x0a, 0x0a,
0x69, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x20, 0x22, 0x7b, 0x7b, 0x20, 0x2e,
0x46, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x20, 0x7d, 0x7d, 0x2f, 0x74, 0x65,
0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x22, 0x0a, 0x0a, 0x7b, 0x7b, 0x2d,
0x20, 0x24, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x20, 0x3a, 0x3d,
0x20, 0x2e, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x20, 0x7d, 0x7d, 0x0a,
0x0a, 0x2f, 0x2f, 0x20, 0x6c, 0x69, 0x73, 0x74, 0x20, 0x6f, 0x66, 0x20,
0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20, 0x74, 0x65, 0x6d,
0x70, 0x6c, 0x61, 0x74, 0x65, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e,
0x0a, 0x76, 0x61, 0x72, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x20, 0x3d,
0x20, 0x5b, 0x5d, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x7b, 0x0a, 0x09,
0x6e, 0x61, 0x6d, 0x65, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x0a,
0x09, 0x64, 0x61, 0x74, 0x61, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67,
0x0a, 0x7d, 0x20, 0x7b, 0x0a, 0x09, 0x7b, 0x7b, 0x20, 0x72, 0x61, 0x6e,
0x67, 0x65, 0x20, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x73, 0x20, 0x2d, 0x7d,
0x7d, 0x0a, 0x09, 0x7b, 0x0a, 0x09, 0x09, 0x6e, 0x61, 0x6d, 0x65, 0x3a,
0x20, 0x7b, 0x7b, 0x20, 0x70, 0x72, 0x69, 0x6e, 0x74, 0x66, 0x20, 0x22,
0x25, 0x71, 0x22, 0x20, 0x2e, 0x4e, 0x61, 0x6d, 0x65, 0x20, 0x7d, 0x7d,
0x2c, 0x0a, 0x09, 0x09, 0x7b, 0x7b, 0x20, 0x69, 0x66, 0x20, 0x24, 0x65,
0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64, 0x20, 0x2d, 0x7d, 0x7d, 0x0a, 0x09,
0x09, 0x64, 0x61, 0x74, 0x61, 0x3a, 0x20, 0x73, 0x74, 0x72, 0x69, 0x6e,
0x67, 0x28, 0x7b, 0x7b, 0x20, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x20, 0x7c,
0x20, 0x63, 0x61, 0x6d, 0x65, 0x6c, 0x69, 0x7a, 0x65, 0x20, 0x7d, 0x7d,
0x29, 0x2c, 0x0a, 0x09, 0x09, 0x7b, 0x7b, 0x2d, 0x20, 0x65, 0x6c, 0x73,
0x65, 0x20, 0x2d, 0x7d, 0x7d, 0x0a, 0x09, 0x09, 0x64, 0x61, 0x74, 0x61,
0x3a, 0x20, 0x7b, 0x7b, 0x20, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x20, 0x7c,
0x20, 0x63, 0x61, 0x6d, 0x65, 0x6c, 0x69, 0x7a, 0x65, 0x20, 0x7d, 0x7d,
0x2c, 0x0a, 0x09, 0x09, 0x7b, 0x7b, 0x2d, 0x20, 0x65, 0x6e, 0x64, 0x20,
0x7d, 0x7d, 0x0a, 0x09, 0x7d, 0x2c, 0x0a, 0x09, 0x7b, 0x7b, 0x2d, 0x20,
0x65, 0x6e, 0x64, 0x20, 0x7d, 0x7d, 0x0a, 0x7d, 0x0a, 0x0a, 0x2f, 0x2f,
0x20, 0x54, 0x20, 0x65, 0x78, 0x70, 0x6f, 0x73, 0x65, 0x73, 0x20, 0x74,
0x68, 0x65, 0x20, 0x65, 0x6d, 0x62, 0x65, 0x64, 0x64, 0x65, 0x64, 0x20,
0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x2e, 0x0a, 0x76,
0x61, 0x72, 0x20, 0x54, 0x20, 0x2a, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61,
0x74, 0x65, 0x2e, 0x54, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x0a,
0x0a, 0x66, 0x75, 0x6e, 0x63, 0x20, 0x69, 0x6e, 0x69, 0x74, 0x28, 0x29,
0x20, 0x7b, 0x0a, 0x09, 0x54, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x6d, 0x70,
0x6c, 0x61, 0x74, 0x65, 0x2e, 0x4e, 0x65, 0x77, 0x28, 0x22, 0x5f, 0x22,
0x29, 0x7b, 0x7b, 0x20, 0x69, 0x66, 0x20, 0x2e, 0x46, 0x75, 0x6e, 0x63,
0x73, 0x20, 0x7d, 0x7d, 0x2e, 0x46, 0x75, 0x6e, 0x63, 0x73, 0x28, 0x7b,
0x7b, 0x20, 0x2e, 0x46, 0x75, 0x6e, 0x63, 0x73, 0x20, 0x7d, 0x7d, 0x29,
0x7b, 0x7b, 0x20, 0x65, 0x6e, 0x64, 0x20, 0x7d, 0x7d, 0x0a, 0x09, 0x66,
0x6f, 0x72, 0x20, 0x5f, 0x2c, 0x20, 0x66, 0x69, 0x6c, 0x65, 0x20, 0x3a,
0x3d, 0x20, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x20, 0x66, 0x69, 0x6c, 0x65,
0x73, 0x20, 0x7b, 0x0a, 0x09, 0x09, 0x54, 0x20, 0x3d, 0x20, 0x74, 0x65,
0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x2e, 0x4d, 0x75, 0x73, 0x74, 0x28,
0x0a, 0x09, 0x09, 0x09, 0x54, 0x2e, 0x4e, 0x65, 0x77, 0x28, 0x66, 0x69,
0x6c, 0x65, 0x2e, 0x6e, 0x61, 0x6d, 0x65, 0x29, 0x2e, 0x50, 0x61, 0x72,
0x73, 0x65, 0x28, 0x66, 0x69, 0x6c, 0x65, 0x2e, 0x64, 0x61, 0x74, 0x61,
0x29, 0x2c, 0x0a, 0x09, 0x09, 0x29, 0x0a, 0x09, 0x7d, 0x0a, 0x7d, 0x0a,
0x0a, 0x2f, 0x2f, 0x0a, 0x2f, 0x2f, 0x20, 0x65, 0x6d, 0x62, 0x65, 0x64,
0x64, 0x65, 0x64, 0x20, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65,
0x20, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x2e, 0x0a, 0x2f, 0x2f, 0x0a, 0x0a,
0x7b, 0x7b, 0x20, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x20, 0x2e, 0x46, 0x69,
0x6c, 0x65, 0x73, 0x20, 0x7d, 0x7d, 0x0a, 0x2f, 0x2f, 0x20, 0x7b, 0x7b,
0x20, 0x2e, 0x50, 0x61, 0x74, 0x68, 0x20, 0x7d, 0x7d, 0x0a, 0x7b, 0x7b,
0x20, 0x69, 0x66, 0x20, 0x24, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x64,
0x20, 0x7d, 0x7d, 0x0a, 0x76, 0x61, 0x72, 0x20, 0x7b, 0x7b, 0x20, 0x2e,
0x42, 0x61, 0x73, 0x65, 0x20, 0x7c, 0x20, 0x63, 0x61, 0x6d, 0x65, 0x6c,
0x69, 0x7a, 0x65, 0x20, 0x7d, 0x7d, 0x20, 0x3d, 0x20, 0x5b, 0x5d, 0x62,
0x79, 0x74, 0x65, 0x7b, 0x0a, 0x7b, 0x7b, 0x20, 0x2e, 0x44, 0x61, 0x74,
0x61, 0x20, 0x7c, 0x20, 0x68, 0x65, 0x78, 0x64, 0x75, 0x6d, 0x70, 0x20,
0x7d, 0x7d, 0x0a, 0x7d, 0x0a, 0x7b, 0x7b, 0x20, 0x65, 0x6c, 0x73, 0x65,
0x20, 0x7d, 0x7d, 0x0a, 0x76, 0x61, 0x72, 0x20, 0x7b, 0x7b, 0x20, 0x2e,
0x42, 0x61, 0x73, 0x65, 0x20, 0x7c, 0x20, 0x63, 0x61, 0x6d, 0x65, 0x6c,
0x69, 0x7a, 0x65, 0x20, 0x7d, 0x7d, 0x20, 0x3d, 0x20, 0x60, 0x7b, 0x7b,
0x20, 0x2e, 0x44, 0x61, 0x74, 0x61, 0x20, 0x7d, 0x7d, 0x60, 0x0a, 0x7b,
0x7b, 0x20, 0x65, 0x6e, 0x64, 0x20, 0x7d, 0x7d, 0x0a, 0x7b, 0x7b, 0x20,
0x65, 0x6e, 0x64, 0x20, 0x7d, 0x7d, 0x0a,
}

Loading…
Cancel
Save