Skip to content

Commit 14bb1dc

Browse files
committed
Stop using ioutil.
1 parent a0d9214 commit 14bb1dc

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

gen.go

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"encoding/json"
1111
"encoding/xml"
1212
"fmt"
13-
"io/ioutil"
13+
"io"
1414
"log"
1515
"net/http"
1616
"os"
@@ -263,7 +263,7 @@ func fetchCLDR(dir string) (string, error) {
263263
return "", err
264264
}
265265

266-
data, err := ioutil.ReadFile(dir + "/cldr-json/cldr-core/package.json")
266+
data, err := os.ReadFile(dir + "/cldr-json/cldr-core/package.json")
267267
if err != nil {
268268
return "", fmt.Errorf("fetchCLDR: %w", err)
269269
}
@@ -331,7 +331,7 @@ func fetchURL(url string) ([]byte, error) {
331331
if resp.StatusCode != http.StatusOK {
332332
return nil, fmt.Errorf("fetchURL: Get %q: %v", url, resp.Status)
333333
}
334-
data, err := ioutil.ReadAll(resp.Body)
334+
data, err := io.ReadAll(resp.Body)
335335
if err != nil {
336336
return nil, fmt.Errorf("fetchURL: Get %q: %w", url, err)
337337
}
@@ -347,7 +347,7 @@ func fetchURL(url string) ([]byte, error) {
347347
// Note that CLDR does not have data for every currency, in which ase
348348
// the original ISO digits are kept.
349349
func replaceDigits(currencies map[string]*currencyInfo, dir string) error {
350-
data, err := ioutil.ReadFile(dir + "/cldr-json/cldr-core/supplemental/currencyData.json")
350+
data, err := os.ReadFile(dir + "/cldr-json/cldr-core/supplemental/currencyData.json")
351351
if err != nil {
352352
return fmt.Errorf("replaceDigits: %w", err)
353353
}
@@ -377,7 +377,7 @@ func replaceDigits(currencies map[string]*currencyInfo, dir string) error {
377377
// Symbols are grouped by locale, and deduplicated by parent.
378378
func generateSymbols(currencies map[string]*currencyInfo, dir string) (map[string]symbolInfoSlice, error) {
379379
symbols := make(map[string]map[string][]string)
380-
files, err := ioutil.ReadDir(dir + "/cldr-json/cldr-numbers-modern/main")
380+
files, err := os.ReadDir(dir + "/cldr-json/cldr-numbers-modern/main")
381381
if err != nil {
382382
return nil, fmt.Errorf("generateSymbols: %w", err)
383383
}
@@ -490,7 +490,7 @@ func generateSymbols(currencies map[string]*currencyInfo, dir string) (map[strin
490490
// Discards symbols belonging to inactive currencies.
491491
func readSymbols(currencies map[string]*currencyInfo, dir string, locale string) (map[string]string, error) {
492492
filename := fmt.Sprintf("%v/cldr-json/cldr-numbers-modern/main/%v/currencies.json", dir, locale)
493-
data, err := ioutil.ReadFile(filename)
493+
data, err := os.ReadFile(filename)
494494
if err != nil {
495495
return nil, fmt.Errorf("readSymbols: %w", err)
496496
}
@@ -526,7 +526,7 @@ func readSymbols(currencies map[string]*currencyInfo, dir string, locale string)
526526
// Formats are deduplicated by parent.
527527
func generateFormats(dir string) (map[string]currencyFormat, error) {
528528
formats := make(map[string]currencyFormat)
529-
files, err := ioutil.ReadDir(dir + "/cldr-json/cldr-numbers-modern/main")
529+
files, err := os.ReadDir(dir + "/cldr-json/cldr-numbers-modern/main")
530530
if err != nil {
531531
return nil, fmt.Errorf("generateFormats: %w", err)
532532
}
@@ -561,7 +561,7 @@ func generateFormats(dir string) (map[string]currencyFormat, error) {
561561
// readFormat reads the given locale's currency format from CLDR data.
562562
func readFormat(dir string, locale string) (currencyFormat, error) {
563563
filename := fmt.Sprintf("%v/cldr-json/cldr-numbers-modern/main/%v/numbers.json", dir, locale)
564-
data, err := ioutil.ReadFile(filename)
564+
data, err := os.ReadFile(filename)
565565
if err != nil {
566566
return currencyFormat{}, fmt.Errorf("readFormat: %w", err)
567567
}
@@ -674,7 +674,7 @@ func readFormat(dir string, locale string) (currencyFormat, error) {
674674
// Ensures ignored locales are skipped.
675675
// Replaces "und" with "en", since this package treats them as equivalent.
676676
func generateParentLocales(dir string) (map[string]string, error) {
677-
data, err := ioutil.ReadFile(dir + "/cldr-json/cldr-core/supplemental/parentLocales.json")
677+
data, err := os.ReadFile(dir + "/cldr-json/cldr-core/supplemental/parentLocales.json")
678678
if err != nil {
679679
return nil, fmt.Errorf("generateParentLocales: %w", err)
680680
}

0 commit comments

Comments
 (0)