Explorar o código

Create custom name mapping with TableName interface or struct tags.

Frederic G. MARAND %!s(int64=9) %!d(string=hai) anos
pai
achega
ddb7ef5985
Modificáronse 1 ficheiros con 12 adicións e 0 borrados
  1. 12 0
      main.go

+ 12 - 0
main.go

@@ -29,6 +29,18 @@ import (
 	"github.com/go-xorm/core"
 )
 
+type Foo struct {
+	Baz string `xorm:`
+}
+
+// Implement the TableName interface to generate a fully custom table name for
+// a struct type.
+//
+// @see xorm.TableName interface.
+func (f Foo) TableName() string {
+	return "foobar";
+}
+
 func check(err error) {
 	if err != nil {
 		fmt.Println(err.Error())