Skip to content

Commit 4f3acc5

Browse files
committed
refactor: fix all linter errors
Signed-off-by: Christian Stewart <christian@aperture.us>
1 parent d89cd18 commit 4f3acc5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+137
-248
lines changed

client/client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func New(addr string) *Client {
1515
}
1616

1717
// Client is a struct used for communicating with a Cayley server through HTTP
18-
// Deprecated: Client exists for backwards compatability. New code should use
18+
// Deprecated: Client exists for backwards compatibility. New code should use
1919
// the updated client github.com/cayleygraph/go-client
2020
type Client struct {
2121
addr string
@@ -68,7 +68,7 @@ type funcCloser struct {
6868
closed bool
6969
}
7070

71-
func (c funcCloser) Close() error {
71+
func (c *funcCloser) Close() error {
7272
if c.closed {
7373
return nil
7474
}
@@ -102,7 +102,7 @@ func (c *Client) QuadWriter() (quad.WriteCloser, error) {
102102
Full: false,
103103
Strict: false,
104104
})
105-
qw.SetCloser(funcCloser{f: func() error {
105+
qw.SetCloser(&funcCloser{f: func() error {
106106
pw.Close()
107107
return <-errc
108108
}})

clog/clog.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,6 @@ var logger Logger = &stdlog{
3434
// SetLogger set the clog logging implementation.
3535
func SetLogger(l Logger) { logger = l }
3636

37-
var verbosity int
38-
3937
// V returns whether the current clog verbosity is above the specified level.
4038
func V(level int) bool {
4139
if logger == nil {

cmd/cayley/command/health.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func NewHealthCmd() *cobra.Command {
1717
Short: "Health check HTTP server",
1818
RunE: func(cmd *cobra.Command, args []string) error {
1919
if len(args) > 1 {
20-
return fmt.Errorf("Too many arguments provided, expected 0 or 1")
20+
return fmt.Errorf("too many arguments provided, expected 0 or 1")
2121
}
2222
address := defaultAddress
2323
if len(args) == 1 {

cmd/cayley/command/repl.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"context"
55
"encoding/json"
66
"fmt"
7-
"io/ioutil"
7+
"io"
88
"os"
99
"os/signal"
1010
"strings"
@@ -81,9 +81,9 @@ func NewQueryCmd() *cobra.Command {
8181
RunE: func(cmd *cobra.Command, args []string) error {
8282
var querystr string
8383
if len(args) == 0 {
84-
bytes, err := ioutil.ReadAll(os.Stdin)
84+
bytes, err := io.ReadAll(os.Stdin)
8585
if err != nil {
86-
return fmt.Errorf("error occured while reading from stdin : %s", err)
86+
return fmt.Errorf("error occurred while reading from stdin : %s", err)
8787
}
8888
querystr = string(bytes)
8989
} else if len(args) == 1 {

cmd/cayleyimport/cayleyimport.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"errors"
66
"fmt"
77
"io"
8-
"io/ioutil"
98
"net/http"
109
"os"
1110
"path/filepath"
@@ -43,7 +42,7 @@ func NewCmd() *cobra.Command {
4342
if len(args) == 0 {
4443
in := cmd.InOrStdin()
4544
if !hasIn(in) {
46-
return errors.New("Either provide file to read from or pipe data")
45+
return errors.New("either provide file to read from or pipe data")
4746
}
4847
reader = in
4948
} else {
@@ -69,11 +68,12 @@ func NewCmd() *cobra.Command {
6968
return err
7069
}
7170
defer r.Body.Close()
72-
body, err := ioutil.ReadAll(r.Body)
71+
body, err := io.ReadAll(r.Body)
7372
if err != nil {
7473
return err
7574
}
76-
if r.StatusCode == http.StatusOK {
75+
switch r.StatusCode {
76+
case http.StatusOK:
7777
var response struct {
7878
Result string `json:"result"`
7979
Count string `json:"count"`
@@ -86,8 +86,8 @@ func NewCmd() *cobra.Command {
8686
if !quiet {
8787
fmt.Println(response.Result)
8888
}
89-
} else if r.StatusCode == http.StatusNotFound {
90-
return errors.New("Database instance does not support write")
89+
case http.StatusNotFound:
90+
return errors.New("database instance does not support write")
9191
}
9292
return nil
9393
},

cmd/download_ui/download_ui.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func DownloadFile(filepath string, url string) error {
4949
defer resp.Body.Close()
5050

5151
if resp.StatusCode != 200 {
52-
return fmt.Errorf("Received %v status code instead of 200 for %v", resp.Status, url)
52+
return fmt.Errorf("received %v status code instead of 200 for %v", resp.Status, url)
5353
}
5454

5555
// Create the file

deps.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build deps_only
2-
// +build deps_only
32

43
package cayley
54

examples/hello_bolt/main.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
76
"log"
87
"os"
98

@@ -15,7 +14,7 @@ import (
1514

1615
func main() {
1716
// File for your new BoltDB. Use path to regular file and not temporary in the real world
18-
tmpdir, err := ioutil.TempDir("", "example")
17+
tmpdir, err := os.MkdirTemp("", "example")
1918
if err != nil {
2019
log.Fatal(err)
2120
}

examples/hello_schema/main.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package main
33
import (
44
"context"
55
"fmt"
6-
"io/ioutil"
76
"log"
87
"math/rand"
98
"os"
@@ -22,10 +21,10 @@ import (
2221
type Person struct {
2322
// dummy field to enforce all object to have a <id> <rdf:type> <ex:Person> relation
2423
// means nothing for Go itself
25-
rdfType struct{} `quad:"@type > ex:Person"`
26-
ID quad.IRI `json:"@id"` // tag @id is a special one - graph node value will be stored in this field
27-
Name string `json:"ex:name"` // field name (predicate) may be written as json field name
28-
Age int `quad:"ex:age"` // or in a quad tag
24+
_ struct{} `quad:"@type > ex:Person"`
25+
ID quad.IRI `json:"@id"` // tag @id is a special one - graph node value will be stored in this field
26+
Name string `json:"ex:name"` // field name (predicate) may be written as json field name
27+
Age int `quad:"ex:age"` // or in a quad tag
2928
}
3029

3130
type Coords struct {
@@ -57,7 +56,7 @@ func main() {
5756
}
5857

5958
// File for your new BoltDB. Use path to regular file and not temporary in the real world
60-
tmpdir, err := ioutil.TempDir("", "example")
59+
tmpdir, err := os.MkdirTemp("", "example")
6160
checkErr(err)
6261

6362
defer os.RemoveAll(tmpdir) // clean up

graph/all/all_cgo.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build cgo
2-
// +build cgo
32

43
package all
54

0 commit comments

Comments
 (0)