mirror of
https://github.com/moul/sshportal.git
synced 2024-11-10 17:26:41 +08:00
20 lines
391 B
Go
20 lines
391 B
Go
package main
|
|
|
|
import "math/rand"
|
|
|
|
const letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
|
|
|
|
func randStringBytes(n int) string {
|
|
b := make([]byte, n)
|
|
for i := range b {
|
|
b[i] = letterBytes[rand.Intn(len(letterBytes))]
|
|
}
|
|
return string(b)
|
|
}
|
|
|
|
func wrapText(in string, length int) string {
|
|
if len(in) <= length {
|
|
return in
|
|
}
|
|
return in[0:length-3] + "..."
|
|
}
|