Skip to content

Commit

Permalink
update markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
ystyle committed Dec 6, 2019
1 parent fca6cd8 commit bd1f6e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import (
"strings"
)

type sqlManager struct {
type SqlManager struct {
sqlTemples []SqlTemple
drivers map[string]Driver
}

func New() *sqlManager {
sm := &sqlManager{
func New() *SqlManager {
sm := &SqlManager{
drivers: make(map[string]Driver),
}
return sm
}

func (sm *sqlManager) Use(plugin Driver) {
func (sm *SqlManager) Use(plugin Driver) {
sm.drivers[plugin.DriverName()] = plugin
}

func (sm *sqlManager) Load() {
func (sm *SqlManager) Load() {
for _, driver := range sm.drivers {
sqls, err := driver.Load()
if err != nil {
Expand All @@ -44,7 +44,7 @@ func (sm *sqlManager) Load() {
}
}

func (sm *sqlManager) findTpl(name string) (*SqlTemple, error) {
func (sm *SqlManager) findTpl(name string) (*SqlTemple, error) {
for _, tpl := range sm.sqlTemples {
if tpl.Name == name {
return &tpl, nil
Expand Down
8 changes: 4 additions & 4 deletions render_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"text/template"
)

func (sm *sqlManager) RenderTPL(name string, data interface{}) (string, error) {
func (sm *SqlManager) RenderTPL(name string, data interface{}) (string, error) {
tpl, err := sm.findTpl(name)
if err != nil {
return "", err
Expand All @@ -24,7 +24,7 @@ func (sm *sqlManager) RenderTPL(name string, data interface{}) (string, error) {
return buff.String(), nil
}

func (sm *sqlManager) RenderTPLUnSave(name string, data interface{}) string {
func (sm *SqlManager) RenderTPLUnSave(name string, data interface{}) string {
sql, err := sm.RenderTPL(name, data)
if err != nil {
log.Printf("sqlmanager - ERROR: %s, render error: %s", name, err.Error())
Expand All @@ -33,7 +33,7 @@ func (sm *sqlManager) RenderTPLUnSave(name string, data interface{}) string {
return sql
}

func (sm *sqlManager) RenderTPLString(sql string, data interface{}) (string, error) {
func (sm *SqlManager) RenderTPLString(sql string, data interface{}) (string, error) {
t := template.New("sql")
_, err := t.Parse(sql)
if err != nil {
Expand All @@ -47,7 +47,7 @@ func (sm *sqlManager) RenderTPLString(sql string, data interface{}) (string, err
return buff.String(), nil
}

func (sm *sqlManager) RenderTPLStringUnsave(sql string, data interface{}) string {
func (sm *SqlManager) RenderTPLStringUnsave(sql string, data interface{}) string {
sql, err := sm.RenderTPL(sql, data)
if err != nil {
log.Printf("sqlmanager - ERROR: render error: %s", err.Error())
Expand Down

0 comments on commit bd1f6e9

Please sign in to comment.