This is an automated email from the ASF dual-hosted git repository.

zeroshade pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git


The following commit(s) were added to refs/heads/master by this push:
     new 7929cc8  ARROW-15245: [Go] Address most of the staticcheck linting 
issues.
7929cc8 is described below

commit 7929cc803b093d082a5b8e52edb593807693a6d5
Author: Matthew Topol <[email protected]>
AuthorDate: Thu Jan 6 14:51:04 2022 -0500

    ARROW-15245: [Go] Address most of the staticcheck linting issues.
    
    Closes #12074 from zeroshade/arrow-15245-staticcheck
    
    Lead-authored-by: Matthew Topol <[email protected]>
    Co-authored-by: Matt Topol <[email protected]>
    Signed-off-by: Matthew Topol <[email protected]>
---
 go/arrow/array/compare.go                 |  2 --
 go/arrow/array/fixed_size_list.go         |  5 ----
 go/arrow/array/list.go                    |  5 ----
 go/arrow/array/record_test.go             | 39 ++++++++++++++++---------------
 go/arrow/array/struct.go                  |  5 ----
 go/arrow/arrio/arrio_test.go              |  2 --
 go/arrow/csv/reader.go                    |  2 +-
 go/arrow/flight/basic_auth_flight_test.go |  4 ++--
 go/arrow/ipc/dict_test.go                 |  4 ++--
 9 files changed, 25 insertions(+), 43 deletions(-)

diff --git a/go/arrow/array/compare.go b/go/arrow/array/compare.go
index fc2bb61..cce2914 100644
--- a/go/arrow/array/compare.go
+++ b/go/arrow/array/compare.go
@@ -513,8 +513,6 @@ func arrayApproxEqual(left, right Interface, opt 
equalOption) bool {
        default:
                panic(xerrors.Errorf("arrow/array: unknown array type %T", l))
        }
