Skip to content

Instantly share code, notes, and snippets.

@JeffreyBPetersen
Created September 13, 2016 00:04
Show Gist options
  • Save JeffreyBPetersen/465c144548ff280582310059499ad235 to your computer and use it in GitHub Desktop.
Save JeffreyBPetersen/465c144548ff280582310059499ad235 to your computer and use it in GitHub Desktop.
Pick a single value out of a multiple return in golang.
package main
import (
"fmt"
"io/ioutil"
)
func door(number int) func(...interface{}) interface{} {
return func(doors ...interface{}) interface{} {
return doors[number]
}
}
func main() {
fmt.Printf("%s", door(0)(ioutil.ReadFile("test.txt")))
}
It's a new car!
With inspiration from "http://blog.vladimirvivien.com/2014/03/hacking-go-filter-values-from-multi.html".
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment