Channel Groups API for Go SDK
Channel groups allow PubNub developers to bundle thousands of channels into a group that can be identified by a name. These channel groups can then be subscribed to, receiving data from the many back-end channels the channel group contains.
Channel group operations
You can't publish to a channel group. You can only subscribe to it. To publish within the channel group, you need to publish to each channel individually.
Add channels to a channel group
Requires Stream Controller add-on
This method requires that the Stream Controller add-on is enabled for your key in the PubNub Admin Portal. See Enable the features your app calls.
This function adds channels to a channel group.
Method(s)
Use the following method in the Go SDK:
Maximum number of channels
You can add up to 200 channels to a channel group per API call.
1pn.AddChannelToChannelGroup().
2 Channels([]string).
3 ChannelGroup(string).
4 QueryParam(queryParam).
5 Execute()
Sample code
Add channels
1
Response
1{
2 "service" : "channel-registry",
3 "status" : 200,
4 "error" : false,
5 "message" : "OK"
6}
List channels in a channel group
Requires Stream Controller add-on
This method requires that the Stream Controller add-on is enabled for your key in the Admin Portal. See Enable the features your app calls.
This function lists all channels in a channel group.
Method(s)
Use the following method in the Go SDK:
1pn.ListChannelsInChannelGroup().
2 ChannelGroup(string).
3 QueryParam(queryParam).
4 Execute()
Sample code
List channels
1
Response
Remove channels from a channel group
Requires Stream Controller add-on
This method requires that the Stream Controller add-on is enabled for your key in the Admin Portal. See Enable the features your app calls.
This function removes channels from a channel group.
Method(s)
Use the following method in the Go SDK:
1pn.RemoveChannelFromChannelGroup().
2 ChannelGroup(string).
3 Channels([]string).
4 QueryParam(queryParam).
5 Execute()
Sample code
Remove channels
1
Response
1{
2 Error:<nil>
3 Category:Unknown
4 Operation:Remove Channel From Channel Group
5 StatusCode:200
6 TLSEnabled:true
7 UUID:d9713e5a-6bcb-439a-942e-5ba064f2e5dd
8 AuthKey:
9 Origin:ps.pndsn.com
10 OriginalResponse: {
11 "status": 200,
12 "message": "OK",
13 "service": "channel-registry",
14 "error": false
15 }
show all 18 linesDelete a channel group
Requires Stream Controller add-on
This method requires that the Stream Controller add-on is enabled for your key in the Admin Portal. See Enable the features your app calls.
This function deletes a channel group.
Method(s)
Use the following method in the Go SDK:
1pn.DeleteChannelGroup().
2 ChannelGroup(string).
3 QueryParam(queryParam).
4 Execute()
Sample code
Delete channel group
1
Response
1{
2 Error:<nil>
3 Category:Unknown
4 Operation:Remove Channel Group
5 StatusCode:200
6 TLSEnabled:true
7 UUID:650089a0-922c-4de6-b422-7a38a964bf45
8 AuthKey:
9 Origin:ps.pndsn.com
10 OriginalResponse: {
11 "status": 200,
12 "message": "OK",
13 "service": "channel-registry",
14 "error": false
15 }
show all 18 lines