Skip to content

Commit

Permalink
Sort languages in prefix maps to make output deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Dec 14, 2023
1 parent 6005108 commit 81c9e8d
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 28 deletions.
8 changes: 7 additions & 1 deletion cmd/buildmetadata/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"strconv"
"strings"

"golang.org/x/exp/maps"
"google.golang.org/protobuf/proto"

"github.com/nyaruka/phonenumbers"
Expand Down Expand Up @@ -342,7 +343,12 @@ func buildPrefixData(build *prefixBuild) {
output.WriteString("package phonenumbers\n\n")
output.WriteString(fmt.Sprintf("var %s = map[string]string {\n", build.varName))

for lang, mappings := range languageMappings {
langs := maps.Keys(languageMappings)
sort.Strings(langs)

for _, lang := range langs {
mappings := languageMappings[lang]

// iterate through our map, creating our full set of values and prefixes
prefixes := make([]int, 0, len(mappings))
seenValues := make(map[string]bool)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.19

require (
github.com/stretchr/testify v1.8.4
golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611
golang.org/x/text v0.14.0
google.golang.org/protobuf v1.31.0
)
Expand Down
5 changes: 3 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611 h1:qCEDpW1G+vcj3Y7Fy52pEM1AWm3abj8WimGYejI3SC4=
golang.org/x/exp v0.0.0-20231214170342-aacd6d4b4611/go.mod h1:iRJReGqOEeBhDZGkGbynYwcHlctCvnjTYIamk7uXpHI=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
Expand Down
8 changes: 4 additions & 4 deletions prefix_to_carriers_bin.go

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions prefix_to_geocodings_bin.go

Large diffs are not rendered by default.

0 comments on commit 81c9e8d

Please sign in to comment.