Interim while bringing sqlc in

This commit is contained in:
Matt Jadud
2025-11-30 08:20:39 -05:00
parent 0fbf88101f
commit f72c6b020f
14 changed files with 315 additions and 8 deletions

View File

@@ -0,0 +1,40 @@
package domain64
import (
"database/sql"
"sync"
"github.com/jpillora/go-tld"
)
type Domain64Map struct {
mu sync.Mutex
m map[string]int
DB *sql.DB
Flushed bool
}
// Just use the D64 values.
// TLD :: 0-255
// TLD.Domain :: FF:FFFFFF or some range of ints
// TLD.DOMAIN.SUBDOMAIN :: FF:FFFFFF:FF (bigger ints)
// now it is just a map
// https://stackoverflow.com/questions/40568759/sqlite-query-integer-field-based-on-a-bit
func NewDomain64Map(db *sql.DB) (*Domain64Map, error) {
d64m := &Domain64Map{}
d64m.DB = db
d64m.Flushed = true
// Init the tables if a DB pointer is passed in.
return d64m, nil
}
func (d64m *Domain64Map) Insert(url string) {
_, err := tld.Parse(url)
if err != nil {
// TODO
panic(err)
}
// If we have this TLD, return the value for it.
}