-
-       return false
 }
 
 func baseArrayEqual(left, right Interface) bool {
diff --git a/go/arrow/array/fixed_size_list.go 
b/go/arrow/array/fixed_size_list.go
index acef33c..a62ada2 100644
--- a/go/arrow/array/fixed_size_list.go
+++ b/go/arrow/array/fixed_size_list.go
@@ -201,11 +201,6 @@ func (b *FixedSizeListBuilder) AppendValues(valid []bool) {
        b.builder.unsafeAppendBoolsToBitmap(valid, len(valid))
 }
 
-func (b *FixedSizeListBuilder) unsafeAppend(v bool) {
-       bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
-       b.length++
-}
-
 func (b *FixedSizeListBuilder) unsafeAppendBoolToBitmap(isValid bool) {
        if isValid {
                bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
diff --git a/go/arrow/array/list.go b/go/arrow/array/list.go
index 9ebc0a4..54089f3 100644
--- a/go/arrow/array/list.go
+++ b/go/arrow/array/list.go
@@ -203,11 +203,6 @@ func (b *ListBuilder) AppendValues(offsets []int32, valid 
[]bool) {
        b.builder.unsafeAppendBoolsToBitmap(valid, len(valid))
 }
 
-func (b *ListBuilder) unsafeAppend(v bool) {
-       bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
-       b.length++
-}
-
 func (b *ListBuilder) unsafeAppendBoolToBitmap(isValid bool) {
        if isValid {
                bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
diff --git a/go/arrow/array/record_test.go b/go/arrow/array/record_test.go
index 56b831b..7b61e1a 100644
--- a/go/arrow/array/record_test.go
+++ b/go/arrow/array/record_test.go
@@ -24,6 +24,7 @@ import (
        "github.com/apache/arrow/go/v7/arrow"
        "github.com/apache/arrow/go/v7/arrow/array"
        "github.com/apache/arrow/go/v7/arrow/memory"
+       "github.com/stretchr/testify/assert"
 )
 
 func TestRecord(t *testing.T) {
@@ -32,8 +33,8 @@ func TestRecord(t *testing.T) {
 
        schema := arrow.NewSchema(
                []arrow.Field{
-                       arrow.Field{Name: "f1-i32", Type: 
arrow.PrimitiveTypes.Int32},
-                       arrow.Field{Name: "f2-f64", Type: 
arrow.PrimitiveTypes.Float64},
+                       {Name: "f1-i32", Type: arrow.PrimitiveTypes.Int32},
+                       {Name: "f2-f64", Type: arrow.PrimitiveTypes.Float64},
                },
                nil,
        )
@@ -146,7 +147,7 @@ func TestRecord(t *testing.T) {
                {
                        schema: arrow.NewSchema(
                                []arrow.Field{
-                                       arrow.Field{Name: "f1-i32", Type: 
arrow.PrimitiveTypes.Int32},
+                                       {Name: "f1-i32", Type: 
arrow.PrimitiveTypes.Int32},
                                },
                                nil,
                        ),
@@ -157,8 +158,8 @@ func TestRecord(t *testing.T) {
                {
                        schema: arrow.NewSchema(
                                []arrow.Field{
-                                       arrow.Field{Name: "f1-i32", Type: 
arrow.PrimitiveTypes.Int32},
-                                       arrow.Field{Name: "f2-f64", Type: 
arrow.PrimitiveTypes.Int32},
+                                       {Name: "f1-i32", Type: 
arrow.PrimitiveTypes.Int32},
+                                       {Name: "f2-f64", Type: 
arrow.PrimitiveTypes.Int32},
                                },
                                nil,
                        ),
@@ -227,8 +228,8 @@ func TestRecordReader(t *testing.T) {
 
        schema := arrow.NewSchema(
                []arrow.Field{
-                       arrow.Field{Name: "f1-i32", Type: 
arrow.PrimitiveTypes.Int32},
-                       arrow.Field{Name: "f2-f64", Type: 
arrow.PrimitiveTypes.Float64},
+                       {Name: "f1-i32", Type: arrow.PrimitiveTypes.Int32},
+                       {Name: "f2-f64", Type: arrow.PrimitiveTypes.Float64},
                },
                nil,
        )
@@ -315,8 +316,8 @@ func TestRecordReader(t *testing.T) {
                        name: "mismatch-name",
                        schema: arrow.NewSchema(
                                []arrow.Field{
-                                       arrow.Field{Name: "f1-i32", Type: 
arrow.PrimitiveTypes.Int32},
-                                       arrow.Field{Name: "f2-XXX", Type: 
arrow.PrimitiveTypes.Float64},
+                                       {Name: "f1-i32", Type: 
arrow.PrimitiveTypes.Int32},
+                                       {Name: "f2-XXX", Type: 
arrow.PrimitiveTypes.Float64},
                                },
                                nil,
                        ),
@@ -326,8 +327,8 @@ func TestRecordReader(t *testing.T) {
                        name: "mismatch-type",
                        schema: arrow.NewSchema(
                                []arrow.Field{
-                                       arrow.Field{Name: "f1-i32", Type: 
arrow.PrimitiveTypes.Int32},
-                                       arrow.Field{Name: "f2-f64", Type: 
arrow.PrimitiveTypes.Int64},
+                                       {Name: "f1-i32", Type: 
arrow.PrimitiveTypes.Int32},
+                                       {Name: "f2-f64", Type: 
arrow.PrimitiveTypes.Int64},
                                },
                                nil,
                        ),
@@ -342,7 +343,7 @@ func TestRecordReader(t *testing.T) {
                        if err == nil {
                                t.Fatalf("expected an error: %v", tc.err)
                        }
-                       if !reflect.DeepEqual(tc.err, err) {
+                       if !assert.Equal(t, tc.err, err) {
                                t.Fatalf("invalid error: got=%v, want=%v", err, 
tc.err)
                        }
                })
@@ -355,8 +356,8 @@ func TestRecordBuilder(t *testing.T) {
 
        schema := arrow.NewSchema(
                []arrow.Field{
-                       arrow.Field{Name: "f1-i32", Type: 
arrow.PrimitiveTypes.Int32},
-                       arrow.Field{Name: "f2-f64", Type: 
arrow.PrimitiveTypes.Float64},
+                       {Name: "f1-i32", Type: arrow.PrimitiveTypes.Int32},
+                       {Name: "f2-f64", Type: arrow.PrimitiveTypes.Float64},
                },
                nil,
        )
@@ -454,13 +455,13 @@ func (m *testMessageBar) GetD() []uint64 {
 
 var testMessageSchema = arrow.NewSchema(
        []arrow.Field{
-               arrow.Field{Name: "foo", Type: arrow.StructOf(
+               {Name: "foo", Type: arrow.StructOf(
                        arrow.Field{Name: "a", Type: 
arrow.PrimitiveTypes.Int32},
                        arrow.Field{Name: "b", Type: arrow.ListOf(
                                arrow.PrimitiveTypes.Uint32,
                        )},
                )},
-               arrow.Field{Name: "bars", Type: arrow.ListOf(
+               {Name: "bars", Type: arrow.ListOf(
                        arrow.StructOf(
                                arrow.Field{Name: "c", Type: 
arrow.PrimitiveTypes.Int64},
                                arrow.Field{Name: "d", Type: arrow.ListOf(
@@ -677,16 +678,16 @@ func TestRecordBuilderMessages(t *testing.T) {
                                B: []uint32{2, 3, 4, 5, 6, 7, 8, 9},
                        },
                        Bars: []*testMessageBar{
-                               &testMessageBar{
+                               {
                                        C: 11,
                                        D: []uint64{12, 13, 14},
                                },
-                               &testMessageBar{
+                               {
                                        C: 15,
                                        D: []uint64{16, 17, 18, 19},
                                },
                                nil,
-                               &testMessageBar{
+                               {
                                        C: 20,
                                        D: []uint64{21},
                                },
diff --git a/go/arrow/array/struct.go b/go/arrow/array/struct.go
index 36d1058..7256529 100644
--- a/go/arrow/array/struct.go
+++ b/go/arrow/array/struct.go
@@ -215,11 +215,6 @@ func (b *StructBuilder) AppendValues(valids []bool) {
 
 func (b *StructBuilder) AppendNull() { b.Append(false) }
 
-func (b *StructBuilder) unsafeAppend(v bool) {
-       bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
-       b.length++
-}
-
 func (b *StructBuilder) unsafeAppendBoolToBitmap(isValid bool) {
        if isValid {
                bitutil.SetBit(b.nullBitmap.Bytes(), b.length)
diff --git a/go/arrow/arrio/arrio_test.go b/go/arrow/arrio/arrio_test.go
index 5f7c585..20ffa55 100644
--- a/go/arrow/arrio/arrio_test.go
+++ b/go/arrow/arrio/arrio_test.go
@@ -65,8 +65,6 @@ func (k copyKind) check(t *testing.T, f *os.File, mem 
memory.Allocator, schema *
 }
 
 func TestCopy(t *testing.T) {
-       type kind int
-
        tempDir, err := ioutil.TempDir("", "go-arrow-copy-")
        if err != nil {
                t.Fatal(err)
diff --git a/go/arrow/csv/reader.go b/go/arrow/csv/reader.go
index fee5f4e..eea3ee7 100644
--- a/go/arrow/csv/reader.go
+++ b/go/arrow/csv/reader.go
@@ -340,7 +340,7 @@ func (r *Reader) parseBool(field array.Builder, str string) 
{
        case "true", "True", "1":
                v = true
        default:
-               r.err = fmt.Errorf("Unrecognized boolean: %s", str)
+               r.err = fmt.Errorf("unrecognized boolean: %s", str)
                field.AppendNull()
                return
        }
diff --git a/go/arrow/flight/basic_auth_flight_test.go 
b/go/arrow/flight/basic_auth_flight_test.go
index b5eb0b8..ecad4b1 100644
--- a/go/arrow/flight/basic_auth_flight_test.go
+++ b/go/arrow/flight/basic_auth_flight_test.go
@@ -189,7 +189,7 @@ func TestBasicAuthHelpers(t *testing.T) {
                t.Fatal(err)
        }
 
-       if "foobar" != string(info.Schema) {
+       if string(info.Schema) != "foobar" {
                t.Fatal("should have received 'foobar'")
        }
 
@@ -198,7 +198,7 @@ func TestBasicAuthHelpers(t *testing.T) {
                t.Fatal(err)
        }
 
-       if "carebears" != string(sc.Schema) {
+       if string(sc.Schema) != "carebears" {
                t.Fatal("should have received carebears")
        }
 }
diff --git a/go/arrow/ipc/dict_test.go b/go/arrow/ipc/dict_test.go
index 1433fe4..8e1b389 100644
--- a/go/arrow/ipc/dict_test.go
+++ b/go/arrow/ipc/dict_test.go
@@ -109,11 +109,11 @@ func TestDictMemo(t *testing.T) {
                t.Fatalf("expected fo find id=0 array")
        }
 
-       v, ok = memo.Dict(2)
+       _, ok = memo.Dict(2)
        if ok {
                t.Fatalf("should not have found id=2")
        }
-       v, ok = memo.Dict(-2)
+       _, ok = memo.Dict(-2)
        if ok {
                t.Fatalf("should not have found id=-2")
        }

Reply via email to