Skip to content

Commit 1ba5fe9

Browse files
dasmbMatthew Mark MillerBen Iofel
authored
Updated build to work under Go 1.13+ (#100)
* Updated build to work under Go 1.13+ * Go modules Co-authored-by: Matthew Mark Miller <matt@flow.io> Co-authored-by: Ben Iofel <ben@flow.io>
1 parent a0ae5ea commit 1ba5fe9

7 files changed

Lines changed: 370 additions & 127 deletions

File tree

cleanse/cleanse.go

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"strconv"
1414
"strings"
1515

16-
"../common"
1716
"github.com/bradfitz/slice"
17+
"github.com/flowcommerce/json-reference/common"
1818
"github.com/flowcommerce/tools/util"
1919
)
2020

@@ -257,11 +257,11 @@ func Cleanse() {
257257
}
258258
}
259259

260-
finalCurrency := common.RemapCurrencyCodeToSupported(currency);
261-
if (finalCurrency == "") {
262-
fmt.Printf("Currency %s could not be remapped\n", currency)
263-
os.Exit(1)
264-
}
260+
finalCurrency := common.RemapCurrencyCodeToSupported(currency)
261+
if finalCurrency == "" {
262+
fmt.Printf("Currency %s could not be remapped\n", currency)
263+
os.Exit(1)
264+
}
265265

