Skip to content

Instantly share code, notes, and snippets.

@jen20
Created February 9, 2015 21:53
Show Gist options
  • Save jen20/5e7b3a4fc3c5db05b281 to your computer and use it in GitHub Desktop.
Save jen20/5e7b3a4fc3c5db05b281 to your computer and use it in GitHub Desktop.
func getRandomProbablyAvailableSuffixedDnsName(prefix string, client *hostedservice.HostedServiceClient) (string, error) {
done := false
maybeName := ""
for done == false {
maybeName = fmt.Sprintf("%s-%d", prefix, rand.Intn(99999))
available, reason, err := client.CheckHostedServiceNameAvailability(maybeName)
if err != nil {
return "", fmt.Errorf("Error checking cloud service name availability: %s", err)
}
done = true
}
return maybeName, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment