You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The RudderStack Go SDK lets you send customer event data from your Go applications to your specified destinations.
26
+
27
+
## SDK setup requirements
28
+
29
+
- Set up a [RudderStack open source](https://app.rudderstack.com/signup?type=opensource) account.
30
+
- Set up a Go source in the dashboard.
31
+
- Copy the write key and the data plane URL. For more information, refer to the [Go SDK documentation](https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-go-sdk/#sdk-setup-requirements).
1
32
2
33
## Installation
3
34
4
-
The package can be simply installed via "go get", we recommend that you use a tool like
5
-
Godep to avoid issues related to API breaking changes introduced between major
6
-
versions of the library.
35
+
You can install the Go SDK via the `go get` command.
7
36
8
-
To install it in the GOPATH:
9
-
```
37
+
| It is highly recommended to use a tool like Godep to avoid any issues related to the breaking API changes introduced between the major versions of the library. |
38
+
| :-----|
39
+
40
+
To install the SDK in the `GOPATH`, run the following:
41
+
42
+
```go
10
43
go get github.com/rudderlabs/analytics-go
11
44
```
12
45
13
-
14
-
## Usage
46
+
## Using the SDK
15
47
16
48
```go
17
49
package main
18
50
19
51
import (
20
-
"github.com/rudderlabs/analytics-go"
52
+
"github.com/rudderlabs/analytics-go/v4"
21
53
)
22
54
23
55
funcmain() {
24
-
// Instantiates a client to use send messages to the Rudder API.
25
-
// User your WRITE KEY in below placeholder "RUDDER WRITE KEY"
56
+
// Instantiates a client to use send messages to the RudderStack API.
// Instantiates a client to use send messages to the RudderStack API.
84
+
85
+
// User your write key in the below placeholder:
86
+
87
+
client, _:= analytics.NewWithConfig(WRITE_KEY,
50
88
analytics.Config{
51
-
Interval: 30 * time.Second,
52
-
BatchSize: 100,
53
-
Verbose: true,
89
+
DataPlaneUrl: DATA_PLANE_URL,
90
+
Interval: 30 * time.Second,
91
+
BatchSize: 100,
92
+
Verbose: true,
93
+
Gzip: 0, // Enables Gzip compression - set to 1 to disable Gzip.
54
94
})
55
95
56
96
// Enqueues a track event that will be sent asynchronously.
97
+
57
98
client.Enqueue(analytics.Track{
58
99
UserId: "test-user",
59
100
Event: "test-snippet",
60
101
})
61
102
62
103
// Flushes any queued messages and closes the client.
104
+
63
105
client.Close()
64
106
}
65
107
```
66
108
109
+
## Gzip support
110
+
111
+
The Go SDK supports Gzip compression from version 4.0.0 and it is enabled (set to `0`) by default. However, you can disable this feature by setting the `Gzip` parameter to `1` while initializing the SDK, as shown:
112
+
113
+
```go
114
+
client, _:= analytics.NewWithConfig(WRITE_KEY,
115
+
analytics.Config{
116
+
DataPlaneUrl: DATA_PLANE_URL,
117
+
Interval: 30 * time.Second,
118
+
BatchSize: 100,
119
+
Verbose: true,
120
+
Gzip: 0// Enables Gzip compression - set to 1 to disable Gzip.
121
+
})
122
+
```
123
+
124
+
125
+
126
+
| Note: Gzip requires `rudder-server` version 1.4 or later. |
127
+
| :-----|
128
+
129
+
## Sending events
130
+
131
+
Refer to the [RudderStack Go SDK documentation](https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-go-sdk/) for more information on the supported event types.
67
132
68
133
## License
69
134
70
-
The library is released under the [MIT license](License.md).
135
+
The RudderStack Go SDK is released under the [MIT license](License.md).
0 commit comments