Skip to content

Commit

Permalink
fix(build): build the project again
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenfonseca committed Feb 23, 2022
1 parent a3b2b57 commit 5b8ac7d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion convert_types.go → cloudformation/convert_types.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goformation
package cloudformation

import "time"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package goformation
package cloudformation

import (
"reflect"
Expand Down
37 changes: 37 additions & 0 deletions cloudformation/utils/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package utils

import (
"encoding/json"
)

// ByJSONLength implements the sort interface and enables sorting by JSON length
type ByJSONLength []interface{}

func (s ByJSONLength) Len() int {
return len(s)
}

func (s ByJSONLength) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}

func (s ByJSONLength) Less(i, j int) bool {
// Nil is always at the end
if s[i] == nil {
return false
}
if s[j] == nil {
return true
}
jsoni, _ := json.Marshal(s[i])
jsonj, _ := json.Marshal(s[j])

if jsoni == nil {
return false
}
if jsonj == nil {
return true
}

return len(jsoni) > len(jsonj)
}

0 comments on commit 5b8ac7d

Please sign in to comment.