diff --git a/go.mod b/go.mod index 6d2ffe4f..a131cc5f 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,3 @@ -module "github.com/cortexlabs/yaml" +module github.com/cortexlabs/yaml -require ( - "gopkg.in/check.v1" v0.0.0-20161208181325-20d25e280405 -) +require gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 diff --git a/yaml.go b/yaml.go index 409647d9..4d053513 100644 --- a/yaml.go +++ b/yaml.go @@ -485,9 +485,30 @@ func EscapeAtSymbol(str string) (string, bool) { return str, false } -func UnescapeAtSymbol(str string) (string, bool) { +func UnescapeAtSymbol(str string) string { + if strings.HasPrefix(str, atSymbolEscapeSeq) { + return "@" + str[len(atSymbolEscapeSeq):] + } + return str +} + +func UnescapeAtSymbolOk(str string) (string, bool) { if strings.HasPrefix(str, atSymbolEscapeSeq) { return "@" + str[len(atSymbolEscapeSeq):], true } return str, false } + +func UnescapeAllAtSymbols(str string) string { + if strings.Contains(str, atSymbolEscapeSeq) { + return strings.ReplaceAll(str, atSymbolEscapeSeq, "@") + } + return str +} + +func UnescapeAllAtSymbolsOk(str string) (string, bool) { + if strings.Contains(str, atSymbolEscapeSeq) { + return strings.ReplaceAll(str, atSymbolEscapeSeq, "@"), true + } + return str, false +}