@@ -74,36 +74,36 @@ type SubstituteFunc func(string, Mapping) (string, bool, error)
7474
7575// ReplacementFunc is a user-supplied function that is apply to the matching
7676// substring. Returns the value as a string and an error.
77- type ReplacementFunc func (string , Mapping , config ) (string , error )
77+ type ReplacementFunc func (string , Mapping , * Config ) (string , error )
7878
79- type config struct {
79+ type Config struct {
8080 pattern * regexp.Regexp
8181 substituteFunc SubstituteFunc
8282 replacementFunc ReplacementFunc
8383 logging bool
8484}
8585
86- type Option func (* config )
86+ type Option func (* Config )
8787
8888func WithPattern (pattern * regexp.Regexp ) Option {
89- return func (cfg * config ) {
89+ return func (cfg * Config ) {
9090 cfg .pattern = pattern
9191 }
9292}
9393
9494func WithSubstitutionFunction (subsFunc SubstituteFunc ) Option {
95- return func (cfg * config ) {
95+ return func (cfg * Config ) {
9696 cfg .substituteFunc = subsFunc
9797 }
9898}
9999
100100func WithReplacementFunction (replacementFunc ReplacementFunc ) Option {
101- return func (cfg * config ) {
101+ return func (cfg * Config ) {
102102 cfg .replacementFunc = replacementFunc
103103 }
104104}
105105
106- func WithoutLogging (cfg * config ) {
106+ func WithoutLogging (cfg * Config ) {
107107 cfg .logging = false
108108}
109109
@@ -112,7 +112,7 @@ func WithoutLogging(cfg *config) {
112112func SubstituteWithOptions (template string , mapping Mapping , options ... Option ) (string , error ) {
113113 var returnErr error
114114
115- cfg := & config {
115+ cfg := & Config {
116116 pattern : defaultPattern ,
117117 replacementFunc : DefaultReplacementFunc ,
118118 logging : true ,
@@ -122,7 +122,7 @@ func SubstituteWithOptions(template string, mapping Mapping, options ...Option)
122122 }
123123
124124 result := cfg .pattern .ReplaceAllStringFunc (template , func (substring string ) string {
125- replacement , err := cfg .replacementFunc (substring , mapping , * cfg )
125+ replacement , err := cfg .replacementFunc (substring , mapping , cfg )
126126 if err != nil {
127127 // Add the template for template errors
128128 var tmplErr * InvalidTemplateError
@@ -143,7 +143,7 @@ func SubstituteWithOptions(template string, mapping Mapping, options ...Option)
143143 return result , returnErr
144144}
145145
146- func DefaultReplacementFunc (substring string , mapping Mapping , cfg config ) (string , error ) {
146+ func DefaultReplacementFunc (substring string , mapping Mapping , cfg * Config ) (string , error ) {
147147 pattern := cfg .pattern
148148 subsFunc := cfg .substituteFunc
149149 if subsFunc == nil {
0 commit comments