Initialize map issues
I am developing a project where I need to declare the following:
mapDataPayload := make(map[string]*dataPayload)
If I append data to it, it works normally.
mapDataPayload := make(map[string]*dataPayload)
for {
select {
case rcvData := <-ch:
mapDataPayload[rcvData.Topic] = append(
mapDataPayload[rcvData.Topic],
&dataPayload{Message: rcvData.Message},
)
}
}
However, I would like to set a limit in size. With append it grows without stopping. What I would like to achieve is when the limit is reached (Max: 100), it would overwrite the index 0, 1, 2...
mapDataPayload[rcvData.Topic][0]
mapDataPayload[rcvData.Topic][1]
I tried to initialize the following with:
make(map[string]*dataPayload, 100)
for {
select {
case rcvData := <-ch:
mapDataPayload[rcvData.Topic][0] = &dataPayload{Message: rcvData.Message}
}
}
But if I check the length it would return 0. Replacing append with direct initialization (mapDataPayload[rcvData.Topic][0]) would cause error immediately.
So, what I want to do is populate the map[string]*dataPayload with a limit, for example this data:
{
"test1": {
"0": {
"Message": "Heasdllo"
},
"1": {
"Message": "Hel132lo"
},
"2": {
"Message": "Hedsallo"
}
},
"testanother": {
"0": {
"Message": "adsad"
},
"1": {
"Message": "Helwqe2lo"
},
"2": {
"Message": "Hel21321lo"
},
"3": {
"Message": "Hel21321lo"
}
}
}
When it reaches the number 100 I want to go back to number 0, 1, 2...
go
add a comment |
I am developing a project where I need to declare the following:
mapDataPayload := make(map[string]*dataPayload)
If I append data to it, it works normally.
mapDataPayload := make(map[string]*dataPayload)
for {
select {
case rcvData := <-ch:
mapDataPayload[rcvData.Topic] = append(
mapDataPayload[rcvData.Topic],
&dataPayload{Message: rcvData.Message},
)
}
}
However, I would like to set a limit in size. With append it grows without stopping. What I would like to achieve is when the limit is reached (Max: 100), it would overwrite the index 0, 1, 2...
mapDataPayload[rcvData.Topic][0]
mapDataPayload[rcvData.Topic][1]
I tried to initialize the following with:
make(map[string]*dataPayload, 100)
for {
select {
case rcvData := <-ch:
mapDataPayload[rcvData.Topic][0] = &dataPayload{Message: rcvData.Message}
}
}
But if I check the length it would return 0. Replacing append with direct initialization (mapDataPayload[rcvData.Topic][0]) would cause error immediately.
So, what I want to do is populate the map[string]*dataPayload with a limit, for example this data:
{
"test1": {
"0": {
"Message": "Heasdllo"
},
"1": {
"Message": "Hel132lo"
},
"2": {
"Message": "Hedsallo"
}
},
"testanother": {
"0": {
"Message": "adsad"
},
"1": {
"Message": "Helwqe2lo"
},
"2": {
"Message": "Hel21321lo"
},
"3": {
"Message": "Hel21321lo"
}
}
}
When it reaches the number 100 I want to go back to number 0, 1, 2...
go
1
Plain slices don't support such functionality. Take a look at golang.org/pkg/container/ring, maybe it's what you need.
– mkopriva
Nov 20 '18 at 14:49
I will take a look on that
– Marco Santos
Nov 20 '18 at 14:52
add a comment |
I am developing a project where I need to declare the following:
mapDataPayload := make(map[string]*dataPayload)
If I append data to it, it works normally.
mapDataPayload := make(map[string]*dataPayload)
for {
select {
case rcvData := <-ch:
mapDataPayload[rcvData.Topic] = append(
mapDataPayload[rcvData.Topic],
&dataPayload{Message: rcvData.Message},
)
}
}
However, I would like to set a limit in size. With append it grows without stopping. What I would like to achieve is when the limit is reached (Max: 100), it would overwrite the index 0, 1, 2...
mapDataPayload[rcvData.Topic][0]
mapDataPayload[rcvData.Topic][1]
I tried to initialize the following with:
make(map[string]*dataPayload, 100)
for {
select {
case rcvData := <-ch:
mapDataPayload[rcvData.Topic][0] = &dataPayload{Message: rcvData.Message}
}
}
But if I check the length it would return 0. Replacing append with direct initialization (mapDataPayload[rcvData.Topic][0]) would cause error immediately.
So, what I want to do is populate the map[string]*dataPayload with a limit, for example this data:
{
"test1": {
"0": {
"Message": "Heasdllo"
},
"1": {
"Message": "Hel132lo"
},
"2": {
"Message": "Hedsallo"
}
},
"testanother": {
"0": {
"Message": "adsad"
},
"1": {
"Message": "Helwqe2lo"
},
"2": {
"Message": "Hel21321lo"
},
"3": {
"Message": "Hel21321lo"
}
}
}
When it reaches the number 100 I want to go back to number 0, 1, 2...
go
I am developing a project where I need to declare the following:
mapDataPayload := make(map[string]*dataPayload)
If I append data to it, it works normally.
mapDataPayload := make(map[string]*dataPayload)
for {
select {
case rcvData := <-ch:
mapDataPayload[rcvData.Topic] = append(
mapDataPayload[rcvData.Topic],
&dataPayload{Message: rcvData.Message},
)
}
}
However, I would like to set a limit in size. With append it grows without stopping. What I would like to achieve is when the limit is reached (Max: 100), it would overwrite the index 0, 1, 2...
mapDataPayload[rcvData.Topic][0]
mapDataPayload[rcvData.Topic][1]
I tried to initialize the following with:
make(map[string]*dataPayload, 100)
for {
select {
case rcvData := <-ch:
mapDataPayload[rcvData.Topic][0] = &dataPayload{Message: rcvData.Message}
}
}
But if I check the length it would return 0. Replacing append with direct initialization (mapDataPayload[rcvData.Topic][0]) would cause error immediately.
So, what I want to do is populate the map[string]*dataPayload with a limit, for example this data:
{
"test1": {
"0": {
"Message": "Heasdllo"
},
"1": {
"Message": "Hel132lo"
},
"2": {
"Message": "Hedsallo"
}
},
"testanother": {
"0": {
"Message": "adsad"
},
"1": {
"Message": "Helwqe2lo"
},
"2": {
"Message": "Hel21321lo"
},
"3": {
"Message": "Hel21321lo"
}
}
}
When it reaches the number 100 I want to go back to number 0, 1, 2...
go
go
edited Nov 20 '18 at 14:51
Marco Santos
asked Nov 20 '18 at 14:37
Marco SantosMarco Santos
684
684
1
Plain slices don't support such functionality. Take a look at golang.org/pkg/container/ring, maybe it's what you need.
– mkopriva
Nov 20 '18 at 14:49
I will take a look on that
– Marco Santos
Nov 20 '18 at 14:52
add a comment |
1
Plain slices don't support such functionality. Take a look at golang.org/pkg/container/ring, maybe it's what you need.
– mkopriva
Nov 20 '18 at 14:49
I will take a look on that
– Marco Santos
Nov 20 '18 at 14:52
1
1
Plain slices don't support such functionality. Take a look at golang.org/pkg/container/ring, maybe it's what you need.
– mkopriva
Nov 20 '18 at 14:49
Plain slices don't support such functionality. Take a look at golang.org/pkg/container/ring, maybe it's what you need.
– mkopriva
Nov 20 '18 at 14:49
I will take a look on that
– Marco Santos
Nov 20 '18 at 14:52
I will take a look on that
– Marco Santos
Nov 20 '18 at 14:52
add a comment |
2 Answers
2
active
oldest
votes
You could implement a data structure for a circular buffer like this
package main
import (
"fmt"
)
type Circle struct {
Size int
Contents interface{}
Pointer int
}
func (c *Circle) Setup(n int) {
(*c).Size=n
(*c).Contents=make(interface{},n)
}
func (c *Circle) Add(value interface{}) {
(*c).Contents[(*c).Pointer] = value
(*c).Pointer = ((*c).Pointer+1) % (*c).Size
}
func main() {
mapDataPayload := make(map[string]*Circle)
mapDataPayload["aaa"]=&Circle{}
mapDataPayload["aaa"].Setup(10)
for i:=0; i<9999; i++ {
mapDataPayload["aaa"].Add(i)
}
mapDataPayload["aaa"].Add("banana")
fmt.Println(mapDataPayload["aaa"].Contents)
}
updated to use interface{} so any type of data can be used
I believe that this is what I am looking for, I will try to implement it and check if it is working as intended.
– Marco Santos
Nov 20 '18 at 15:26
It worked however I am only able to store integer values on mapDataPayload["aaa"].Add(i) and I receive byte which could be any type, could be an integer, string, ...
– Marco Santos
Nov 20 '18 at 15:38
oh ok, you need to replace theContents int
withContents interface{}
I've updated the answer
– Vorsprung
Nov 20 '18 at 15:45
For some reason the first position starts 0 (undefined), but when it reaches the end and starts again it is overwritten as expected. Its not a big deal to me starting in the position 1 instead of 0 but I just point it out for someone that find this answer useful.
– Marco Santos
Nov 20 '18 at 15:52
yes, that was my fault. Fixed in code snippet now. Swap the lines in the func Add so the pointer is incremented after the insertion
– Vorsprung
Nov 20 '18 at 16:26
add a comment |
Use like this:
for {
select {
case rcvData := <-ch:
_, exists := mapDataPayload[rcvData.Topic]
if !exists {
mapDataPayload[rcvData.Topic] = *dataPayload{}
}
if len(mapDataPayload[rcvData.Topic]) < 100 {
mapDataPayload[rcvData.Topic] = append(
mapDataPayload[rcvData.Topic],
&dataPayload{Message: rcvData.Message},
)
} else {
mapDataPayload[rcvData.Topic][len(mapDataPayload[rcvData.Topic]) % 100] = &dataPayload{Message: rcvData.Message}
}
}
}
This does not work as expected. size var is incrementing no mater the rcvData.Topic which is dynamic
– Marco Santos
Nov 20 '18 at 16:02
Oh no. I've done some mistakes. Fixing...
– Shudipta Sharma
Nov 20 '18 at 16:32
editing finished
– Shudipta Sharma
Nov 20 '18 at 16:40
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395380%2finitialize-map-issues%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
You could implement a data structure for a circular buffer like this
package main
import (
"fmt"
)
type Circle struct {
Size int
Contents interface{}
Pointer int
}
func (c *Circle) Setup(n int) {
(*c).Size=n
(*c).Contents=make(interface{},n)
}
func (c *Circle) Add(value interface{}) {
(*c).Contents[(*c).Pointer] = value
(*c).Pointer = ((*c).Pointer+1) % (*c).Size
}
func main() {
mapDataPayload := make(map[string]*Circle)
mapDataPayload["aaa"]=&Circle{}
mapDataPayload["aaa"].Setup(10)
for i:=0; i<9999; i++ {
mapDataPayload["aaa"].Add(i)
}
mapDataPayload["aaa"].Add("banana")
fmt.Println(mapDataPayload["aaa"].Contents)
}
updated to use interface{} so any type of data can be used
I believe that this is what I am looking for, I will try to implement it and check if it is working as intended.
– Marco Santos
Nov 20 '18 at 15:26
It worked however I am only able to store integer values on mapDataPayload["aaa"].Add(i) and I receive byte which could be any type, could be an integer, string, ...
– Marco Santos
Nov 20 '18 at 15:38
oh ok, you need to replace theContents int
withContents interface{}
I've updated the answer
– Vorsprung
Nov 20 '18 at 15:45
For some reason the first position starts 0 (undefined), but when it reaches the end and starts again it is overwritten as expected. Its not a big deal to me starting in the position 1 instead of 0 but I just point it out for someone that find this answer useful.
– Marco Santos
Nov 20 '18 at 15:52
yes, that was my fault. Fixed in code snippet now. Swap the lines in the func Add so the pointer is incremented after the insertion
– Vorsprung
Nov 20 '18 at 16:26
add a comment |
You could implement a data structure for a circular buffer like this
package main
import (
"fmt"
)
type Circle struct {
Size int
Contents interface{}
Pointer int
}
func (c *Circle) Setup(n int) {
(*c).Size=n
(*c).Contents=make(interface{},n)
}
func (c *Circle) Add(value interface{}) {
(*c).Contents[(*c).Pointer] = value
(*c).Pointer = ((*c).Pointer+1) % (*c).Size
}
func main() {
mapDataPayload := make(map[string]*Circle)
mapDataPayload["aaa"]=&Circle{}
mapDataPayload["aaa"].Setup(10)
for i:=0; i<9999; i++ {
mapDataPayload["aaa"].Add(i)
}
mapDataPayload["aaa"].Add("banana")
fmt.Println(mapDataPayload["aaa"].Contents)
}
updated to use interface{} so any type of data can be used
I believe that this is what I am looking for, I will try to implement it and check if it is working as intended.
– Marco Santos
Nov 20 '18 at 15:26
It worked however I am only able to store integer values on mapDataPayload["aaa"].Add(i) and I receive byte which could be any type, could be an integer, string, ...
– Marco Santos
Nov 20 '18 at 15:38
oh ok, you need to replace theContents int
withContents interface{}
I've updated the answer
– Vorsprung
Nov 20 '18 at 15:45
For some reason the first position starts 0 (undefined), but when it reaches the end and starts again it is overwritten as expected. Its not a big deal to me starting in the position 1 instead of 0 but I just point it out for someone that find this answer useful.
– Marco Santos
Nov 20 '18 at 15:52
yes, that was my fault. Fixed in code snippet now. Swap the lines in the func Add so the pointer is incremented after the insertion
– Vorsprung
Nov 20 '18 at 16:26
add a comment |
You could implement a data structure for a circular buffer like this
package main
import (
"fmt"
)
type Circle struct {
Size int
Contents interface{}
Pointer int
}
func (c *Circle) Setup(n int) {
(*c).Size=n
(*c).Contents=make(interface{},n)
}
func (c *Circle) Add(value interface{}) {
(*c).Contents[(*c).Pointer] = value
(*c).Pointer = ((*c).Pointer+1) % (*c).Size
}
func main() {
mapDataPayload := make(map[string]*Circle)
mapDataPayload["aaa"]=&Circle{}
mapDataPayload["aaa"].Setup(10)
for i:=0; i<9999; i++ {
mapDataPayload["aaa"].Add(i)
}
mapDataPayload["aaa"].Add("banana")
fmt.Println(mapDataPayload["aaa"].Contents)
}
updated to use interface{} so any type of data can be used
You could implement a data structure for a circular buffer like this
package main
import (
"fmt"
)
type Circle struct {
Size int
Contents interface{}
Pointer int
}
func (c *Circle) Setup(n int) {
(*c).Size=n
(*c).Contents=make(interface{},n)
}
func (c *Circle) Add(value interface{}) {
(*c).Contents[(*c).Pointer] = value
(*c).Pointer = ((*c).Pointer+1) % (*c).Size
}
func main() {
mapDataPayload := make(map[string]*Circle)
mapDataPayload["aaa"]=&Circle{}
mapDataPayload["aaa"].Setup(10)
for i:=0; i<9999; i++ {
mapDataPayload["aaa"].Add(i)
}
mapDataPayload["aaa"].Add("banana")
fmt.Println(mapDataPayload["aaa"].Contents)
}
updated to use interface{} so any type of data can be used
edited Nov 20 '18 at 16:25
answered Nov 20 '18 at 15:05


VorsprungVorsprung
22.6k32144
22.6k32144
I believe that this is what I am looking for, I will try to implement it and check if it is working as intended.
– Marco Santos
Nov 20 '18 at 15:26
It worked however I am only able to store integer values on mapDataPayload["aaa"].Add(i) and I receive byte which could be any type, could be an integer, string, ...
– Marco Santos
Nov 20 '18 at 15:38
oh ok, you need to replace theContents int
withContents interface{}
I've updated the answer
– Vorsprung
Nov 20 '18 at 15:45
For some reason the first position starts 0 (undefined), but when it reaches the end and starts again it is overwritten as expected. Its not a big deal to me starting in the position 1 instead of 0 but I just point it out for someone that find this answer useful.
– Marco Santos
Nov 20 '18 at 15:52
yes, that was my fault. Fixed in code snippet now. Swap the lines in the func Add so the pointer is incremented after the insertion
– Vorsprung
Nov 20 '18 at 16:26
add a comment |
I believe that this is what I am looking for, I will try to implement it and check if it is working as intended.
– Marco Santos
Nov 20 '18 at 15:26
It worked however I am only able to store integer values on mapDataPayload["aaa"].Add(i) and I receive byte which could be any type, could be an integer, string, ...
– Marco Santos
Nov 20 '18 at 15:38
oh ok, you need to replace theContents int
withContents interface{}
I've updated the answer
– Vorsprung
Nov 20 '18 at 15:45
For some reason the first position starts 0 (undefined), but when it reaches the end and starts again it is overwritten as expected. Its not a big deal to me starting in the position 1 instead of 0 but I just point it out for someone that find this answer useful.
– Marco Santos
Nov 20 '18 at 15:52
yes, that was my fault. Fixed in code snippet now. Swap the lines in the func Add so the pointer is incremented after the insertion
– Vorsprung
Nov 20 '18 at 16:26
I believe that this is what I am looking for, I will try to implement it and check if it is working as intended.
– Marco Santos
Nov 20 '18 at 15:26
I believe that this is what I am looking for, I will try to implement it and check if it is working as intended.
– Marco Santos
Nov 20 '18 at 15:26
It worked however I am only able to store integer values on mapDataPayload["aaa"].Add(i) and I receive byte which could be any type, could be an integer, string, ...
– Marco Santos
Nov 20 '18 at 15:38
It worked however I am only able to store integer values on mapDataPayload["aaa"].Add(i) and I receive byte which could be any type, could be an integer, string, ...
– Marco Santos
Nov 20 '18 at 15:38
oh ok, you need to replace the
Contents int
with Contents interface{}
I've updated the answer– Vorsprung
Nov 20 '18 at 15:45
oh ok, you need to replace the
Contents int
with Contents interface{}
I've updated the answer– Vorsprung
Nov 20 '18 at 15:45
For some reason the first position starts 0 (undefined), but when it reaches the end and starts again it is overwritten as expected. Its not a big deal to me starting in the position 1 instead of 0 but I just point it out for someone that find this answer useful.
– Marco Santos
Nov 20 '18 at 15:52
For some reason the first position starts 0 (undefined), but when it reaches the end and starts again it is overwritten as expected. Its not a big deal to me starting in the position 1 instead of 0 but I just point it out for someone that find this answer useful.
– Marco Santos
Nov 20 '18 at 15:52
yes, that was my fault. Fixed in code snippet now. Swap the lines in the func Add so the pointer is incremented after the insertion
– Vorsprung
Nov 20 '18 at 16:26
yes, that was my fault. Fixed in code snippet now. Swap the lines in the func Add so the pointer is incremented after the insertion
– Vorsprung
Nov 20 '18 at 16:26
add a comment |
Use like this:
for {
select {
case rcvData := <-ch:
_, exists := mapDataPayload[rcvData.Topic]
if !exists {
mapDataPayload[rcvData.Topic] = *dataPayload{}
}
if len(mapDataPayload[rcvData.Topic]) < 100 {
mapDataPayload[rcvData.Topic] = append(
mapDataPayload[rcvData.Topic],
&dataPayload{Message: rcvData.Message},
)
} else {
mapDataPayload[rcvData.Topic][len(mapDataPayload[rcvData.Topic]) % 100] = &dataPayload{Message: rcvData.Message}
}
}
}
This does not work as expected. size var is incrementing no mater the rcvData.Topic which is dynamic
– Marco Santos
Nov 20 '18 at 16:02
Oh no. I've done some mistakes. Fixing...
– Shudipta Sharma
Nov 20 '18 at 16:32
editing finished
– Shudipta Sharma
Nov 20 '18 at 16:40
add a comment |
Use like this:
for {
select {
case rcvData := <-ch:
_, exists := mapDataPayload[rcvData.Topic]
if !exists {
mapDataPayload[rcvData.Topic] = *dataPayload{}
}
if len(mapDataPayload[rcvData.Topic]) < 100 {
mapDataPayload[rcvData.Topic] = append(
mapDataPayload[rcvData.Topic],
&dataPayload{Message: rcvData.Message},
)
} else {
mapDataPayload[rcvData.Topic][len(mapDataPayload[rcvData.Topic]) % 100] = &dataPayload{Message: rcvData.Message}
}
}
}
This does not work as expected. size var is incrementing no mater the rcvData.Topic which is dynamic
– Marco Santos
Nov 20 '18 at 16:02
Oh no. I've done some mistakes. Fixing...
– Shudipta Sharma
Nov 20 '18 at 16:32
editing finished
– Shudipta Sharma
Nov 20 '18 at 16:40
add a comment |
Use like this:
for {
select {
case rcvData := <-ch:
_, exists := mapDataPayload[rcvData.Topic]
if !exists {
mapDataPayload[rcvData.Topic] = *dataPayload{}
}
if len(mapDataPayload[rcvData.Topic]) < 100 {
mapDataPayload[rcvData.Topic] = append(
mapDataPayload[rcvData.Topic],
&dataPayload{Message: rcvData.Message},
)
} else {
mapDataPayload[rcvData.Topic][len(mapDataPayload[rcvData.Topic]) % 100] = &dataPayload{Message: rcvData.Message}
}
}
}
Use like this:
for {
select {
case rcvData := <-ch:
_, exists := mapDataPayload[rcvData.Topic]
if !exists {
mapDataPayload[rcvData.Topic] = *dataPayload{}
}
if len(mapDataPayload[rcvData.Topic]) < 100 {
mapDataPayload[rcvData.Topic] = append(
mapDataPayload[rcvData.Topic],
&dataPayload{Message: rcvData.Message},
)
} else {
mapDataPayload[rcvData.Topic][len(mapDataPayload[rcvData.Topic]) % 100] = &dataPayload{Message: rcvData.Message}
}
}
}
edited Nov 20 '18 at 16:39
answered Nov 20 '18 at 14:54


