Reduce code for lang

This commit is contained in:
Eliot Whalan 2016-07-04 10:04:37 +10:00
parent 9d97f561c2
commit 34b1065736
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) err := query.Scan(&id, &title, &hash, &paste, &delkey)
check(err) check(err)
url := ADDRESS + "/p/" + id url := ADDRESS + "/p/" + id
return Response{id, title, hash, url, len(paste), delkey return Response{id, title, hash, url, len(paste), delkey}
} }
} }
id := generateName() id := generateName()
var url string url := ADDRESS + "/p/" + id
if lang == "" { if lang != "" {
url = ADDRESS + "/p/" + id url += "/" + lang
} else {
url = ADDRESS + "/p/" + id + "/" + lang
} }
const timeFormat = "2006-01-02 15:04:05" const timeFormat = "2006-01-02 15:04:05"
expiryTime := time.Now().Add(durationFromExpiry(expiry)).Format(timeFormat) expiryTime := time.Now().Add(durationFromExpiry(expiry)).Format(timeFormat)