Skip to content

Commit 464e26b

Browse files
committed
Remove dependency on io/ioutil module
This fixes lint errors generated in CI after upgrading go version into 1.19.6. Signed-off-by: Periyasamy Palanisamy <[email protected]>
1 parent e0bed3f commit 464e26b

File tree

7 files changed

+23
-21
lines changed

7 files changed

+23
-21
lines changed

cache/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Package cache provides a cache of model.Model elements that can be used in an OV
33
44
The cache can be accessed using a simple API:
55
6-
cache.Table("Open_vSwitch").Row("<ovs-uuid>")
6+
cache.Table("Open_vSwitch").Row("<ovs-uuid>")
77
88
It implements the ovsdb.NotificationHandler interface
99
such that it can be populated automatically by

cmd/modelgen/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"encoding/json"
55
"flag"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"log"
99
"os"
1010
"path/filepath"
@@ -56,7 +56,7 @@ func main() {
5656
}
5757
defer schemaFile.Close()
5858

59-
schemaBytes, err := ioutil.ReadAll(schemaFile)
59+
schemaBytes, err := io.ReadAll(schemaFile)
6060
if err != nil {
6161
log.Fatal(err)
6262
}

cmd/print_schema/print_schema.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"encoding/json"
55
"flag"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"log"
99
"os"
1010
"runtime"
@@ -53,7 +53,7 @@ func main() {
5353
}
5454
defer schemaFile.Close()
5555

56-
schemaBytes, err := ioutil.ReadAll(schemaFile)
56+
schemaBytes, err := io.ReadAll(schemaFile)
5757
if err != nil {
5858
log.Fatal(err)
5959
}

mapper/mapper.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ import (
1212
// to what column in the database id through field a field tag.
1313
// The tag used is "ovsdb" and has the following structure
1414
// 'ovsdb:"${COLUMN_NAME}"'
15+
//
1516
// where COLUMN_NAME is the name of the column and must match the schema
1617
//
17-
//Example:
18-
// type MyObj struct {
19-
// Name string `ovsdb:"name"`
20-
// }
18+
// Example:
19+
//
20+
// type MyObj struct {
21+
// Name string `ovsdb:"name"`
22+
// }
2123
type Mapper struct {
2224
Schema ovsdb.DatabaseSchema
2325
}

model/model.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ import (
1616
// The struct may also have non-tagged fields (which will be ignored by the API calls)
1717
// The Model interface must be implemented by the pointer to such type
1818
// Example:
19-
//type MyLogicalRouter struct {
20-
// UUID string `ovsdb:"_uuid"`
21-
// Name string `ovsdb:"name"`
22-
// ExternalIDs map[string]string `ovsdb:"external_ids"`
23-
// LoadBalancers []string `ovsdb:"load_balancer"`
24-
//}
19+
//
20+
// type MyLogicalRouter struct {
21+
// UUID string `ovsdb:"_uuid"`
22+
// Name string `ovsdb:"name"`
23+
// ExternalIDs map[string]string `ovsdb:"external_ids"`
24+
// LoadBalancers []string `ovsdb:"load_balancer"`
25+
// }
2526
type Model interface{}
2627

2728
type CloneableModel interface {

modelgen/generator.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"bytes"
55
"fmt"
66
"go/format"
7-
"io/ioutil"
87
"log"
8+
"os"
99
"text/template"
1010
)
1111

@@ -47,11 +47,11 @@ func (g *generator) Generate(filename string, tmpl *template.Template, args inte
4747
fmt.Print("\n")
4848
return nil
4949
}
50-
content, err := ioutil.ReadFile(filename)
50+
content, err := os.ReadFile(filename)
5151
if err == nil && bytes.Equal(content, src) {
5252
return nil
5353
}
54-
return ioutil.WriteFile(filename, src, 0644)
54+
return os.WriteFile(filename, src, 0644)
5555
}
5656

5757
// NewGenerator returns a new Generator

ovsdb/schema.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"encoding/json"
55
"fmt"
66
"io"
7-
"io/ioutil"
87
"math"
98
"os"
109
"strings"
@@ -48,7 +47,7 @@ func (schema DatabaseSchema) Print(w io.Writer) {
4847

4948
// SchemaFromFile returns a DatabaseSchema from a file
5049
func SchemaFromFile(f *os.File) (DatabaseSchema, error) {
51-
data, err := ioutil.ReadAll(f)
50+
data, err := io.ReadAll(f)
5251
if err != nil {
5352
return DatabaseSchema{}, err
5453
}
@@ -124,7 +123,7 @@ of this library, we define an ExtendedType that includes all possible column typ
124123
atomic fields).
125124
*/
126125

127-
//ExtendedType includes atomic types as defined in the RFC plus Enum, Map and Set
126+
// ExtendedType includes atomic types as defined in the RFC plus Enum, Map and Set
128127
type ExtendedType = string
129128

130129
// RefType is used to define the possible RefTypes

0 commit comments

Comments
 (0)