From 41e2d0c9b589864f92fa7525bf16aceb29c33f63 Mon Sep 17 00:00:00 2001 From: Ariel Mashraki Date: Sat, 21 Aug 2021 16:34:15 +0300 Subject: [PATCH] entc/load: replace bindata with package embed --- entc/load/internal/bindata.go | 269 ---------------------------------- entc/load/load.go | 57 +++---- 2 files changed, 29 insertions(+), 297 deletions(-) delete mode 100644 entc/load/internal/bindata.go diff --git a/entc/load/internal/bindata.go b/entc/load/internal/bindata.go deleted file mode 100644 index b732acf82..000000000 --- a/entc/load/internal/bindata.go +++ /dev/null @@ -1,269 +0,0 @@ -// Package internal Code generated by go-bindata. (@generated) DO NOT EDIT. -// sources: -// template/main.tmpl -// schema.go -package internal - -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 -} - -// Name return file name -func (fi bindataFileInfo) Name() string { - return fi.name -} - -// Size return file size -func (fi bindataFileInfo) Size() int64 { - return fi.size -} - -// Mode return file mode -func (fi bindataFileInfo) Mode() os.FileMode { - return fi.mode -} - -// ModTime return file modify time -func (fi bindataFileInfo) ModTime() time.Time { - return fi.modTime -} - -// IsDir return file whether a directory -func (fi bindataFileInfo) IsDir() bool { - return fi.mode&os.ModeDir != 0 -} - -// Sys return file is sys mode -func (fi bindataFileInfo) Sys() interface{} { - return nil -} - -var _templateMainTmpl = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\x54\x91\x51\x6f\xd3\x30\x14\x85\x9f\xe3\x5f\x71\x88\x40\x4b\x46\xe7\x6e\x7b\x03\xa9\x0f\xd3\x56\xa4\x22\xd8\x90\x3a\x89\x87\x51\x21\xd7\xb9\x69\xad\xa5\x76\xb8\x76\x27\x2a\x2b\xff\x1d\xd9\x69\x07\xbc\x25\x3e\xc7\xe7\x3b\xd7\x37\xc6\xe9\xb9\xb8\x75\xfd\x81\xcd\x66\x1b\x70\x7d\x79\xf5\xe1\xa2\x67\xf2\x64\x03\x3e\x29\x4d\x6b\xe7\x9e\xb1\xb0\x5a\xe2\xa6\xeb\x90\x4d\x1e\x49\xe7\x17\x6a\xa4\x78\xdc\x1a\x0f\xef\xf6\xac\x09\xda\x35\x04\xe3\xd1\x19\x4d\xd6\x53\x83\xbd\x6d\x88\x11\xb6\x84\x9b\x5e\xe9\x2d\xe1\x5a\x5e\x9e\x54\xb4\x6e\x6f\x1b\x61\x6c\xd6\xbf\x2c\x6e\xe7\xf7\xcb\x39\x5a\xd3\x11\x8e\x67\xec\x5c\x40\x63\x98\x74\x70\x7c\x80\x6b\x11\xfe\x81\x05\x26\x92\xe2\x7c\x3a\x0c\x42\xc4\x88\x86\x5a\x63\x09\xe5\x4e\x19\x5b\x62\x18\xc4\x74\x8a\xdb\xd4\x67\x43\x96\x58\x05\x6a\xb0\x3e\xe0\x8c\x6c\xd0\xaf\x47\x67\x12\x77\x0f\xb8\x7f\x78\xc4\xfc\x6e\xf1\x28\x45\xaf\xf4\xb3\xda\x10\x52\x86\x10\x66\xd7\x3b\x0e\xa8\x44\x51\x3a\x5f\x8a\xa2\x5c\x1f\x02\xa5\x8f\x18\x11\x68\xd7\x77\x2a\x10\xca\xd1\xe5\x33\x52\x14\x64\x83\xd7\x5b\xda\x29\xc4\x88\x9e\x8d\x0d\x2d\xca\x77\xbf\x4a\xc8\x6f\xc7\xec\x61\x10\xb5\x10\x2f\x8a\x31\x1a\x3d\x66\x78\x5a\x91\x0d\x72\x61\x03\x71\xab\x34\xc5\x84\xb8\x00\x2b\xbb\x21\xbc\xb5\x6a\x47\xf8\x38\x83\xbc\x57\x3b\xf2\xe9\x7e\xf1\x17\x23\x4f\x98\xa3\xaf\x8c\x43\x6a\x32\x19\x13\xc8\x36\xc9\x3f\x08\xd1\xee\xad\xce\x63\x55\x35\xa2\x28\x12\xbe\x33\x96\x3c\x9e\x56\x4f\xab\x34\x97\x28\x5a\xc7\xf8\x39\x39\xb6\x4a\xc0\x91\x7f\x6a\x19\x45\x51\xac\x27\x20\xe6\xa4\x7d\x55\xec\xb7\xaa\x5b\x66\xb1\x1a\x3d\xb5\x28\x0a\xd3\x66\xc7\x9b\x19\xac\xe9\xf2\x9d\xa2\x55\xa6\xab\x88\x39\xc9\xa9\xfb\xc8\x9d\x41\xf5\x3d\xd9\xa6\xca\xbf\x13\xac\x6b\x91\x54\xe7\xe5\x32\x34\x6e\x1f\xe4\x77\x36\x81\xaa\xfc\xe4\xf2\xb3\x33\xf6\x64\x1c\xeb\x56\xe5\x0f\x5b\xd6\x75\xfd\x3a\xdb\x89\x92\xf0\x8e\xf3\x90\x63\x16\x31\x8f\x59\xcb\xc0\xc6\x6e\x92\x47\xce\x93\xa7\xaa\xdf\xe7\x90\x6c\x9c\xff\x36\xa1\xba\xca\x71\xff\x6d\x77\x9c\x6c\x5c\x6e\x8c\xa7\x07\xfd\x13\x00\x00\xff\xff\xfa\x69\x6b\x50\x33\x03\x00\x00") - -func templateMainTmplBytes() ([]byte, error) { - return bindataRead( - _templateMainTmpl, - "template/main.tmpl", - ) -} - -func templateMainTmpl() (*asset, error) { - bytes, err := templateMainTmplBytes() - if err != nil { - return nil, err - } - - info := bindataFileInfo{name: "template/main.tmpl", size: 819, mode: os.FileMode(420), modTime: time.Unix(1, 0)} - a := &asset{bytes: bytes, info: info} - return a, nil -} - -var _schemaGo = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xb4\x5a\xdd\x8f\xdb\x36\x12\x7f\xb6\xff\x8a\xe9\x02\x0d\xe4\xc0\xd5\xf6\x8a\xa2\xb8\x73\xce\x07\x14\x69\x82\xee\xf5\xb2\x0d\x9a\xa4\x2f\x41\x90\x72\xa5\x91\x97\x59\x89\x74\x29\x7a\x3f\xba\xcd\xff\x7e\x98\x21\x29\x51\xb2\x64\x3b\xfb\x91\x97\x58\x43\xce\x70\xe6\xc7\xf9\x22\xb9\xc7\xc7\xf0\x5c\xaf\x6f\x8c\x5c\x9d\x5b\xf8\xee\xdb\x7f\xfc\xeb\x9b\xb5\xc1\x1a\x95\x85\x97\x22\xc3\x33\xad\x2f\xe0\x44\x65\x29\xfc\x58\x96\xc0\x93\x6a\xa0\x71\x73\x89\x79\x3a\x3d\x3e\x86\xb7\xe7\xb2\x86\x5a\x6f\x4c\x86\x90\xe9\x1c\x41\xd6\x50\xca\x0c\x55\x8d\x39\x6c\x54\x8e\x06\xec\x39\xc2\x8f\x6b\x91\x9d\x23\x7c\x97\x7e\x1b\x46\xa1\xd0\x1b\x95\x93\x08\xa9\x78\xca\xff\x4e\x9e\xbf\x38\x7d\xf3\x02\x0a\x59\x62\xa0\x19\xad\x2d\xe4\xd2\x60\x66\xb5\xb9\x01\x5d\x80\x8d\xd6\xb3\x06\x31\x9d\x4e\xd7\x22\xbb\x10\x2b\x84\x52\x8b\x7c\x3a\x95\xd5\x5a\x1b\x0b\xc9\x74\x72\x84\x2a\xd3\xb9\x54\xab\xe3\x4f\xb5\x56\x47\xd3\xc9\x51\x51\x59\xfa\xcf\x60\x51\x62\x66\x8f\xa6\x3c\xc7\xae\x74\x2a\xf5\x31\x2a\x1e\x8b\xbf\x8f\xeb\xec\x1c\x2b\x31\x42\x3e\xc6\x7c\x85\x63\x63\x85\xc4\x32\x1f\x1b\x94\x2a\xc7\xeb\xa3\xe9\x6c\x4a\xd6\xbf\x61\x1a\x18\xf4\xb8\xd7\x20\x14\xa0\xb2\xa9\x1f\xb0\xe7\xc2\xc2\x95\xa8\xd9\x3c\xcc\xa1\x30\xba\x02\x01\x99\xae\xd6\xa5\x24\x8c\x6b\x34\xe0\x21\x48\xa7\xf6\x66\x8d\x41\x64\x6d\xcd\x26\xb3\x70\x3b\x9d\x9c\x8a\x0a\xc1\xff\xab\xad\x91\x6a\x05\xfd\x7f\x7f\x10\x46\x8b\x23\x25\x2a\x9c\xeb\x4a\x5a\xac\xd6\xf6\xe6\xe8\x8f\xe9\xe4\xb9\x56\x85\xf4\xf3\x49\xad\xf8\xbb\xcb\x9b\xf1\x48\x97\xfb\x45\xbe\xc2\xda\x4f\x7b\xff\xe1\x29\x7d\x8e\xac\x4c\x68\xd6\x5d\xe6\x97\x04\x62\xdd\x30\xf3\xe7\x30\x33\xc3\xdd\xe3\x3e\x21\x94\xfd\xe2\xef\x3f\x3c\xe5\xcf\x61\x6e\xe9\x66\x76\xd9\x7f\xd6\xfa\x22\xd2\xfc\xb5\xae\xa5\x95\x5a\x0d\xb0\x9f\xd3\xcc\x2e\xf3\x6b\x5d\xca\xec\xe6\x10\xe6\x35\xcf\xec\x72\xff\xa8\x94\xb6\x82\x18\x6a\xa8\xc4\xfa\xbd\xdb\xb2\x0f\x52\x59\x34\x85\xc8\xf0\xf6\x73\xe0\x16\xed\xcc\x8e\x88\xcf\xec\x5a\xcd\xb2\x39\xd6\x99\x91\x67\x58\x83\x80\x75\x20\xfa\x10\x73\x3e\xe9\x3d\xa7\xe1\x68\x7d\x27\xc2\x4d\x2a\x0b\x70\x7c\x0c\x8e\xe4\xf9\x19\xfa\x63\xc2\x00\x4a\x59\xdb\x74\x3a\x79\x25\xaf\x31\x3f\x61\x63\xcf\xb4\x2e\x3d\x87\xcc\x84\xc5\x1a\x64\x11\xad\x0a\xfa\xec\x13\x66\xce\xbd\x2b\xe2\xfa\x46\x2a\x27\x40\xaa\xb0\x88\x5b\x92\x49\x20\xe3\x85\x2b\x26\xb9\x35\x9d\xbd\xce\x41\xb6\x23\xc9\xd1\xef\x10\x48\x8e\x71\x38\x8e\x46\x23\x69\x3c\x94\x4e\x54\xa1\xdb\x69\x4f\x19\xb9\xf4\xed\xcd\x1a\x3b\x03\x9e\x9d\x14\xe8\xb2\xbf\x15\xf1\x62\x7b\x56\xb7\xa2\x17\x89\x6f\xe4\x5f\x91\xee\x4f\xa5\xb2\x3f\x7c\x3f\xca\x5d\xcb\xbf\x7a\x8b\xbf\x50\x9b\xaa\x6e\xa6\xbd\xff\xe0\x40\xb9\x85\xd3\x39\xfc\x1e\x74\x69\xdc\x12\x69\x72\x97\xff\x9d\x92\x7f\x6e\x1a\x05\xd8\x2f\x06\xfe\x79\xfe\x0d\x4f\xee\x0a\x38\x95\x65\x29\xce\x4a\x3c\x48\x80\xf2\x93\xbb\x22\x7e\x5d\x93\x6f\x8b\xf2\x20\x11\xda\x4f\xee\x8a\xf8\x09\x0b\xb1\x29\xed\x61\x66\xe4\x6e\xf2\xa0\x84\xdf\x45\x49\x70\xc4\x31\x3d\x2e\xe1\xe3\x25\xcd\x1e\x94\xf3\x8b\x54\x94\x13\x7d\x49\x4b\xfd\xe7\x98\x9c\x0b\xa9\xf2\xde\xbe\xac\x73\x61\x31\x98\xb5\x6f\x5f\x78\xf2\xc7\x41\xbb\x4e\xaa\x6a\x63\x9b\x0d\xda\x23\x48\x86\xc9\x5d\x19\xbf\x8b\x52\xe6\xc2\x6a\xc3\x9e\xc6\xb1\x3f\x2e\xe3\xb2\x99\xdc\x73\x74\xab\x8d\x58\xe1\x2f\xc8\xf9\x77\x4f\x98\xd4\x6e\xf2\xc7\x0b\xbc\xe9\x67\xf0\x38\x65\x0f\x66\xf0\x38\x89\xbb\xd1\x9e\x22\xa8\x88\x7c\x79\x10\x22\x75\x98\xdc\x93\xc1\x79\x92\x72\x04\xcd\x8d\x8a\x41\xc7\xae\x20\x83\x27\x7f\xdc\xce\x1c\x71\x41\x81\xb1\x92\xb2\xaf\xa6\x4c\x9e\xeb\xaa\xc2\x66\x4f\xf6\x00\x9b\xb9\xc9\x03\x55\x89\x7b\x80\xed\x24\xcd\xe4\x3b\xe4\x68\xe6\x7b\x98\x56\x27\xc0\xbc\x9f\x77\x77\x72\xde\xc3\xdb\xcf\xcc\x71\x5f\xb3\x9b\x95\x2b\x46\x97\xf9\x37\x2c\x1a\x93\x77\x33\x1b\x2c\x3e\x6e\xdb\xfc\x1b\x16\xcd\xc4\xc1\xf6\x2c\xe6\x1f\x4f\xe9\x23\xde\xbd\x23\x9f\x9f\xa8\x4b\x34\xf5\xce\xd8\x68\xda\x33\x9e\xd9\xd7\xfb\xcf\x8d\x34\x98\xef\x67\x37\x7e\xe6\x78\x96\x78\x4a\xbd\x67\xda\xcd\x1b\x07\xa4\x88\x87\x6a\xd3\x5c\xa7\xb3\x1d\x11\x8e\x7e\x87\x90\x70\x8c\x6d\x4c\xdc\x6f\xa3\xba\x2d\xfc\xa0\x8f\x1d\xda\xc2\xef\x62\x1e\x6a\xe1\xe3\x2d\xd9\xed\xdc\x8f\xbe\x49\xa7\x78\xc5\xd1\x91\x19\xe4\x3e\x56\xa8\xb0\x21\x64\xb5\xdb\x15\xfe\xe5\x7a\xed\xb5\xd5\x26\x9d\x16\x1b\x95\x05\xce\x04\x73\xef\x68\x3f\x35\x33\x66\x3e\xe4\x6e\xa7\x13\x85\xb0\x58\xc2\x13\xfa\xbc\x9d\x4e\x28\x9d\x2c\x1a\x1b\x31\x4f\xdf\x8a\xd5\x9c\xc8\x37\x6b\x5c\xc4\x64\xca\x43\xd3\x09\x67\xbd\x98\x4e\xdf\x44\x67\xf8\x17\x2d\x9d\xbf\x69\xc0\xb9\xc4\xa2\x19\x70\xdf\x34\xe2\xe3\x72\x11\x46\xfc\x37\x0d\x85\x98\x5b\xf8\xa1\xf0\xed\xc6\x8a\x56\x09\x1e\x2b\x82\x12\xed\x2e\x2e\x78\xa8\xfd\xa6\xd1\x68\x83\x16\x50\x89\x0b\x4c\x86\xb7\x69\x36\x9f\x4e\x3e\x4f\x27\x85\x36\xf0\x71\x0e\xc2\x12\x5c\x46\xa8\x15\x92\xc8\x78\x97\x09\x3e\x85\xa9\xc8\xf3\x96\x9a\x08\x3b\x63\x76\x59\x50\xab\x44\xbc\x4e\xc7\x67\xfc\xf9\xd5\x12\x94\x2c\x03\x27\xa5\xc4\x65\xb3\x6d\x06\x8b\x99\xa3\x47\xde\xb8\x04\x37\x2f\xa2\xb1\x78\x83\x76\x63\x14\x28\x6c\xbd\xc6\x65\xf7\xc6\x6d\x9a\x30\x66\x32\xbb\x8d\xfb\x39\xe4\x37\xcc\x9b\x14\x79\x38\x2b\xc4\x9e\x93\xb8\xf3\xf0\x1c\xd0\x18\xfa\xbe\x65\xe3\x8a\x3c\x7d\x61\x4c\x6c\x50\x50\x49\x96\x73\x28\x2a\x4b\xc3\xda\x14\x89\x8b\x37\xf8\xfa\xcf\x05\x7c\x7d\x79\x34\x27\x46\xde\x2f\x2f\xc1\xa1\x55\x33\x52\x4f\x78\xa1\xdb\xbe\x9b\x41\xc3\xc3\x5e\x53\xe8\xee\x08\x51\xe6\x7d\x4f\xe6\x11\xef\xcb\x7c\xa2\x58\xc4\x03\x4c\xd9\xf2\x4e\x1e\x6a\xfd\x33\x9c\x03\x16\xad\x0e\xa1\xd9\x9f\x4e\x9a\x16\xbf\x1d\x0d\x14\x1a\xf5\x6d\xee\xa2\x95\x1b\x1a\x5f\x07\x18\xaf\x1d\x37\xc4\x0b\x5e\xbb\xd3\x22\xb7\x33\x9b\x8e\x77\xd1\xd8\xdc\xb4\xb5\x7d\xb7\xe7\xe1\xae\xe3\xb7\xcd\x2e\x8f\x97\xa8\x92\x22\x4f\x5b\xea\x8c\x85\x84\xb6\xb0\x59\xa3\xa1\xf0\x70\xd3\x1e\x36\x6b\x34\x94\xad\xe0\x82\x7d\xe1\x15\x3a\xbc\x08\x1f\x4f\x19\x8d\xbd\x62\x3b\xf6\xea\x62\x3c\xf6\xea\x82\xfd\x02\x96\xfb\xfd\xb3\x92\x75\x4d\x09\x9f\x2b\x9a\x24\x26\x5a\x3e\x78\xed\xd1\x9c\x64\x91\xf7\xb5\xb2\xe9\x80\xbb\x58\x02\x9f\x6c\x09\x4a\x3a\xf1\xce\x9e\x39\xfa\x57\x4b\xf8\x36\x68\xc7\x27\xe1\x25\x3c\xa1\x81\x48\xb1\xb0\xc1\x7e\x56\x7c\xbe\x5a\x36\xe7\x2b\x02\xf6\xd7\x22\x69\x3d\x67\xc6\x47\xae\xc4\x69\x41\xc5\xdc\xdd\x6f\xf8\x23\x12\xf0\xc1\x0d\x32\xa1\xe0\x0c\x81\xef\x23\x31\x07\xab\x79\xce\x0a\x15\x1a\xc1\x01\x4f\x9c\x2f\xb5\x01\xbc\x16\xd5\xba\xc4\x39\x28\x6d\x41\x00\xe5\x01\x3e\x75\x94\xf2\x02\xc1\xca\x0a\xd3\x53\x7d\x95\xb2\xc6\x1f\x39\xf2\xc9\x60\x2a\x5f\xe9\x2b\x61\xea\x73\x51\xc6\x9a\x3d\xe3\x09\x11\xd4\xad\x55\xee\xf4\xb9\x8c\x22\x20\x4e\x5f\x75\x31\x27\x9e\x36\x87\xb9\x86\x62\xbb\xf4\xb9\xfb\x18\x4e\x62\xee\xe7\x50\x12\x63\xe6\x44\xe6\xd7\xf0\x94\x27\x75\xeb\x9f\x13\x4d\x05\x50\x72\xae\xe1\x6f\x52\x96\xdb\x8e\xe0\x89\x32\xbf\xe6\x03\x42\xdd\x14\xb5\x30\x44\x23\x8e\xb0\x95\x38\x68\xa8\xcd\x1b\x9d\x70\xa4\xa1\x87\x2e\x43\x24\x73\xab\x0e\xc9\x91\x58\x68\xbc\xde\x83\xec\xb7\xcf\xdf\xdc\x3a\x47\xa9\xd9\x4b\xa2\xab\xe0\x46\x0d\xfa\xa5\x41\xc0\x7f\xdf\xfc\x7a\x4a\xdc\xdc\x23\x7a\x27\xcb\xd1\x39\x19\x4f\x21\x01\x6f\xe2\xab\xb6\x9a\xc6\x4b\x41\x8d\xb3\x38\xd3\x97\xe8\xb7\xa9\xb3\x7c\x52\x07\x2d\xa8\x07\xf5\x4b\xce\x20\x39\x83\xf7\x1f\xce\x6e\x2c\x3a\xc7\x6b\xcb\x4e\xcd\x1b\xe7\x78\x6f\x39\x8b\xa8\x42\x86\xa4\xef\xaf\x17\x1d\x2d\x99\x6d\x35\x2b\x52\xb9\xeb\xfd\xa4\x17\x61\x8e\x6f\x36\xe3\x18\x77\x7c\x5f\xb8\x45\xb2\x08\x01\x52\xa7\xe4\xaf\x7c\x85\x18\xe4\xba\xd8\x38\xa0\x4c\x7a\x2c\xb8\x4e\x5e\x51\xd6\xf1\x65\x12\x43\x8d\x6c\xaf\xf0\xa3\x06\x12\xf4\x25\x1a\x23\x73\x6c\xae\x35\xe3\xd1\x74\xd0\x7f\x3c\x52\x91\x95\xc9\xcc\x85\xed\x78\x3e\xed\x18\xe8\xc2\xe0\xe1\x2d\x74\x6d\x7d\xb3\x96\x28\x90\x43\x31\x2c\xd4\x28\xf2\x10\x6b\x79\x5c\x30\xee\xee\xe8\xf8\xe1\x70\x70\x47\x91\x25\x88\xf5\x1a\x55\x9e\x78\xc2\xbc\x6d\xb1\xa3\xdc\x92\xcc\x66\x1e\x26\x7f\xbb\x1f\x1b\xe0\xdf\x06\x1e\xd3\x04\x4a\x78\x6d\x6e\xf0\x6f\x11\xce\x8c\xf0\x32\x11\x19\x72\x12\x94\x8c\x13\xe6\xa0\x35\xbd\x4d\xe7\x67\x8a\x87\xdf\xf3\xfe\x32\xee\x41\xe3\xe1\xd7\xf1\x8c\x9d\x12\x56\xcf\x7c\x52\x7c\xa7\xaa\x4e\x5a\x74\xa9\xcd\xa5\xc5\x95\xbc\x44\x05\x67\x9b\xa2\x40\x03\x9c\x0c\x7d\x4d\x0a\xef\x19\x9c\xd7\x7a\x12\x92\xb3\x4d\xe1\x93\x18\x35\xd0\x8e\x38\x1f\x4b\x65\x1d\x18\x58\xc3\x46\x1c\x09\x9a\x43\xbd\x1b\x08\x34\x26\x76\x88\x22\x0a\x75\x5f\xb2\x98\xa5\x5d\xa3\x48\x7d\xdb\x50\x27\xdb\x92\xb7\x45\x93\xec\xa8\x68\xc7\x35\xbb\xc9\x77\xfc\xab\xf6\x6f\x25\x56\x87\x77\x17\x77\x5c\x8d\xf3\xbb\x07\x2c\xa9\xc1\xc3\x32\x83\x7e\xd2\xec\x17\x04\x86\x8d\x74\x63\xe9\x9d\xf8\xea\xe4\xda\x1d\xd1\x15\x43\x24\xe7\x50\x45\x21\xe3\x54\xe6\x22\x2a\x2a\xdf\xd8\x0d\x97\x8a\xea\xba\x29\x13\xd3\xc9\xc4\xdf\x23\xc4\xda\xf8\xc4\x58\x5d\xcf\x5a\xb8\x07\x90\xed\x76\x9f\xb4\x7a\xe3\xb7\x2a\xf2\x5a\xd2\x97\x15\xfe\xd4\xd9\xd3\xa2\xdd\xd1\x09\x35\x50\x7e\xfd\xf6\x14\xd7\x8d\x66\x9a\x36\xa0\xca\x97\xea\xc2\xca\x50\x63\xd7\x5c\x50\x2f\xe1\x49\xf8\xed\x24\x72\x3a\xf1\xf5\xf6\xd3\x9c\x49\xfe\x85\x8e\x89\xd6\xb8\xfe\x68\x12\x3d\xbb\x2d\x40\xce\x5b\xe1\xc1\x59\xa3\x74\xe5\x3b\x2e\xa8\x8b\x00\xc8\x58\x91\x78\x68\xd0\xc7\x8a\xc3\x9d\xaa\x03\x4b\xdd\x55\x1f\x1e\x41\xfb\xd1\xba\x70\x9f\xc2\xc0\x0b\xb8\x77\xe8\xd8\x0c\x57\x1c\x1e\xdc\xef\x5b\xfd\x79\xc9\xa0\xbd\x7b\x31\x8f\x74\xff\xd9\x29\xf4\x80\xfe\x18\xd4\xf0\xaf\xe6\xb1\xad\xbe\x42\x3d\xa4\xb1\xb2\x00\xb7\x50\x47\x50\x9d\xfa\xd7\xfd\xc8\xd2\xd7\x5e\x9f\x9e\xa9\x5f\x6c\xd7\x40\x5b\x58\x5d\x0f\xb4\x84\xc3\x3d\x61\xb7\x20\x74\xab\x81\x8f\x61\x57\x0e\xdc\x29\xfa\x0e\xe5\xa0\xd3\x62\x8e\xd6\x83\xf1\x14\xfc\xc5\x15\x61\x38\xc1\x1e\x96\x5f\xc7\x9d\xa0\x29\x9f\xa3\x99\x33\x6c\x0f\xcf\xd9\x97\x00\xb7\x30\x1f\xc4\x2e\xee\xd4\x46\xa1\x1b\x8b\xe1\x2f\x04\x6e\x28\x42\x0f\x0d\xd0\x26\x3e\x9d\x6f\x36\x3e\x5c\x88\xd2\x5d\x03\x7f\x3e\xd8\xe4\x4e\xd7\x38\x6a\xf3\x78\x30\x1f\x6e\xf5\x60\xa8\x1e\x16\xa9\x87\x99\xd3\x0b\x37\xb5\x7d\x5c\xe3\xc8\xcc\x36\xc6\xcc\x41\x5f\xb8\xce\x39\x0a\xdc\xf7\x42\xf9\x1e\xe5\x03\x6b\xfb\x95\xbe\xf0\x3a\x0e\x4f\x22\x9d\x55\x63\x67\xb0\xb1\x0a\xb2\x69\x9d\xd4\xe3\x93\xbe\x42\xb3\x42\x33\x7b\x06\xfb\x65\x56\x6e\x72\x22\x14\x5b\xdd\x58\x8a\xee\x25\xe2\x60\x3b\xbb\xd3\x30\x5e\x70\x0e\x24\xbc\x91\x2c\xfd\x1d\xcf\x1d\x45\xcb\x1d\xa2\x0b\x70\x77\xe0\x77\x14\x5d\x8c\x8b\xee\xcb\xdb\xf7\x86\x44\xdc\x07\x78\x84\xd8\xef\x0f\xc3\x53\xee\xe3\x0d\xa3\x12\xc7\x7c\xa1\x85\xb5\x3d\x8e\xb4\xd1\x4a\xba\xb6\x97\xa5\x7f\xff\x4d\x5f\x27\xaa\xd0\xe9\xe9\xa6\x42\x23\xb3\x64\x46\xc4\xde\xfd\x69\x7b\x81\xfa\x92\x96\xe8\x9e\x94\xd8\x1c\x15\x6c\xe9\xde\x51\xa6\x49\x51\x6a\x61\x7f\xf8\x7e\xd6\x41\x69\xa0\x98\x6f\x14\x5e\xaf\x31\xb3\x98\xf7\x2e\x5f\xf9\x02\xb9\xb9\x3b\x5e\xb8\xcb\xe3\xf8\xee\xb8\xbe\x92\x36\x3b\x07\xeb\x56\x67\x5b\xe8\x64\xf1\x8c\x77\x4f\xd4\x08\x16\xfe\xb3\x84\xf8\xaf\xb5\xec\x3f\xe1\xc9\x13\xb0\xf0\xef\x1e\xf9\x87\xef\x17\x54\xc4\xfb\xb7\xac\xee\x46\x9a\x50\x1e\x12\xf7\x4e\x0e\xcb\x7b\x27\x47\x05\x6e\x5a\x89\x43\xf5\xbe\x2d\xb8\x70\x65\xc4\xba\x8e\xff\xce\xcf\xd3\x85\xca\xdd\x09\x2b\x10\x2a\xb4\xe7\x3a\x87\x2b\x69\xcf\xc1\x60\xa6\x2f\xdd\xb1\x1a\x55\xbd\x31\x08\x4a\xc3\x5a\x28\x99\xd5\x20\x15\xf8\x33\xb0\x54\x2b\xdf\x25\x44\x05\xbe\xc8\xa3\x3f\x69\x02\x4f\x9c\xc1\xfb\x0f\xed\xdf\xe1\x7d\x9e\x41\xe2\x6b\x79\x44\xee\x5f\x2a\xe6\x48\x07\x7b\x12\xef\x5b\x1e\x59\xc0\x25\x97\x35\xa7\x1c\x9d\x90\x2f\x3b\xb5\x9d\x2f\xbb\x3b\x2e\xf1\xf5\xdb\x60\x9d\x53\xbe\x79\xea\x9a\xc3\x25\x1f\x9e\x8a\x50\xd7\xd9\x0b\xb9\x7d\xa2\x33\x64\xf0\x2e\xff\x5e\x5a\x27\xb3\x79\x0f\x5d\x77\xd4\xd8\x02\xd7\x91\xef\x0b\x65\x7c\xbb\x16\xa3\xe9\xe8\x01\x4c\x7e\x38\x26\x2c\xdd\x19\xa8\x25\x3e\x06\x92\x1d\xfb\x3a\x60\x3a\x20\xd1\x1f\xbd\x06\x71\x8c\x99\xb7\xa1\x0c\x67\x9e\x2d\x30\xc3\xc0\x7d\xe1\xec\xde\xf5\xc5\x80\x86\x91\x00\xa9\x7b\x8b\x20\x4c\xc3\xb9\x2c\xa2\x3f\x22\xac\xc1\xd2\x01\x60\x65\x73\x22\xdc\x05\x6d\x63\x48\x1f\x5c\x77\x07\xb4\x05\xad\x23\xdf\x17\xd8\x5d\x77\x43\x89\x3b\x5b\x39\xfc\x5e\xb5\xf7\x43\x8f\x82\x9f\x33\x67\x00\x3d\xa7\xc4\x6e\xec\x9c\x15\x5b\xc8\xb9\x5e\x79\x0b\x39\x47\xbe\x2f\x72\x9d\xa3\x40\xe4\x90\x8e\x1e\xdc\x91\xbe\xd8\x1b\x5d\x0f\xdf\x12\x1f\x11\x4a\x67\xdf\x00\x94\xe7\xfe\xec\xb0\x0b\x4a\xaf\x7e\x1f\x4a\xdf\x84\x6f\x61\xe9\xe9\xf7\x05\xb3\x7b\xc8\x88\xd0\xf4\x03\x33\xf6\x4d\xbf\x18\xc1\xe9\x0f\x0a\x2d\xf5\x11\xf1\xf4\xcb\x0e\x00\xba\x0e\x47\x93\x5d\x88\x06\x13\xe6\x9d\x73\x49\x73\x11\x6a\x3b\xef\xd2\xb3\xce\x17\x1f\xc4\xb5\x01\xeb\x1f\xa8\xe3\x26\xec\xb5\xe5\x56\x6e\x62\x61\x09\x36\x7d\x51\x62\x95\x74\x5a\x09\x3b\xfd\x3c\xfd\x7f\x00\x00\x00\xff\xff\x8c\x1c\x20\xaa\x19\x34\x00\x00") - -func schemaGoBytes() ([]byte, error) { - return bindataRead( - _schemaGo, - "schema.go", - ) -} - -func schemaGo() (*asset, error) { - bytes, err := schemaGoBytes() - if err != nil { - return nil, err - } - - info := bindataFileInfo{name: "schema.go", size: 13337, mode: os.FileMode(420), modTime: time.Unix(1, 0)} - a := &asset{bytes: bytes, info: info} - return a, nil -} - -// 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 - } - 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 -} - -// 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 -} - -// _bindata is a table, holding each asset generator, mapped to its name. -var _bindata = map[string]func() (*asset, error){ - "template/main.tmpl": templateMainTmpl, - "schema.go": schemaGo, -} - -// 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{ - "schema.go": &bintree{schemaGo, map[string]*bintree{}}, - "template": &bintree{nil, map[string]*bintree{ - "main.tmpl": &bintree{templateMainTmpl, map[string]*bintree{}}, - }}, -}} - -// 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 -} - -// 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 -} - -func _filePath(dir, name string) string { - cannonicalName := strings.Replace(name, "\\", "/", -1) - return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...) -} diff --git a/entc/load/load.go b/entc/load/load.go index f957aff0b..f6908482a 100644 --- a/entc/load/load.go +++ b/entc/load/load.go @@ -7,6 +7,7 @@ package load import ( "bytes" + "embed" "fmt" "go/ast" "go/format" @@ -15,7 +16,6 @@ import ( "go/types" "os" "os/exec" - "path/filepath" "reflect" "sort" "strings" @@ -23,27 +23,27 @@ import ( "time" "entgo.io/ent" - "entgo.io/ent/entc/load/internal" - "golang.org/x/tools/go/packages" ) -// A SchemaSpec holds a serializable version of an ent.Schema -// and its Go package information. -type SchemaSpec struct { - // Schemas are the schema descriptors. - Schemas []*Schema - // PkgPath is the package path of the loaded ent.Schema. - PkgPath string -} +type ( + // A SchemaSpec holds a serializable version of an ent.Schema + // and its Go package information. + SchemaSpec struct { + // Schemas are the schema descriptors. + Schemas []*Schema + // PkgPath is the package path of the loaded ent.Schema. + PkgPath string + } -// Config holds the configuration for package building. -type Config struct { - // Path is the path for the schema package. - Path string - // Names are the schema names to load. Empty means all schemas in the directory. - Names []string -} + // Config holds the configuration for loading an ent/schema package. + Config struct { + // Path is the path for the schema package. + Path string + // Names are the schema names to load. Empty means all schemas in the directory. + Names []string + } +) // Load loads the schemas package and build the Go plugin with this info. func (c *Config) Load() (*SchemaSpec, error) { @@ -133,35 +133,36 @@ func (c *Config) load() (string, error) { return pkg.PkgPath, nil } -//go:generate go run github.com/go-bindata/go-bindata/go-bindata -pkg=internal -o=internal/bindata.go -mode=420 -modtime=1 ./template/... schema.go - -var buildTmpl = templates() +var ( + //go:embed template/main.tmpl schema.go + files embed.FS + buildTmpl = templates() +) func templates() *template.Template { - tmpl := template.New("templates").Funcs(template.FuncMap{"base": filepath.Base}) - tmpl = template.Must(tmpl.Parse(string(internal.MustAsset("template/main.tmpl")))) - // Turns the schema file and its imports into templates. tmpls, err := schemaTemplates() if err != nil { panic(err) } + tmpl := template.Must(template.New("templates"). + ParseFS(files, "template/main.tmpl")) for _, t := range tmpls { tmpl = template.Must(tmpl.Parse(t)) } return tmpl } -// schemaTemplates returns the templates needed for loading the schema.go file. +// schemaTemplates turns the schema.go file and its import block into templates. func schemaTemplates() ([]string, error) { - const name = "schema.go" var ( imports []string code bytes.Buffer fset = token.NewFileSet() + src, _ = files.ReadFile("schema.go") ) - f, err := parser.ParseFile(fset, name, string(internal.MustAsset(name)), parser.AllErrors) + f, err := parser.ParseFile(fset, "schema.go", src, parser.AllErrors) if err != nil { - return nil, fmt.Errorf("parse file: %s: %w", name, err) + return nil, fmt.Errorf("parse schema file: %w", err) } for _, decl := range f.Decls { if decl, ok := decl.(*ast.GenDecl); ok && decl.Tok == token.IMPORT {