From aee570b5968bfb0ce0551d7bd73c77bcf18860e6 Mon Sep 17 00:00:00 2001 From: Valentin Kuznetsov Date: Sun, 1 Aug 2021 13:30:12 -0400 Subject: [PATCH] Replace ioutil.ReadAll to io.ReadAll, ioutil.ReadFile to os.ReadFile per go 1.16 changes --- config/config.go | 4 ++-- dasconfig.json | 4 ++-- dasmaps/dasmaps.go | 7 +++---- monitor/das2go_monitor.go | 4 ++-- utils/fetch.go | 2 +- utils/rucio.go | 4 ++-- utils/utils.go | 5 ++--- 7 files changed, 14 insertions(+), 16 deletions(-) diff --git a/config/config.go b/config/config.go index 40fe02e..b7d7be7 100644 --- a/config/config.go +++ b/config/config.go @@ -9,8 +9,8 @@ import ( "encoding/json" "errors" "fmt" - "io/ioutil" "log" + "os" ) // Configuration stores DAS configuration parameters @@ -54,7 +54,7 @@ func (c *Configuration) String() string { // ParseConfig parse given config file func ParseConfig(configFile string) error { - data, err := ioutil.ReadFile(configFile) + data, err := os.ReadFile(configFile) if err != nil { log.Printf("Unable to read: file %s, error %v\n", configFile, err) return err diff --git a/dasconfig.json b/dasconfig.json index 50d7ea0..2e2d16e 100644 --- a/dasconfig.json +++ b/dasconfig.json @@ -4,7 +4,7 @@ "base": "/das", "port": 8217, "services": ["combined","conddb","dashboard","dbs3","mcm","reqmgr2","runregistry","cric","rucio"], - "urlQueueLimit": 0, + "urlQueueLimit": 100, "urlRetry": 3, "templates": "/Users/vk/Work/Languages/Go/gopath/src/github.com/dmwm/das2go/templates", "jscripts": "/Users/vk/Work/Languages/Go/gopath/src/github.com/dmwm/das2go/js", @@ -23,5 +23,5 @@ "logFile": "/tmp/das.log", "useDNSCache": false, "authDN": false, - "verbose": 0 + "verbose": 2 } diff --git a/dasmaps/dasmaps.go b/dasmaps/dasmaps.go index 87bdb9f..2fb7ab0 100644 --- a/dasmaps/dasmaps.go +++ b/dasmaps/dasmaps.go @@ -8,7 +8,6 @@ package dasmaps import ( "encoding/json" "fmt" - "io/ioutil" "log" "os" "regexp" @@ -551,7 +550,7 @@ func (m *DASMaps) LoadMapsFromFile() { resp := utils.FetchResponse(client, githubUrl, "") if resp.Error == nil { // write data to local area - err := ioutil.WriteFile(fname, []byte(resp.Data), 0777) + err := os.WriteFile(fname, []byte(resp.Data), 0777) if err != nil { log.Printf("ERROR: unable to write DAS maps, time %v, error %v\n", time.Now(), err) return @@ -563,7 +562,7 @@ func (m *DASMaps) LoadMapsFromFile() { } m.ReadMapFile(fname) /* - data, err := ioutil.ReadFile(fname) + data, err := os.ReadFile(fname) if err != nil { log.Printf("ERROR: unable to read DAS maps, time %v, file %v, error %v\n", time.Now(), fname, err) return @@ -586,7 +585,7 @@ func (m *DASMaps) ReadMapFile(fname string) { if utils.VERBOSE > 0 { fmt.Println("Load dasmaps", fname) } - data, err := ioutil.ReadFile(fname) + data, err := os.ReadFile(fname) if err != nil { log.Printf("ERROR: unable to read DAS maps, time %v, file %v, error %v\n", time.Now(), fname, err) return diff --git a/monitor/das2go_monitor.go b/monitor/das2go_monitor.go index 8b778a7..742f10d 100644 --- a/monitor/das2go_monitor.go +++ b/monitor/das2go_monitor.go @@ -26,7 +26,7 @@ func checkHttpEndpoint(endpoint, pat string) bool { log.Printf("ERROR: unable to fetch data, url %v, error %v\n", endpoint, err) return false } - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) if err != nil { log.Printf("ERROR: unable to read response body, status %v, error %v\n", resp.Status, err) return false @@ -102,7 +102,7 @@ func main() { flag.StringVar(&config, "config", "config.json", "DAS server config") flag.Parse() // parse DAS config file and find our on which port it is running - data, e := ioutil.ReadFile(config) + data, e := os.ReadFile(config) if e != nil { log.Fatalf("unable to open %s\n", config) } diff --git a/utils/fetch.go b/utils/fetch.go index 9089d77..fcdb6d4 100644 --- a/utils/fetch.go +++ b/utils/fetch.go @@ -155,7 +155,7 @@ func tlsCerts() ([]tls.Certificate, error) { // helper function to either read file content or return given string func readToken(r string) string { if _, err := os.Stat(r); err == nil { - b, e := ioutil.ReadFile(r) + b, e := os.ReadFile(r) if e != nil { log.Fatalf("Unable to read data from file: %s, error: %s", r, e) } diff --git a/utils/rucio.go b/utils/rucio.go index e12028e..657a4a1 100644 --- a/utils/rucio.go +++ b/utils/rucio.go @@ -6,7 +6,7 @@ package utils import ( "fmt" - "io/ioutil" + "io" "log" "net/http" "net/http/httputil" @@ -140,7 +140,7 @@ func FetchRucioToken(rurl string) (string, int64, error) { dump, err := httputil.DumpResponse(resp, true) log.Printf("http response rurl %v, dump %v, error %v\n", rurl, string(dump), err) } - _, err = ioutil.ReadAll(resp.Body) + _, err = io.ReadAll(resp.Body) if err != nil { if VERBOSE > 0 { log.Println("ERROR: unable to read response body", err) diff --git a/utils/utils.go b/utils/utils.go index 1fc9ddf..b644974 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -10,7 +10,6 @@ import ( "encoding/gob" "encoding/json" "fmt" - "io/ioutil" "log" "os" "runtime" @@ -497,7 +496,7 @@ func LoadExamples(ename, home string) string { resp := FetchResponse(client, githubUrl, "") if resp.Error == nil { // write data to local area - err := ioutil.WriteFile(fname, []byte(resp.Data), 0777) + err := os.WriteFile(fname, []byte(resp.Data), 0777) if err != nil { log.Println("ERROR: unable to write DAS example file", err) return "" @@ -507,7 +506,7 @@ func LoadExamples(ename, home string) string { return "" } } - data, err := ioutil.ReadFile(fname) + data, err := os.ReadFile(fname) if err != nil { log.Printf("ERROR: unable to read DAS example file %v, error %v\n", fname, err) return ""