The Go Playground Imports embed package main import ( "fmt" ) type PriorityQueue struct { high chan string low chan string } func (pq *PriorityQueue) NextItem() string { if len(pq.high) > 0 { return <-pq.high } var item string select { case item = <-pq.high: case item = <-pq.low: } return item } func NewPriorityQueue() *PriorityQueue { return &PriorityQueue{ high: make(chan string, 10), low: make(chan string, 10), } } func main() { pq := NewPriorityQueue() pq.low <- "I'm first, at LOW 1" pq.low <- "LOW 2" pq.high <- "HIGH 1" pq.high <- "HIGH 2" pq.high <- "HIGH 3" fmt.Println(pq.NextItem()) pq.high <- "HIGH 4" pq.low <- "LOW3" fmt.Println(pq.NextItem()) fmt.Println(pq.NextItem()) fmt.Println(pq.NextItem()) pq.high <- "HIGH 5" fmt.Println(pq.NextItem()) fmt.Println(pq.NextItem()) fmt.Println(pq.NextItem()) fmt.Printl...