Skip to content

Commit

Permalink
Replace ioutil.ReadAll to io.ReadAll, ioutil.ReadFile to os.ReadFile …
Browse files Browse the repository at this point in the history
…per go 1.16 changes
  • Loading branch information
vkuznet committed Aug 1, 2021
1 parent 300bb32 commit aee570b
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 16 deletions.
4 changes: 2 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"log"
"os"
)

// Configuration stores DAS configuration parameters
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions dasconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -23,5 +23,5 @@
"logFile": "/tmp/das.log",
"useDNSCache": false,
"authDN": false,
"verbose": 0
"verbose": 2
}
7 changes: 3 additions & 4 deletions dasmaps/dasmaps.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package dasmaps
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"regexp"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions monitor/das2go_monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion utils/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions utils/rucio.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package utils

import (
"fmt"
"io/ioutil"
"io"
"log"
"net/http"
"net/http/httputil"
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"encoding/gob"
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"runtime"
Expand Down Expand Up @@ -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 ""
Expand All @@ -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 ""
Expand Down

0 comments on commit aee570b

Please sign in to comment.