March 2020
Intermediate to advanced
406 pages
8h 39m
English
A multimap is a map where one or more values can be returned with a key. A practical application of a multimap would be a web query string. Query strings can have multiple values assigned to the same key, as we can see with the following example URL: https://www.example.com/?foo=bar&foo=baz&a=b.
In our example, we are going to create a multimap of cars. Our car struct has a year and a style associated with each car. We'll be able to aggregate these different types together. The following code snippet is an implementation of a multimap:
package mainimport ( "fmt" "github.com/jwangsadinata/go-multimap/slicemultimap")type cars []struct { year int style string}func main() { newCars := cars{{2019, "convertible"}, {1966, "fastback"}, {2019, ...Read now
Unlock full access