Skip to content

Commit 7f31702

Browse files
committed
Add @ helper methods
1 parent 11baebd commit 7f31702

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

go.mod

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
module "github.com/cortexlabs/yaml"
1+
module github.com/cortexlabs/yaml
22

3-
require (
4-
"gopkg.in/check.v1" v0.0.0-20161208181325-20d25e280405
5-
)
3+
require gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405

yaml.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -485,9 +485,30 @@ func EscapeAtSymbol(str string) (string, bool) {
485485
return str, false
486486
}
487487

488-
func UnescapeAtSymbol(str string) (string, bool) {
488+
func UnescapeAtSymbol(str string) string {
489+
if strings.HasPrefix(str, atSymbolEscapeSeq) {
490+
return "@" + str[len(atSymbolEscapeSeq):]
491+
}
492+
return str
493+
}
494+
495+
func UnescapeAtSymbolOk(str string) (string, bool) {
489496
if strings.HasPrefix(str, atSymbolEscapeSeq) {
490497
return "@" + str[len(atSymbolEscapeSeq):], true
491498
}
492499
return str, false
493500
}
501+
502+
func UnescapeAllAtSymbols(str string) string {
503+
if strings.Contains(str, atSymbolEscapeSeq) {
504+
return strings.ReplaceAll(str, atSymbolEscapeSeq, "@")
505+
}
506+
return str
507+
}
508+
509+
func UnescapeAllAtSymbolsOk(str string) (string, bool) {
510+
if strings.Contains(str, atSymbolEscapeSeq) {
511+
return strings.ReplaceAll(str, atSymbolEscapeSeq, "@"), true
512+
}
513+
return str, false
514+
}

0 commit comments

Comments
 (0)