Map and filter
The next code example demonstrates the use of a few standard intermediate functions:Â map
and filter
.
Note
The code in this example can be copy/pasted into The Go playground, which is a service that takes your Go program, compiles, links, and runs your program with the latest version of Go inside a sandbox and then returns the output to the screen. You can find it at https://play.golang.org/.
Executable commands must always use package main
. We can separate each import statement on a separate line for readability.
External packages can be referenced using their remote GitHub repository path. We can preface long package names with a shorter alias. The go_utils
package can now be referenced with the u
 letter. Note that if we aliased a package name with _
, its exported functions can be referenced directly in our Go code without indicating which package it came from:
package main import ( "fmt" "log" "strings" "errors" u "github.com/go-goodies/go_utils" )
Note
iota
: A Go...