Reduce code for lang
This commit is contained in:
parent
9d97f561c2
commit
34b1065736
11
main.go
11
main.go
|
@ -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)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue