Created
August 30, 2018 16:04
-
-
Save pdk/f658b3b96ede4149697f8d42c92627ee to your computer and use it in GitHub Desktop.
using makro for non-error values
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
// GatherItems collects incoming items. If somehow we get more than n, an error is returned. | |
func GatherItems(n int) ([]string, error) { | |
makro checkLen { | |
if len(items) > n { | |
return items, fmt.Errorf("more than %d items gathered: %d", n, len(items)) | |
} | |
} | |
var items []string | |
items = append(items, GetItemsFromSourceAlpha()...) | |
checkLen() | |
items = append(items, GetItemsFromSourceBeta()...) | |
checkLen() | |
items = append(items, GetItemsFromSourceGamma()...) | |
checkLen() | |
return items, nil | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment