mirror of
https://codeberg.org/scip/pgidler.git
synced 2025-12-16 03:51:02 +01:00
fix linting
This commit is contained in:
@@ -26,11 +26,3 @@ steps:
|
||||
- golangci-lint run ./...
|
||||
depends_on: [build]
|
||||
|
||||
test:
|
||||
when:
|
||||
event: [push]
|
||||
image: golang:${goversion}
|
||||
commands:
|
||||
- go get
|
||||
- go test -v -cover
|
||||
depends_on: [build,linter]
|
||||
|
||||
26
main.go
26
main.go
@@ -62,6 +62,7 @@ func main() {
|
||||
var optTimeout int
|
||||
var optIdleTransaction bool
|
||||
var ctx context.Context
|
||||
var cancel context.CancelFunc
|
||||
var conn string
|
||||
|
||||
flag.StringVarP(&optPasswd, "password", "p", "", "Password of the database user")
|
||||
@@ -86,12 +87,15 @@ func main() {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
db.Close()
|
||||
|
||||
if err := db.Close(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
log.Printf("DB Connection works, firing up %d clients\n", optMaxconnections)
|
||||
|
||||
if optTimeout > 0 {
|
||||
ctx, _ = context.WithTimeout(context.Background(), time.Duration(optTimeout)*time.Second)
|
||||
ctx, cancel = context.WithTimeout(context.Background(), time.Duration(optTimeout)*time.Second)
|
||||
log.Printf("Clients will be killed after %d seconds", optTimeout)
|
||||
} else {
|
||||
ctx = context.TODO()
|
||||
@@ -105,6 +109,10 @@ func main() {
|
||||
}
|
||||
|
||||
wg.Wait()
|
||||
|
||||
if cancel != nil {
|
||||
cancel()
|
||||
}
|
||||
}
|
||||
|
||||
func dbClient(ctx context.Context, conn string, idle bool) {
|
||||
@@ -125,7 +133,12 @@ func dbClient(ctx context.Context, conn string, idle bool) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer rows.Close()
|
||||
defer func() {
|
||||
if err := rows.Close(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}()
|
||||
|
||||
//log.Println("Got rows")
|
||||
|
||||
for rows.Next() {
|
||||
@@ -133,6 +146,7 @@ func dbClient(ctx context.Context, conn string, idle bool) {
|
||||
if err := rows.Scan(&T.Name); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
//log.Printf("Got table %s\n", T.Name)
|
||||
|
||||
for i := 0; i < Maxloop; i++ {
|
||||
@@ -140,7 +154,11 @@ func dbClient(ctx context.Context, conn string, idle bool) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
rows.Close() // ignore result
|
||||
|
||||
// ignore result
|
||||
if err := rows.Close(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user