Created
February 9, 2015 21:53
-
-
Save jen20/5e7b3a4fc3c5db05b281 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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