November 2017
Intermediate to advanced
670 pages
17h 35m
English
Remember those four numerics types that we implemented a Sum method for without generics? Let's revisit that code and see if we can improve our code base now that we know about gen:
cd <DEVDIR>/learn-fp-go/4-purely-functional/ch11-functor-monoid/04_generics_nums. initglide-update
Note that we need to run glide-update so that the vendors directory will be created for us. It will first be placed in our GOPATH so that when we run the next command, the gen package and its dependencies will go in our vendors directory rather than our project’s src directory:
go get github.com/clipperhouse/gen
Now, let's cd to ~/dev/04_generics_nums/src/num and run gen:
cd src/num;gen;cd -
We can see that gen created four files, one for each slice ...