This is a creation in Article, where the information may have evolved or changed.
Random number generation to be used.
Const Letterbytes = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
Const (
Letteridxbits = 6
Letteridxmask = 1<<letteridxbits-1
Letteridxmax = 63/letteridxbits
)
Domain Check
Func domaincheck (domain string) bool {
var match bool
Support to start with HTTP//or https://and the middle of the domain name
Isline: = "^ ((/http) | ( https://))? ([A-za-z0-9] ([a-za-z0-9\\-]{0,61}[a-za-z0-9]) \ \.) +[a-za-z]{2,6} (/) "
Support to start with HTTP///https://and no/in the middle of the domain name
Notline: = "^ ((/http) | ( https://))? ([A-za-z0-9] ([a-za-z0-9\\-]{0,61}[a-za-z0-9]) \ \.) +[a-za-z]{2,6} "
Match, _ = RegExp. Matchstring (isline, domain)
If!match {
Match, _ = RegExp. Matchstring (notline, domain)
}
Return match
}
Promotion ID Random generation ()
Func randstringbytesmaskimprsrc (n int) string {
var src = rand. Newsource (time. Now (). Unixnano ())
B: = make ([]byte, N)
For I, cache, remain: = N-1, src. Int63 (), Letteridxmax; I >= 0; {
If remain = = 0 {
Cache, remain = src. Int63 (), Letteridxmax
}
If idx: = Int (cache & Letteridxmask); IDX < Len (letterbytes) {
B[i] = Letterbytes[idx]
i--
}
Cache >>= Letteridxbits
remain--
}
return string (b)
}