Skip to content

Commit

Permalink
Fix lint warn
Browse files Browse the repository at this point in the history
  • Loading branch information
k1LoW committed Mar 8, 2024
1 parent 2a9417d commit a1b3a34
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions repfn.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ type repFn func(in string) (string, error)
var envPlaceholderRe = regexp.MustCompile(`\${.+}`)

func InterpolateRepFn(mapping func(string) (string, bool)) repFn {
const repToken = "__NOT_INTERPOLATE_START__"
const notRep = "__NOT_INTERPOLATE_START__"
mapper := Mapper{mapping: mapping}
return func(in string) (string, error) {
if !envPlaceholderRe.MatchString(in) {
return in, nil
}
r := strings.NewReplacer("${", "${", "$", repToken)
rr := strings.NewReplacer(repToken, "$")
r := strings.NewReplacer("${", "${", "$", notRep)
rr := strings.NewReplacer(notRep, "$")

replace, err := interpolate.Interpolate(mapper, r.Replace(in))
if err != nil {
Expand Down Expand Up @@ -138,8 +138,8 @@ func trySubstr(delimStart, delimEnd, in string) ([]string, int) {

func unescapeDelims(delimStart, delimEnd, in string) string {
const (
eeStartToken = "__E_E_DELIM_START__"
eeEndToken = "__E_E_DELIM_END__"
eeStartRep = "__E_E_DELIM_START__" //
eeEndRep = "__E_E_DELIM_END__"
)
var (
escapedDelimStart string
Expand All @@ -153,7 +153,7 @@ func unescapeDelims(delimStart, delimEnd, in string) string {
escapedDelimEnd += fmt.Sprintf("\\%s", string(r))
}
escapedescapedDelimEnd := fmt.Sprintf("\\%s", escapedDelimEnd)
rep := strings.NewReplacer(escapedescapedDelimStart, eeStartToken, escapedescapedDelimEnd, eeEndToken, escapedDelimStart, delimStart, escapedDelimEnd, delimEnd)
rep2 := strings.NewReplacer(eeStartToken, escapedDelimStart, eeEndToken, escapedDelimEnd)
rep := strings.NewReplacer(escapedescapedDelimStart, eeStartRep, escapedescapedDelimEnd, eeEndRep, escapedDelimStart, delimStart, escapedDelimEnd, delimEnd)
rep2 := strings.NewReplacer(eeStartRep, escapedDelimStart, eeEndRep, escapedDelimEnd)
return rep2.Replace(rep.Replace(in))
}

0 comments on commit a1b3a34

Please sign in to comment.