-
-
Save krancour/58c678092e8e64566320e1fcf2649152 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func EnglishGreeting(name string) error { | |
fmt.Printf("Hello, %s!\n", name) | |
return nil | |
} | |
func SpanishGreeting(name string) error { | |
fmt.Printf("Hola, %s!\n", name) | |
return nil | |
} | |
func SayGreetings(greetingFns []func(string) error, name string) error { | |
for _, greetingFn := range greetingFns { | |
if err := greetingFn(name); err != nil { | |
return err | |
} | |
} | |
return nil | |
} | |
func main() { | |
SayGreetings( | |
[]func(string) error{EnglishGreeting, SpanishGreeting}, | |
"World", | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment