Skip to content

Instantly share code, notes, and snippets.

@danhuynhdev
Last active July 22, 2016 10:39
Show Gist options
  • Save danhuynhdev/19bca4e4ca1e7e57ffbbe287e19bd670 to your computer and use it in GitHub Desktop.
Save danhuynhdev/19bca4e4ca1e7e57ffbbe287e19bd670 to your computer and use it in GitHub Desktop.
if url.ShortID == "" {
for {
shortId, err := GenerateID()
if err != nil {
http.Error(res, err.Error(), 500)
return
}
url = URL{ShortID: shortId, OriginalURL: original}
if db.NewRecord(url) {
break
}
}
db.Create(&url)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment