Reduce code for lang

This commit is contained in:
Eliot Whalan 2016-07-04 10:04:37 +10:00
parent c7101dc5cb
commit 27aff618fd
No known key found for this signature in database
GPG Key ID: C0A42175139840D6
1 changed files with 5 additions and 6 deletions

11
main.go
View File

@ -112,16 +112,15 @@ func save(raw string, lang string, title string, expiry string) Response {
err := query.Scan(&id, &title, &hash, &paste, &delkey)
check(err)
url := ADDRESS + "/p/" + id
return Response{id, title, hash, url, len(paste), delkey
return Response{id, title, hash, url, len(paste), delkey}
}
}
id := generateName()
var url string
if lang == "" {
url = ADDRESS + "/p/" + id
} else {
url = ADDRESS + "/p/" + id + "/" + lang
url := ADDRESS + "/p/" + id
if lang != "" {
url += "/" + lang
}
const timeFormat = "2006-01-02 15:04:05"
expiryTime := time.Now().Add(durationFromExpiry(expiry)).Format(timeFormat)