Skip to content

Instantly share code, notes, and snippets.

@napicella
Last active April 1, 2018 14:36
Show Gist options
  • Save napicella/d5ba583f0da4b9f5e0fa1f479be6cb25 to your computer and use it in GitHub Desktop.
Save napicella/d5ba583f0da4b9f5e0fa1f479be6cb25 to your computer and use it in GitHub Desktop.
Golang-patterns Chain example
package chain
import "fmt"
func ExampleChain() {
endpoint, _ := chain(
loadEndpointFromConfigFile,
loadEndpointFromEnvVariables,
loadEndpointFromDatabase,
).get()
fmt.Println(endpoint)
// Output: some-endpoint
}
func loadEndpointFromEnvVariables() (string, error) {
return "", nil
}
func loadEndpointFromConfigFile() (string, error) {
return "", nil
}
func loadEndpointFromDatabase() (string, error) {
return "some-endpoint", nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment