Hello,
I am currently reimplementing things I wrote in Perl to get some more exposure to Go.
One of the programs creates a little inventory at runtime which looks like this:
foo.rpm = 23
bar.rpm = 42
In Perl I used a Hash to implement it and in Go the logical counterpart (for me) seems to be map[string]int
.
However, I was wondering is there is a more elegant way to do this. I want to be able to add items to this inventory (e.g. blarb.rpm = 123
) as the program runs and I also want to do lookups (find number for foo.rpm
).
What do you think is the most fitting data/function structure to implement such a thing?
Thanks!
Cheers, Lordy