New to Go – Quick Debug Question

Written by
Link to Post by 

I’m trying to use the ring queue (here)[] in my web scraping project. Multiple crawlers will need to import this queuing system, so I want an outward facing Add() function that adds the site to the queue. I mostly have it down, however, the queue contents print twice and I don’t know why. My queue.go file is the main logic, while the test.go file adds some test sites to the queue. Here’s what both look like:


package queue 

import ( “fmt” “” )

var Queue = queue.New() var Input string = “”

func Main() { for {



func Add(site string) { Queue.Add(site) fmt.Println(Queue.Peek()) Queue.Remove() }


package test 

import ( “time” “crawler/modules/queue” )

func Main() { queue.Add(“”) queue.Add(“”) time.Sleep(2000 * time.Millisecond) queue.Add(“”) }


submitted by /u/bmw417
[link] [comments]

Article Tags:
· ·
Article Categories:

Leave a Reply