Skip to content

Commit 29f4d74

Browse files
committed
better way to ignore cancel
1 parent c6694ff commit 29f4d74

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func main() {
7777
os.Exit(1)
7878
}
7979

80-
ctx := createContext(*t)
80+
ctx, _ := createContext(*t)
8181
err = conn.WriteQuery(ctx, query, *o, loggerFn)
8282
if err != nil {
8383
fmt.Println(err)
@@ -94,14 +94,14 @@ func readQueryFromFile(path string) (*sql2csv.Query, error) {
9494
return sql2csv.NewQuery(string(f))
9595
}
9696

97-
func createContext(timeout int) context.Context {
97+
func createContext(timeout int) (context.Context, context.CancelFunc) {
9898
if timeout == 0 {
99-
return context.Background()
99+
return context.Background(), nil
100100
}
101101

102-
c, _ := context.WithTimeout(context.Background(), time.Second*time.Duration(timeout))
102+
c, cancel := context.WithTimeout(context.Background(), time.Second*time.Duration(timeout))
103103

104-
return c
104+
return c, cancel
105105
}
106106

107107
func verboseLog(logger *log.Logger, verbose bool, ln string) {

0 commit comments

Comments
 (0)