Skip to content

Commit

Permalink
apacheGH-41887: [Go] Run linter via pre-commit (apache#41888)
Browse files Browse the repository at this point in the history
### Rationale for this change
Add and run pre-commit 

### What changes are included in this PR?
Update pre-commit file
Run pre-commit

### Are these changes tested?
N/A

### Are there any user-facing changes?
No

GitHub Issue: apache#41887
* GitHub Issue: apache#41887

Lead-authored-by: Tom Scott-Coombes <[email protected]>
Co-authored-by: Tom Scott-Coombes <[email protected]>
Co-authored-by: Sutou Kouhei <[email protected]>
Signed-off-by: Matt Topol <[email protected]>
  • Loading branch information
tscottcoombes1 and kou authored Jun 3, 2024
1 parent 54bece3 commit 99014ab
Show file tree
Hide file tree
Showing 111 changed files with 11,252 additions and 9,616 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,9 @@ __debug_bin
.envrc

# Develocity
.mvn/.gradle-enterprise/
.mvn/.develocity/

# rat
filtered_rat.txt
rat.txt
29 changes: 29 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

linters:
# Disable all linters.
# Default: false
disable-all: true
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- gofmt
- goimports

issues:
fix: true
14 changes: 14 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,17 @@ repos:
'--disable',
'dangling-hyphen,line-too-long',
]
- repo: https://github.com/golangci/golangci-lint
rev: v1.59.0
hooks:
# no built-in support for multiple go.mod
# https://github.com/golangci/golangci-lint/issues/828
- id: golangci-lint-full
name: golangci-lint-full-arrow
entry: bash -c 'cd go/arrow && golangci-lint run'
- id: golangci-lint-full
name: golangci-lint-full-parquet
entry: bash -c 'cd go/parquet && golangci-lint run'
- id: golangci-lint-full
name: golangci-lint-full-internal
entry: bash -c 'cd go/internal && golangci-lint run'
2 changes: 1 addition & 1 deletion go/arrow/array/bufferbuilder_numeric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"testing"
"unsafe"

"github.com/apache/arrow/go/v17/arrow/memory"
"github.com/apache/arrow/go/v17/arrow/endian"
"github.com/apache/arrow/go/v17/arrow/memory"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion go/arrow/array/numeric.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 5 additions & 7 deletions go/arrow/array/numeric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package array_test

