Skip to content

Commit

Permalink
enable go vet with exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ModEtchFill committed Sep 14, 2023
1 parent af6bc1d commit 8dfe1f8
Show file tree
Hide file tree
Showing 20 changed files with 537 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.18
require (
github.com/go-sql-driver/mysql v1.4.1
github.com/godror/godror v0.26.3
github.com/lib/pq v1.10.3
github.com/lib/pq v1.10.9
)

require (
Expand Down
9 changes: 2 additions & 7 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@ github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5y
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/lib/pq v1.10.3 h1:v9QZf2Sn6AmjXtQeFpdoq/eaNtYP6IN+7lcrygsIAtg=
github.com/lib/pq v1.10.3 h1:v9QZf2Sn6AmjXtQeFpdoq/eaNtYP6IN+7lcrygsIAtg=
github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.3/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw=
github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
60 changes: 60 additions & 0 deletions govet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

# rebuilds are for developing this script
if [ x$1 = xrebuild ]
then
find . -name 'vet.log*' | xargs /bin/rm
fi

out=0
# find directories with go source files
for e in `find . -name '*.go' |sed -e 's,/[^/]*$,,'|sort -u`
do
(
d=`echo $e | sed -e 's,^..,,'`
cd $d
go vet -c=3 github.com/paypal/hera/$d 2> vet.log3
rv=$?
if [ $rv -ne 0 ]
then
# remove line numbers
sed -e 's/^[0-9]*//;s/[.]go:[0-9]*:[0-9]*: /.go /' vet.log3 > vet.log2

# save the go vet output if we are rebuilding
if [ x$1 = xrebuild -a ! -e vet.log ]
then
cp vet.log{2,}
fi

# diff go vet output against dev commit vet.log
if [ ! -e vet.log ]
then
cat vet.log2
rvd=2
else
diff vet.log{,2}
rvd=$?
fi
if [ $rvd -ne 0 ]
then
echo $rvd rv-vet-diff $d
exit $rvd
fi
fi
)
subRv=$?
if [ $subRv -ne 0 ]
then
out=$subRv
fi
done

if [ x$1 = xrebuild ]
then
time ./govet.sh
out=$?
echo `date` "second pass complete for rebuild"
fi

echo $out overall go vet rv
exit $out
33 changes: 33 additions & 0 deletions tests/functionaltest/bind_eviction_tests/inclause_evict/vet.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# github.com/paypal/hera/tests/functionaltest/bind_eviction_tests/inclause_evict
./main_test_disable.go the cancel function is not used on all paths (possible context leak)
db.SetMaxIdleConns(0)
defer db.Close()

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
conn, err := db.Conn(ctx)
if err != nil {
return err
./main_test_disable.go this return statement may be reached without using the cancel var defined on line 66
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
conn, err := db.Conn(ctx)
if err != nil {
return err
}
defer conn.Close()
defer cancel()
./main_test_disable.go the cancel function is not used on all paths (possible context leak)
db.SetMaxIdleConns(0)
defer db.Close()

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
conn, err := db.Conn(ctx)
if err != nil {
return err
./main_test_disable.go this return statement may be reached without using the cancel var defined on line 107
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
conn, err := db.Conn(ctx)
if err != nil {
return err
}
defer conn.Close()
defer cancel()
33 changes: 33 additions & 0 deletions tests/functionaltest/bind_eviction_tests/simple_evict/vet.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# github.com/paypal/hera/tests/functionaltest/bind_eviction_tests/simple_evict
./main_test_disable.go the cancel function is not used on all paths (possible context leak)
db.SetMaxIdleConns(0)
defer db.Close()

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
conn, err := db.Conn(ctx)
if err != nil {
return err
./main_test_disable.go this return statement may be reached without using the cancel var defined on line 66
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
conn, err := db.Conn(ctx)
if err != nil {
return err
}

defer conn.Close()
./main_test_disable.go the cancel function is not used on all paths (possible context leak)
db.SetMaxIdleConns(0)
defer db.Close()

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
conn, err := db.Conn(ctx)
if err != nil {
return err
./main_test_disable.go this return statement may be reached without using the cancel var defined on line 112
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
conn, err := db.Conn(ctx)
if err != nil {
return err
}
defer conn.Close()
// cancel must be called before conn.Close()
49 changes: 49 additions & 0 deletions tests/functionaltest/bind_eviction_tests/util/vet.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# github.com/paypal/hera/tests/functionaltest/bind_eviction_tests/util
./dbops.go the cancel function is not used on all paths (possible context leak)
db.SetMaxIdleConns(0)
defer db.Close()

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
conn, err := db.Conn(ctx)
if err != nil {
return err
./dbops.go this return statement may be reached without using the cancel var defined on line 37
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
conn, err := db.Conn(ctx)
if err != nil {
return err
}
defer conn.Close()
defer cancel()
./dbops.go the cancel function is not used on all paths (possible context leak)
db.SetMaxIdleConns(0)
defer db.Close()

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
conn, err := db.Conn(ctx)
if err != nil {
return err
./dbops.go this return statement may be reached without using the cancel var defined on line 84
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
conn, err := db.Conn(ctx)
if err != nil {
return err
}
defer conn.Close()
defer cancel()
./dbops.go the cancel function is not used on all paths (possible context leak)
db.SetMaxIdleConns(0)
defer db.Close()

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
conn, err := db.Conn(ctx)
if err != nil {
fmt.Println("Error creating context:", err)
./dbops.go this return statement may be reached without using the cancel var defined on line 139
conn, err := db.Conn(ctx)
if err != nil {
fmt.Println("Error creating context:", err)
return count
}
defer conn.Close()
defer cancel()
Loading

0 comments on commit 8dfe1f8

Please sign in to comment.