Created
July 9, 2016 20:31
-
-
Save stk132/e8bc1501c04763c8b8d89a3826490a7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "fmt" | |
var ( | |
VUsers Users | |
) | |
func init() { | |
VUsers = Users{ | |
original: "users", | |
ID: Column{name: "id"}, | |
Name: Column{name: "name"}, | |
} | |
} | |
type Column struct { | |
name string | |
} | |
func (c Column) N() string { | |
return c.name | |
} | |
type Users struct { | |
original string | |
ID Column | |
Name Column | |
} | |
func (t Users) N() string { | |
return t.original | |
} | |
func (t Users) A(aliasName string) Users { | |
return Users{ | |
original: aliasName, | |
ID: Column{name: fmt.Sprintf("%s.%s", aliasName, "id")}, | |
Name: Column{name: fmt.Sprintf("%s.%s", aliasName, "name")}, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment