Skip to content

Commit

Permalink
Merge pull request #18 from bavix/naming-fix
Browse files Browse the repository at this point in the history
short naming
  • Loading branch information
rez1dent3 committed Sep 1, 2023
2 parents 9c73a20 + 0c16538 commit 127ac6b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions pkg/yaml2json/convertor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ func TestConvertor(t *testing.T) {

bytes, err := convertor.Execute("hello", []byte(`
yaml2json:
base64: {{ uuidToBase64StdEncoding "77465064-a0ce-48a3-b7e4-d50f88e55093" }}
highLow: {{ uuidToHighLowLittleEndian "e351220b-4847-42f5-8abb-c052b87ff2d4" }}
base64: {{ uuid2base64 "77465064-a0ce-48a3-b7e4-d50f88e55093" }}
highLow: {{ uuid2highLow "e351220b-4847-42f5-8abb-c052b87ff2d4" }}
`))

expected := `{
Expand Down
4 changes: 2 additions & 2 deletions pkg/yaml2json/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ func (e *engine) Execute(name string, data []byte) ([]byte, error) {

func (e *engine) funcMap() template.FuncMap {
return template.FuncMap{
"uuidToBase64StdEncoding": func(guid string) string {
"uuid2base64": func(guid string) string {
v := uuid.MustParse(guid)

return base64.StdEncoding.EncodeToString(v[:])
},
"uuidToHighLowLittleEndian": func(guid string) string {
"uuid2highLow": func(guid string) string {
v := uuid.MustParse(guid)

high := int64(v[0]) | int64(v[1])<<8 | int64(v[2])<<16 | int64(v[3])<<24 |
Expand Down

0 comments on commit 127ac6b

Please sign in to comment.