33 lines
721 B
Go
33 lines
721 B
Go
package domain64
|
|
|
|
type Domain64 struct {
|
|
// The TLD is FF
|
|
TLD uint8
|
|
// The Domain is FFFFFF, so the uint16 is the closest we'll get
|
|
Domain uint16
|
|
// Subdomains are FF
|
|
Subdomain uint8
|
|
// Paths are, again, FFFFFF
|
|
Path uint16
|
|
}
|
|
|
|
/*
|
|
```mermaid
|
|
packet-beta
|
|
0-7: "FF | TLD"
|
|
8-31: "FFFFFF | Domain"
|
|
32-39: "FF | Subdomain"
|
|
40-63: "FFFFFF | Path"
|
|
```
|
|
*/
|
|
func (d64 *Domain64) AsInt64() int64 {
|
|
var result int64 = 0
|
|
result = result | (int64(d64.TLD) << (64 - 8))
|
|
result = result | (int64(d64.Domain) << (64 - (8 + 24)))
|
|
result = result | (int64(d64.Subdomain) << (64 - (8 + 24 + 8)))
|
|
result = result | (int64(d64.Path) << (64 - (8 + 24 + 8 + 24)))
|
|
return result
|
|
}
|
|
|
|
// https://gobyexample.com/testing-and-benchmarking
|