mirror of
https://github.com/ent/ent.git
synced 2026-04-28 05:30:56 +03:00
entc: add relevant example-code for bytes field
Reviewed By: alexsn Differential Revision: D16639870 fbshipit-source-id: 948cb0256fc8691a6c2194ee31db984d6ac1aede
This commit is contained in:
committed by
Facebook Github Bot
parent
66ea49049a
commit
c5259c8528
@@ -519,7 +519,7 @@ func templateDialectSqlCreateTmpl() (*asset, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "template/dialect/sql/create.tmpl", size: 6066, mode: os.FileMode(420), modTime: time.Unix(1564676394, 0)}
|
||||
info := bindataFileInfo{name: "template/dialect/sql/create.tmpl", size: 6066, mode: os.FileMode(420), modTime: time.Unix(1564868040, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
@@ -639,7 +639,7 @@ func templateDialectSqlPredicateTmpl() (*asset, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "template/dialect/sql/predicate.tmpl", size: 4064, mode: os.FileMode(420), modTime: time.Unix(1564676224, 0)}
|
||||
info := bindataFileInfo{name: "template/dialect/sql/predicate.tmpl", size: 4064, mode: os.FileMode(420), modTime: time.Unix(1564868040, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
@@ -378,14 +378,15 @@ func catch(err *error) {
|
||||
|
||||
// goimports runs goimports on the given target.
|
||||
func goimports(target string) error {
|
||||
if _, err := exec.LookPath("goimports"); err != nil {
|
||||
return fmt.Errorf("entc/gen: goimports was not found in $PATH")
|
||||
}
|
||||
cmd := exec.Command("goimports", "-w", target)
|
||||
out := bytes.NewBuffer(nil)
|
||||
cmd.Stderr = out
|
||||
if err := cmd.Run(); err != nil {
|
||||
switch err := cmd.Run(); err.(type) {
|
||||
case nil:
|
||||
return nil
|
||||
case *exec.ExitError:
|
||||
return fmt.Errorf("entc/gen: goimports: %s", out)
|
||||
default:
|
||||
return fmt.Errorf("entc/gen: %s", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -317,6 +317,8 @@ func (f Field) ExampleCode() string {
|
||||
switch f.Type {
|
||||
case field.TypeString:
|
||||
return "\"string\""
|
||||
case field.TypeBytes:
|
||||
return "[]byte{}"
|
||||
case field.TypeBool:
|
||||
return "true"
|
||||
case field.TypeTime:
|
||||
|
||||
@@ -80,7 +80,7 @@ func ExampleUser() {
|
||||
SetAge(1).
|
||||
SetName("string").
|
||||
SetPhone("string").
|
||||
SetBuffer(1).
|
||||
SetBuffer([]byte{}).
|
||||
SaveX(ctx)
|
||||
log.Println("user created:", u)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user