Skip to content

Commit 0e8ef7d

Browse files
authored
fix(client): Go 1.19 compatibility (#30)
1 parent a1d913f commit 0e8ef7d

File tree

14 files changed

+132
-73
lines changed

14 files changed

+132
-73
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
go-version: [1.20.x]
9+
go-version: [1.19.x, 1.20.x]
1010
name: Build with Go ${{ matrix.go-version }}
1111
steps:
1212
- name: Checkout repository

README.md

+46
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ Golang client for QuestDB's [Influx Line Protocol](https://questdb.io/docs/refer
66
(ILP) over HTTP and TCP. This library makes it easy to insert data into
77
[QuestDB](https://questdb.io).
88

9+
The library requires Go 1.19 or newer.
10+
911
Features:
1012
* Context-aware API.
1113
* Optimized for batch writes.
@@ -73,6 +75,50 @@ To connect via TCP, set the configuration string to:
7375
// ...
7476
```
7577

78+
## Migration from v2
79+
80+
v2 code example:
81+
```go
82+
package main
83+
84+
import (
85+
"context"
86+
87+
qdb "github.com/questdb/go-questdb-client/v2"
88+
)
89+
90+
func main() {
91+
// Connect to QuestDB running on 127.0.0.1:9009 (ILP/TCP)
92+
sender, err := qdb.NewLineSender(context.TODO())
93+
// ...
94+
defer sender.Close()
95+
// ...
96+
}
97+
```
98+
99+
Migrated v3 code:
100+
```go
101+
package main
102+
103+
import (
104+
"context"
105+
106+
qdb "github.com/questdb/go-questdb-client/v3"
107+
)
108+
109+
func main() {
110+
// Connect to QuestDB running on 127.0.0.1:9000 (ILP/HTTP)
111+
sender, err := qdb.NewLineSender(context.TODO(), qdb.WithHTTP())
112+
// Alternatively, you can use the LineSenderFromConf function:
113+
// sender, err := qdb.LineSenderFromConf(ctx, "http::addr=localhost:9000;")
114+
// ...
115+
defer sender.Close(context.TODO())
116+
// ...
117+
}
118+
```
119+
120+
Note that the migrated code uses the HTTP sender instead of the TCP one.
121+
76122
## Community
77123

78124
If you need help, have additional questions or want to provide feedback, you

examples/from-conf/main.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
qdb "github.com/questdb/go-questdb-client/v3"
99
)
1010

11+
const dateOnly = "2006-01-02"
12+
1113
func main() {
1214
ctx := context.TODO()
1315
sender, err := qdb.LineSenderFromConf(ctx, "http::addr=localhost:9000;")
@@ -23,7 +25,7 @@ func main() {
2325
}()
2426

2527
// Send a few ILP messages.
26-
bday, err := time.Parse(time.DateOnly, "1856-07-10")
28+
bday, err := time.Parse(dateOnly, "1856-07-10")
2729
if err != nil {
2830
log.Fatal(err)
2931
}
@@ -38,7 +40,7 @@ func main() {
3840
log.Fatal(err)
3941
}
4042

41-
bday, err = time.Parse(time.DateOnly, "1847-02-11")
43+
bday, err = time.Parse(dateOnly, "1847-02-11")
4244
if err != nil {
4345
log.Fatal(err)
4446
}

examples/http/auth-and-tls/main.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
qdb "github.com/questdb/go-questdb-client/v3"
99
)
1010

11+
const dateOnly = "2006-01-02"
12+
1113
func main() {
1214
ctx := context.TODO()
1315
sender, err := qdb.NewLineSender(
@@ -31,7 +33,7 @@ func main() {
3133
}()
3234

3335
// Send a few ILP messages.
34-
bday, err := time.Parse(time.DateOnly, "1856-07-10")
36+
bday, err := time.Parse(dateOnly, "1856-07-10")
3537
if err != nil {
3638
log.Fatal(err)
3739
}
@@ -46,7 +48,7 @@ func main() {
4648
log.Fatal(err)
4749
}
4850

49-
bday, err = time.Parse(time.DateOnly, "1847-02-11")
51+
bday, err = time.Parse(dateOnly, "1847-02-11")
5052
if err != nil {
5153
log.Fatal(err)
5254
}

examples/http/auth/main.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
qdb "github.com/questdb/go-questdb-client/v3"
99
)
1010

11+
const dateOnly = "2006-01-02"
12+
1113
func main() {
1214
ctx := context.TODO()
1315
sender, err := qdb.NewLineSender(
@@ -31,7 +33,7 @@ func main() {
3133
}()
3234

3335
// Send a few ILP messages.
34-
bday, err := time.Parse(time.DateOnly, "1856-07-10")
36+
bday, err := time.Parse(dateOnly, "1856-07-10")
3537
if err != nil {
3638
log.Fatal(err)
3739
}
@@ -46,7 +48,7 @@ func main() {
4648
log.Fatal(err)
4749
}
4850

49-
bday, err = time.Parse(time.DateOnly, "1847-02-11")
51+
bday, err = time.Parse(dateOnly, "1847-02-11")
5052
if err != nil {
5153
log.Fatal(err)
5254
}

examples/http/basic/main.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
qdb "github.com/questdb/go-questdb-client/v3"
99
)
1010

11+
const dateOnly = "2006-01-02"
12+
1113
func main() {
1214
ctx := context.TODO()
1315
// Connect to QuestDB running on 127.0.0.1:9009
@@ -24,7 +26,7 @@ func main() {
2426
}()
2527

2628
// Send a few ILP messages.
27-
bday, err := time.Parse(time.DateOnly, "1856-07-10")
29+
bday, err := time.Parse(dateOnly, "1856-07-10")
2830
if err != nil {
2931
log.Fatal(err)
3032
}
@@ -39,7 +41,7 @@ func main() {
3941
log.Fatal(err)
4042
}
4143

42-
bday, err = time.Parse(time.DateOnly, "1847-02-11")
44+
bday, err = time.Parse(dateOnly, "1847-02-11")
4345
if err != nil {
4446
log.Fatal(err)
4547
}

examples/tcp/auth-and-tls/main.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
qdb "github.com/questdb/go-questdb-client/v3"
99
)
1010

11+
const dateOnly = "2006-01-02"
12+
1113
func main() {
1214
ctx := context.TODO()
1315
sender, err := qdb.NewLineSender(
@@ -27,7 +29,7 @@ func main() {
2729
defer sender.Close(ctx)
2830

2931
// Send a few ILP messages.
30-
bday, err := time.Parse(time.DateOnly, "1856-07-10")
32+
bday, err := time.Parse(dateOnly, "1856-07-10")
3133
if err != nil {
3234
log.Fatal(err)
3335
}
@@ -42,7 +44,7 @@ func main() {
4244
log.Fatal(err)
4345
}
4446

45-
bday, err = time.Parse(time.DateOnly, "1847-02-11")
47+
bday, err = time.Parse(dateOnly, "1847-02-11")
4648
if err != nil {
4749
log.Fatal(err)
4850
}

examples/tcp/auth/main.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
qdb "github.com/questdb/go-questdb-client/v3"
99
)
1010

11+
const dateOnly = "2006-01-02"
12+
1113
func main() {
1214
ctx := context.TODO()
1315
sender, err := qdb.NewLineSender(
@@ -26,7 +28,7 @@ func main() {
2628
defer sender.Close(ctx)
2729

2830
// Send a few ILP messages.
29-
bday, err := time.Parse(time.DateOnly, "1856-07-10")
31+
bday, err := time.Parse(dateOnly, "1856-07-10")
3032
if err != nil {
3133
log.Fatal(err)
3234
}
@@ -41,7 +43,7 @@ func main() {
4143
log.Fatal(err)
4244
}
4345

44-
bday, err = time.Parse(time.DateOnly, "1847-02-11")
46+
bday, err = time.Parse(dateOnly, "1847-02-11")
4547
if err != nil {
4648
log.Fatal(err)
4749
}

examples/tcp/basic/main.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
qdb "github.com/questdb/go-questdb-client/v3"
99
)
1010

11+
const dateOnly = "2006-01-02"
12+
1113
func main() {
1214
ctx := context.TODO()
1315
// Connect to QuestDB running on 127.0.0.1:9009
@@ -19,7 +21,7 @@ func main() {
1921
defer sender.Close(ctx)
2022

2123
// Send a few ILP messages.
22-
bday, err := time.Parse(time.DateOnly, "1856-07-10")
24+
bday, err := time.Parse(dateOnly, "1856-07-10")
2325
if err != nil {
2426
log.Fatal(err)
2527
}
@@ -34,7 +36,7 @@ func main() {
3436
log.Fatal(err)
3537
}
3638

37-
bday, err = time.Parse(time.DateOnly, "1847-02-11")
39+
bday, err = time.Parse(dateOnly, "1847-02-11")
3840
if err != nil {
3941
log.Fatal(err)
4042
}

go.mod

+4-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/questdb/go-questdb-client/v3
22

3-
go 1.18
3+
go 1.19
44

55
require (
66
github.com/stretchr/testify v1.9.0
@@ -17,13 +17,10 @@ require (
1717
github.com/containerd/log v0.1.0 // indirect
1818
github.com/cpuguy83/dockercfg v0.3.1 // indirect
1919
github.com/davecgh/go-spew v1.1.1 // indirect
20-
github.com/distribution/reference v0.5.0 // indirect
21-
github.com/docker/docker v25.0.2+incompatible // indirect
20+
github.com/docker/distribution v2.8.2+incompatible // indirect
21+
github.com/docker/docker v24.0.9+incompatible // indirect
2222
github.com/docker/go-connections v0.5.0 // indirect
2323
github.com/docker/go-units v0.5.0 // indirect
24-
github.com/felixge/httpsnoop v1.0.3 // indirect
25-
github.com/go-logr/logr v1.2.4 // indirect
26-
github.com/go-logr/stdr v1.2.2 // indirect
2724
github.com/go-ole/go-ole v1.3.0 // indirect
2825
github.com/gogo/protobuf v1.3.2 // indirect
2926
github.com/golang/protobuf v1.5.3 // indirect
@@ -34,11 +31,11 @@ require (
3431
github.com/magiconair/properties v1.8.7 // indirect
3532
github.com/moby/patternmatcher v0.6.0 // indirect
3633
github.com/moby/sys/sequential v0.5.0 // indirect
37-
github.com/moby/sys/user v0.1.0 // indirect
3834
github.com/moby/term v0.5.0 // indirect
3935
github.com/morikuni/aec v1.0.0 // indirect
4036
github.com/opencontainers/go-digest v1.0.0 // indirect
4137
github.com/opencontainers/image-spec v1.1.0-rc5 // indirect
38+
github.com/opencontainers/runc v1.1.5 // indirect
4239
github.com/pkg/errors v0.9.1 // indirect
4340
github.com/pmezard/go-difflib v1.0.0 // indirect
4441
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
@@ -48,10 +45,6 @@ require (
4845
github.com/tklauser/go-sysconf v0.3.12 // indirect
4946
github.com/tklauser/numcpus v0.6.1 // indirect
5047
github.com/yusufpapurcu/wmi v1.2.3 // indirect
51-
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.45.0 // indirect
52-
go.opentelemetry.io/otel v1.19.0 // indirect
53-
go.opentelemetry.io/otel/metric v1.19.0 // indirect
54-
go.opentelemetry.io/otel/trace v1.19.0 // indirect
5548
golang.org/x/exp v0.0.0-20231005195138-3e424a577f31 // indirect
5649
golang.org/x/mod v0.13.0 // indirect
5750
golang.org/x/sys v0.16.0 // indirect

0 commit comments

Comments
 (0)