Shudipta SharmaShudipta Sharma
1,071312
1,071312
This does not work as expected. size var is incrementing no mater the rcvData.Topic which is dynamic
– Marco Santos
Nov 20 '18 at 16:02
Oh no. I've done some mistakes. Fixing...
– Shudipta Sharma
Nov 20 '18 at 16:32
editing finished
– Shudipta Sharma
Nov 20 '18 at 16:40
add a comment |
This does not work as expected. size var is incrementing no mater the rcvData.Topic which is dynamic
– Marco Santos
Nov 20 '18 at 16:02
Oh no. I've done some mistakes. Fixing...
– Shudipta Sharma
Nov 20 '18 at 16:32
editing finished
– Shudipta Sharma
Nov 20 '18 at 16:40
This does not work as expected. size var is incrementing no mater the rcvData.Topic which is dynamic
– Marco Santos
Nov 20 '18 at 16:02
This does not work as expected. size var is incrementing no mater the rcvData.Topic which is dynamic
– Marco Santos
Nov 20 '18 at 16:02
Oh no. I've done some mistakes. Fixing...
– Shudipta Sharma
Nov 20 '18 at 16:32
Oh no. I've done some mistakes. Fixing...
– Shudipta Sharma
Nov 20 '18 at 16:32
editing finished
– Shudipta Sharma
Nov 20 '18 at 16:40
editing finished
– Shudipta Sharma
Nov 20 '18 at 16:40
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53395380%2finitialize-map-issues%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Plain slices don't support such functionality. Take a look at golang.org/pkg/container/ring, maybe it's what you need.
– mkopriva
Nov 20 '18 at 14:49
I will take a look on that
– Marco Santos
Nov 20 '18 at 14:52