import (
import (
"math"
"reflect"
"testing"
Expand Down Expand Up @@ -144,7 +144,7 @@ func TestFloat16MarshalJSON(t *testing.T) {

bldr := array.NewFloat16Builder(pool)
defer bldr.Release()

jsonstr := `[0, 1, 2, 3, "NaN", "NaN", 4, 5, "+Inf", "-Inf"]`

bldr.Append(float16.New(0))
Expand All @@ -158,7 +158,6 @@ func TestFloat16MarshalJSON(t *testing.T) {
bldr.Append(float16.Inf())
bldr.Append(float16.Inf().Negate())


expected := bldr.NewFloat16Array()
defer expected.Release()
expected_json, err := expected.MarshalJSON()
Expand All @@ -172,7 +171,7 @@ func TestFloat32MarshalJSON(t *testing.T) {

bldr := array.NewFloat32Builder(pool)
defer bldr.Release()

jsonstr := `[0, 1, "+Inf", 2, 3, "NaN", "NaN", 4, 5, "-Inf"]`

bldr.Append(0)
Expand All @@ -186,10 +185,9 @@ func TestFloat32MarshalJSON(t *testing.T) {
bldr.Append(5)
bldr.Append(float32(math.Inf(-1)))


expected := bldr.NewFloat32Array()
defer expected.Release()

expected_json, err := expected.MarshalJSON()
assert.NoError(t, err)

Expand Down Expand Up @@ -223,7 +221,7 @@ func TestFloat64MarshalJSON(t *testing.T) {
assert.NoError(t, err)

assert.JSONEq(t, jsonstr, string(expected_json))

}

func TestUnmarshalSpecialFloat(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions go/arrow/array/numericbuilder.gen_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/arrow/array/record_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func TestRecord(t *testing.T) {
if _, err := rec.SetColumn(0, col2_1); err == nil {
t.Fatalf("expected an error")
}
newRec, err := rec.SetColumn(1, col2_1);
newRec, err := rec.SetColumn(1, col2_1)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
Expand Down
16 changes: 8 additions & 8 deletions go/arrow/datatype_nested_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ func TestStructOf(t *testing.T) {
fields: []Field{{Name: "f1", Type: PrimitiveTypes.Int32}},
want: &StructType{
fields: []Field{{Name: "f1", Type: PrimitiveTypes.Int32}},
index: map[string][]int{"f1": []int{0}},
index: map[string][]int{"f1": {0}},
},
},
{
fields: []Field{{Name: "f1", Type: PrimitiveTypes.Int32, Nullable: true}},
want: &StructType{
fields: []Field{{Name: "f1", Type: PrimitiveTypes.Int32, Nullable: true}},
index: map[string][]int{"f1": []int{0}},
index: map[string][]int{"f1": {0}},
},
},
{
Expand All @@ -114,7 +114,7 @@ func TestStructOf(t *testing.T) {
{Name: "f1", Type: PrimitiveTypes.Int32},
{Name: "", Type: PrimitiveTypes.Int64},
},
index: map[string][]int{"f1": []int{0}, "": []int{1}},
index: map[string][]int{"f1": {0}, "": {1}},
},
},
{
Expand All @@ -127,7 +127,7 @@ func TestStructOf(t *testing.T) {
{Name: "f1", Type: PrimitiveTypes.Int32},
{Name: "f2", Type: PrimitiveTypes.Int64},
},
index: map[string][]int{"f1": []int{0}, "f2": []int{1}},
index: map[string][]int{"f1": {0}, "f2": {1}},
},
},
{
Expand All @@ -142,7 +142,7 @@ func TestStructOf(t *testing.T) {
{Name: "f2", Type: PrimitiveTypes.Int64},
{Name: "f3", Type: ListOf(PrimitiveTypes.Float64)},
},
index: map[string][]int{"f1": []int{0}, "f2": []int{1}, "f3": []int{2}},
index: map[string][]int{"f1": {0}, "f2": {1}, "f3": {2}},
},
},
{
Expand All @@ -157,7 +157,7 @@ func TestStructOf(t *testing.T) {
{Name: "f2", Type: PrimitiveTypes.Int64},
{Name: "f3", Type: ListOf(ListOf(PrimitiveTypes.Float64))},
},
index: map[string][]int{"f1": []int{0}, "f2": []int{1}, "f3": []int{2}},
index: map[string][]int{"f1": {0}, "f2": {1}, "f3": {2}},
},
},
{
Expand All @@ -172,7 +172,7 @@ func TestStructOf(t *testing.T) {
{Name: "f2", Type: PrimitiveTypes.Int64},
{Name: "f3", Type: ListOf(ListOf(StructOf(Field{Name: "f1", Type: PrimitiveTypes.Float64})))},
},
index: map[string][]int{"f1": []int{0}, "f2": []int{1}, "f3": []int{2}},
index: map[string][]int{"f1": {0}, "f2": {1}, "f3": {2}},
},
},
{
Expand All @@ -187,7 +187,7 @@ func TestStructOf(t *testing.T) {
{Name: "f2", Type: PrimitiveTypes.Int64},
{Name: "f1", Type: PrimitiveTypes.Int64},
},
index: map[string][]int{"f1": []int{0, 2}, "f2": []int{1}},
index: map[string][]int{"f1": {0, 2}, "f2": {1}},
},
},
} {
Expand Down
5 changes: 3 additions & 2 deletions go/arrow/flight/gen/flight/Flight.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions go/arrow/flight/gen/flight/FlightSql.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions go/arrow/flight/gen/flight/Flight_grpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/arrow/float16/float16.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func (n Num) Signbit() bool { return (n.bits & 0x8000) != 0 }

func (n Num) IsNaN() bool { return (n.bits & 0x7fff) > 0x7c00 }

func (n Num) IsInf() bool {return (n.bits & 0x7c00) == 0x7c00 }
func (n Num) IsInf() bool { return (n.bits & 0x7c00) == 0x7c00 }

func (n Num) IsZero() bool { return (n.bits & 0x7fff) == 0 }

Expand Down
1 change: 1 addition & 0 deletions go/arrow/gen-flatbuffers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build ignore
// +build ignore

package main
Expand Down
1 change: 1 addition & 0 deletions go/arrow/internal/debug/assert_off.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !assert
// +build !assert

package debug
Expand Down
1 change: 1 addition & 0 deletions go/arrow/internal/debug/assert_on.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build assert
// +build assert

package debug
Expand Down
6 changes: 2 additions & 4 deletions go/arrow/internal/debug/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
/*
Package debug provides APIs for conditional runtime assertions and debug logging.
Using Assert
# Using Assert
To enable runtime assertions, build with the assert tag. When the assert tag is omitted,
the code for the assertion will be omitted from the binary.
Using Log
# Using Log
To enable runtime debug logs, build with the debug tag. When the debug tag is omitted,
the code for logging will be omitted from the binary.
Expand Down
1 change: 1 addition & 0 deletions go/arrow/internal/debug/log_off.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build !debug
// +build !debug

package debug
Expand Down
1 change: 1 addition & 0 deletions go/arrow/internal/debug/log_on.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build debug
// +build debug

package debug
Expand Down
1 change: 1 addition & 0 deletions go/arrow/internal/debug/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

//go:build debug || assert
// +build debug assert

package debug
Expand Down
2 changes: 1 addition & 1 deletion go/arrow/internal/flatbuf/Binary.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions go/arrow/internal/flatbuf/BinaryView.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 99014ab

Please sign in to comment.