diff options
| author | Dave Henderson <dhenderson@gmail.com> | 2022-08-04 19:52:09 -0400 |
|---|---|---|
| committer | Dave Henderson <dhenderson@gmail.com> | 2022-08-04 19:54:51 -0400 |
| commit | f67ce5ac8d8bc3f47563dd6512946d8947cf412a (patch) | |
| tree | 4697b947e9d6eeec1479c29cdd661ced2dd5effb /data | |
| parent | f13bcfdd78e0e502947addb3b3f0556bbbf9edf5 (diff) | |
Fix lint errors
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'data')
| -rw-r--r-- | data/data.go | 39 | ||||
| -rw-r--r-- | data/datasource_file.go | 4 | ||||
| -rw-r--r-- | data/datasource_git.go | 9 | ||||
| -rw-r--r-- | data/datasource_git_test.go | 6 | ||||
| -rw-r--r-- | data/datasource_http.go | 4 | ||||
| -rw-r--r-- | data/datasource_stdin.go | 3 |
6 files changed, 37 insertions, 28 deletions
diff --git a/data/data.go b/data/data.go index 0c81dc54..96f82e7f 100644 --- a/data/data.go +++ b/data/data.go @@ -258,10 +258,13 @@ func autoIndex(i int) string { // CSV - Unmarshal CSV // parameters: -// delim - (optional) the (single-character!) field delimiter, defaults to "," -// in - the CSV-format string to parse +// +// delim - (optional) the (single-character!) field delimiter, defaults to "," +// in - the CSV-format string to parse +// // returns: -// an array of rows, which are arrays of cells (strings) +// +// an array of rows, which are arrays of cells (strings) func CSV(args ...string) ([][]string, error) { records, hdr, err := parseCSV(args...) if err != nil { @@ -275,13 +278,16 @@ func CSV(args ...string) ([][]string, error) { // CSVByRow - Unmarshal CSV in a row-oriented form // parameters: -// delim - (optional) the (single-character!) field delimiter, defaults to "," -// hdr - (optional) comma-separated list of column names, -// set to "" to get auto-named columns (A-Z), omit -// to use the first line -// in - the CSV-format string to parse +// +// delim - (optional) the (single-character!) field delimiter, defaults to "," +// hdr - (optional) comma-separated list of column names, +// set to "" to get auto-named columns (A-Z), omit +// to use the first line +// in - the CSV-format string to parse +// // returns: -// an array of rows, indexed by the header name +// +// an array of rows, indexed by the header name func CSVByRow(args ...string) (rows []map[string]string, err error) { records, hdr, err := parseCSV(args...) if err != nil { @@ -299,13 +305,16 @@ func CSVByRow(args ...string) (rows []map[string]string, err error) { // CSVByColumn - Unmarshal CSV in a Columnar form // parameters: -// delim - (optional) the (single-character!) field delimiter, defaults to "," -// hdr - (optional) comma-separated list of column names, -// set to "" to get auto-named columns (A-Z), omit -// to use the first line -// in - the CSV-format string to parse +// +// delim - (optional) the (single-character!) field delimiter, defaults to "," +// hdr - (optional) comma-separated list of column names, +// set to "" to get auto-named columns (A-Z), omit +// to use the first line +// in - the CSV-format string to parse +// // returns: -// a map of columns, indexed by the header name. values are arrays of strings +// +// a map of columns, indexed by the header name. values are arrays of strings func CSVByColumn(args ...string) (cols map[string][]string, err error) { records, hdr, err := parseCSV(args...) if err != nil { diff --git a/data/datasource_file.go b/data/datasource_file.go index 7619f039..e6be0440 100644 --- a/data/datasource_file.go +++ b/data/datasource_file.go @@ -4,7 +4,7 @@ import ( "bytes" "context" "encoding/json" - "io/ioutil" + "io" "net/url" "os" "path/filepath" @@ -57,7 +57,7 @@ func readFile(ctx context.Context, source *Source, args ...string) ([]byte, erro defer f.Close() - b, err := ioutil.ReadAll(f) + b, err := io.ReadAll(f) if err != nil { return nil, errors.Wrapf(err, "Can't read %s", p) } diff --git a/data/datasource_git.go b/data/datasource_git.go index c2673dd3..c5291413 100644 --- a/data/datasource_git.go +++ b/data/datasource_git.go @@ -5,7 +5,7 @@ import ( "context" "encoding/json" "fmt" - "io/ioutil" + "io" "net/url" "os" "path" @@ -136,7 +136,7 @@ func (g gitsource) parseGitPath(u *url.URL, args ...string) (out *url.URL, p str return out, p, err } -//nolint: interfacer +// nolint: interfacer func cloneURL(u *url.URL) *url.URL { out, _ := url.Parse(u.String()) return out @@ -263,7 +263,7 @@ func (g gitsource) read(fs billy.Filesystem, path string) (string, []byte, error return "", nil, fmt.Errorf("can't open %s: %w", path, err) } - b, err := ioutil.ReadAll(f) + b, err := io.ReadAll(f) if err != nil { return "", nil, fmt.Errorf("can't read %s: %w", path, err) } @@ -294,7 +294,8 @@ func (g gitsource) readDir(fs billy.Filesystem, path string) ([]byte, error) { /* auth methods: - ssh named key (no password support) - - GIT_SSH_KEY (base64-encoded) or GIT_SSH_KEY_FILE (base64-encoded, or not) + - GIT_SSH_KEY (base64-encoded) or GIT_SSH_KEY_FILE (base64-encoded, or not) + - ssh agent auth (preferred) - http basic auth (for github, gitlab, bitbucket tokens) - http token auth (bearer token, somewhat unusual) diff --git a/data/datasource_git_test.go b/data/datasource_git_test.go index 0c20c558..157e14a8 100644 --- a/data/datasource_git_test.go +++ b/data/datasource_git_test.go @@ -4,7 +4,7 @@ import ( "context" "encoding/base64" "fmt" - "io/ioutil" + "io" "net/url" "os" "strings" @@ -336,7 +336,7 @@ func TestOpenFileRepo(t *testing.T) { f, err := fs.Open("/foo/bar/hi.txt") assert.NilError(t, err) - b, _ := ioutil.ReadAll(f) + b, _ := io.ReadAll(f) assert.Equal(t, "hello world", string(b)) _, repo, err := g.clone(ctx, mustParseURL("git+file:///repo#main"), 0) @@ -375,7 +375,7 @@ func TestOpenBareFileRepo(t *testing.T) { f, err := fs.Open("/hello.txt") assert.NilError(t, err) - b, _ := ioutil.ReadAll(f) + b, _ := io.ReadAll(f) assert.Equal(t, "hello world", string(b)) } diff --git a/data/datasource_http.go b/data/datasource_http.go index 03e1ac4c..1061a3a1 100644 --- a/data/datasource_http.go +++ b/data/datasource_http.go @@ -2,7 +2,7 @@ package data import ( "context" - "io/ioutil" + "io" "mime" "net/http" "net/url" @@ -39,7 +39,7 @@ func readHTTP(ctx context.Context, source *Source, args ...string) ([]byte, erro if err != nil { return nil, err } - body, err := ioutil.ReadAll(res.Body) + body, err := io.ReadAll(res.Body) if err != nil { return nil, err } diff --git a/data/datasource_stdin.go b/data/datasource_stdin.go index b8bd0eff..4592b209 100644 --- a/data/datasource_stdin.go +++ b/data/datasource_stdin.go @@ -3,7 +3,6 @@ package data import ( "context" "io" - "io/ioutil" "os" "github.com/pkg/errors" @@ -12,7 +11,7 @@ import ( func readStdin(ctx context.Context, source *Source, args ...string) ([]byte, error) { stdin := stdinFromContext(ctx) - b, err := ioutil.ReadAll(stdin) + b, err := io.ReadAll(stdin) if err != nil { return nil, errors.Wrapf(err, "Can't read %s", stdin) } |
