Skip to content

Commit

Permalink
Hide custom funcs field to private
Browse files Browse the repository at this point in the history
  • Loading branch information
pinzolo committed Aug 4, 2018
1 parent ecd3c48 commit 1177a2c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sqlt.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ type SQLTemplate struct {
// This func should return current time.
// If this function is not set, used `time.Now()` as default function.
TimeFunc func() time.Time
// CustomFuncs are custom functions that are used in template.
CustomFuncs map[string]interface{}
// customFuncs are custom functions that are used in template.
customFuncs map[string]interface{}
}

// New template initialized with dialect.
func New(dialect Dialect) SQLTemplate {
return SQLTemplate{dialect: dialect, CustomFuncs: make(map[string]interface{})}
return SQLTemplate{dialect: dialect, customFuncs: make(map[string]interface{})}
}

// AddFunc add custom template func.
func (st SQLTemplate) AddFunc(name string, fn interface{}) SQLTemplate {
st.CustomFuncs[name] = fn
st.customFuncs[name] = fn
return st
}

// AddFuncs add custom template functions.
func (st SQLTemplate) AddFuncs(funcs map[string]interface{}) SQLTemplate {
for k, v := range funcs {
st.CustomFuncs[k] = v
st.customFuncs[k] = v
}
return st
}
Expand Down Expand Up @@ -76,7 +76,7 @@ func (st SQLTemplate) ExecNamed(text string, m map[string]interface{}) (string,
}

func (st SQLTemplate) exec(c *context, text string, m map[string]interface{}) (string, error) {
t, err := template.New("").Funcs(c.funcMap(st.CustomFuncs)).Delims(LeftDelim, RightDelim).Parse(dropSample(text))
t, err := template.New("").Funcs(c.funcMap(st.customFuncs)).Delims(LeftDelim, RightDelim).Parse(dropSample(text))
if err != nil {
return "", err
}
Expand Down

0 comments on commit 1177a2c

Please sign in to comment.