package internal import ( log "github.com/sirupsen/logrus" ) type Crawler interface { Start() Crawl(url string) error } type crawler struct { q chan string } func NewCrawler() (Crawler, error) { return &crawler{q: make(chan string)}, nil } func (c *crawler) loop() { for { url := <-c.q log.Debugf("crawling %s", url) } } func (c *crawler) Crawl(url string) error { c.q <- url return nil } func (c *crawler) Start() { go c.loop() }