266266
return Country{
267267
Name: countryName(record),
@@ -413,7 +413,7 @@ func Cleanse() {
413413
LargeWidth: toInt32(record["large_width"]),
414414
LargeHeight: toInt32(record["large_height"]),
415415
Regions: strings.Split(record["regions"], " "),
416-
Capabilities: strings.FieldsFunc(record["capabilities"], splitCapabilities),
416+
Capabilities: strings.FieldsFunc(record["capabilities"], splitCapabilities),
417417
}
418418
},
419419
func(record map[string]string) string {
@@ -510,7 +510,7 @@ func countryName(record map[string]string) string {
510510
"Falkland Islands (Malvinas)": "Falkland Islands",
511511
"China, Hong Kong Special Administrative Region": "Hong Kong",
512512
"China, Macao Special Administrative Region": "Macau",
513-
"Viet Nam": "Vietnam",
513+
"Viet Nam": "Vietnam",
514514
}
515515

516516
name := record["official_name_en"]
@@ -645,29 +645,29 @@ func readCurrencySymbols(file string) map[string]CurrencySymbols {
645645

646646
for _, main := range data.Main {
647647
for code, c := range main.Numbers.Currencies {
648-
if c.Symbol == "" {
649-
fmt.Printf("Currency %s has no symbol\n", code)
650-
os.Exit(1)
651-
}
652-
653-
var narrow string
654-
if c.Symbol == c.SymbolAltNarrow {
655-
narrow = c.Symbol
656-
} else {
657-
narrow = c.SymbolAltNarrow
658-
}
659-
660-
var primary string
661-
if code == "USD" {
662-
primary = "US$"
663-
} else {
664-
primary = c.Symbol
665-
}
666-
667-
currencySymbols[code] = CurrencySymbols{
668-
Primary: primary,
669-
Narrow: narrow,
670-
}
648+
if c.Symbol == "" {
649+
fmt.Printf("Currency %s has no symbol\n", code)
650+
os.Exit(1)
651+
}
652+
653+
var narrow string
654+
if c.Symbol == c.SymbolAltNarrow {
655+
narrow = c.Symbol
656+
} else {
657+
narrow = c.SymbolAltNarrow
658+
}
659+
660+
var primary string
661+
if code == "USD" {
662+
primary = "US$"
663+
} else {
664+
primary = c.Symbol
665+
}
666+
667+
currencySymbols[code] = CurrencySymbols{
668+
Primary: primary,
669+
Narrow: narrow,
670+
}
671671
}
672672
}
673673
return currencySymbols
@@ -681,11 +681,11 @@ func readCurrencies(file string) []Currency {
681681
currencies := []Currency{}
682682

683683
for _, c := range data {
684-
currencies = append(currencies, Currency{
685-
Name: c.Name,
686-
Iso_4217_3: c.Iso_4217_3,
687-
NumberDecimals: c.NumberDecimals,
688-
})
684+
currencies = append(currencies, Currency{
685+
Name: c.Name,
686+
Iso_4217_3: c.Iso_4217_3,
687+
NumberDecimals: c.NumberDecimals,
688+
})
689689
}
690690
sortCurrencies(currencies)
691691

@@ -792,7 +792,6 @@ func LoadCurrencyLocales() map[string]string {
792792
return table
793793
}
794794

795-
796795
// For some reason, some countries are missing from the underlying CLDR "Numbers" data that we ingest.
797796
// It's easier to add this manual override than figure out how to fix the source data.
798797
func LoadLocaleOverrides() []common.Locale {

final/final.go

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,49 +9,49 @@ import (
99
"sort"
1010
"strings"
1111

12-
"../cleanse"
13-
"../common"
1412
"github.com/bradfitz/slice"
13+
"github.com/flowcommerce/json-reference/cleanse"
14+
"github.com/flowcommerce/json-reference/common"
1515
)
1616

1717
type CleansedDataSet struct {
18-
Carriers []cleanse.Carrier
19-
CarrierServices []cleanse.CarrierService
20-
Continents []cleanse.Continent
21-
Countries []cleanse.Country
22-
CountryContinents []cleanse.CountryContinent
23-
CountryDuties []cleanse.CountryDuty
24-
Currencies []cleanse.Currency
25-
CurrencySymbols map[string]cleanse.CurrencySymbols
26-
Numbers []cleanse.Number
27-
Languages []cleanse.Language
28-
LocaleNames []cleanse.LocaleName
29-
PaymentMethods []cleanse.PaymentMethod
30-
Provinces []cleanse.Province
31-
ProvinceTranslations []cleanse.ProvinceTranslation
32-
Timezones []cleanse.Timezone
33-
CountryTimezones []cleanse.CountryTimezone
34-
CountryDefaultLanguages []cleanse.CountryDefaultLanguage
18+
Carriers []cleanse.Carrier
19+
CarrierServices []cleanse.CarrierService
20+
Continents []cleanse.Continent
21+
Countries []cleanse.Country
22+
CountryContinents []cleanse.CountryContinent
23+
CountryDuties []cleanse.CountryDuty
24+
Currencies []cleanse.Currency
25+
CurrencySymbols map[string]cleanse.CurrencySymbols
26+
Numbers []cleanse.Number
27+
Languages []cleanse.Language
28+
LocaleNames []cleanse.LocaleName
29+
PaymentMethods []cleanse.PaymentMethod
30+
Provinces []cleanse.Province
31+
ProvinceTranslations []cleanse.ProvinceTranslation
32+
Timezones []cleanse.Timezone
33+
CountryTimezones []cleanse.CountryTimezone
34+
CountryDefaultLanguages []cleanse.CountryDefaultLanguage
3535
}
3636

3737
func Generate() {
3838
data := CleansedDataSet{
39-
Carriers: cleanse.LoadCarriers(),
40-
CarrierServices: cleanse.LoadCarrierServices(),
41-
Continents: cleanse.LoadContinents(),
42-
Countries: cleanse.LoadCountries(),
43-
CountryContinents: cleanse.LoadCountryContinents(),
44-
CountryDuties: cleanse.LoadCountryDuties(),
45-
Currencies: cleanse.LoadCurrencies(),
46-
CurrencySymbols: cleanse.LoadCurrencySymbols(),
47-
Languages: cleanse.LoadLanguages(),
48-
LocaleNames: cleanse.LoadLocaleNames(),
49-
PaymentMethods: cleanse.LoadPaymentMethods(),
50-
Provinces: cleanse.LoadProvinces(),
51-
ProvinceTranslations: cleanse.LoadProvinceTranslations(),
52-
Numbers: cleanse.LoadNumbers(),
53-
Timezones: cleanse.LoadTimezones(),
54-
CountryTimezones: cleanse.LoadCountryTimezones(),
39+
Carriers: cleanse.LoadCarriers(),
40+
CarrierServices: cleanse.LoadCarrierServices(),
41+
Continents: cleanse.LoadContinents(),
42+
Countries: cleanse.LoadCountries(),
43+
CountryContinents: cleanse.LoadCountryContinents(),
44+
CountryDuties: cleanse.LoadCountryDuties(),
45+
Currencies: cleanse.LoadCurrencies(),
46+
CurrencySymbols: cleanse.LoadCurrencySymbols(),
47+
Languages: cleanse.LoadLanguages(),
48+
LocaleNames: cleanse.LoadLocaleNames(),
49+
PaymentMethods: cleanse.LoadPaymentMethods(),
50+
Provinces: cleanse.LoadProvinces(),
51+
ProvinceTranslations: cleanse.LoadProvinceTranslations(),
52+
Numbers: cleanse.LoadNumbers(),
53+
Timezones: cleanse.LoadTimezones(),
54+
CountryTimezones: cleanse.LoadCountryTimezones(),
5555
CountryDefaultLanguages: cleanse.LoadCountryDefaultLanguages(),
5656
}
5757

@@ -350,7 +350,7 @@ func commonPaymentMethods(data CleansedDataSet, regions []common.Region) []commo
350350
Medium: toPaymentMethodImage(pm.Id, pm.MediumWidth, pm.MediumHeight, "60"),
351351
Large: toPaymentMethodImage(pm.Id, pm.LargeWidth, pm.LargeHeight, "120"),
352352
},
353-
Regions: theseRegions,
353+
Regions: theseRegions,
354354
Capabilities: theseCapabilities,
355355
})
356356
}
@@ -425,20 +425,20 @@ func commonCountries(data CleansedDataSet) []common.Country {
425425
var defaultLanguage string
426426
for _, cl := range data.CountryDefaultLanguages {
427427
if cl.CountryCode == c.Iso_3166_3 {
428-
lang := findLanguageByCode(data.Languages, cl.LanguageCode)
429-
if (defaultLanguage != "") {
430-
fmt.Printf("ERROR: invalid multiple default language codes for country[%s]\n", cl.CountryCode)
431-
os.Exit(1)
432-
}
433-
if (!common.Contains(languages, lang.Iso_639_2)) {
434-
fmt.Printf("ERROR: default language[%s] is not listed in languages for country[%s]\n", lang.Iso_639_2, cl.CountryCode)
435-
os.Exit(1)
436-
}
428+
lang := findLanguageByCode(data.Languages, cl.LanguageCode)
429+
if defaultLanguage != "" {
430+
fmt.Printf("ERROR: invalid multiple default language codes for country[%s]\n", cl.CountryCode)
431+
os.Exit(1)
432+
}
433+
if !common.Contains(languages, lang.Iso_639_2) {
434+
fmt.Printf("ERROR: default language[%s] is not listed in languages for country[%s]\n", lang.Iso_639_2, cl.CountryCode)
435+
os.Exit(1)
436+
}
437437
defaultLanguage = lang.Iso_639_2
438438
}
439439
}
440-
if (defaultLanguage == "" && len(languages) > 0) {
441-
defaultLanguage = languages[0]
440+
if defaultLanguage == "" && len(languages) > 0 {
441+
defaultLanguage = languages[0]
442442
}
443443

444444
var defaultCurrency string

go.mod

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module github.com/flowcommerce/json-reference
2+
3+
go 1.15
4+
5+
require (
6+
github.com/bradfitz/slice v0.0.0-20180809154707-2b758aa73013
7+
github.com/flowcommerce/apidoc v0.0.0-20160831220209-3530ddeff243 // indirect
8+
github.com/flowcommerce/tools v0.0.0-20201012200937-c79fdda1d469
9+
github.com/urfave/cli v1.22.5
10+
go4.org v0.0.0-20201209231011-d4a079459e60 // indirect
11+
)

0 commit comments

Comments
 (0)