Attempting to correct Go project layout

This commit is contained in:
Dan Buch
2012-12-01 18:34:55 -05:00
parent bbb709be31
commit 80e5b8fa5e
6 changed files with 9 additions and 24 deletions

View File

@@ -0,0 +1,45 @@
package main
import (
"log"
)
import (
"github.com/streadway/amqp"
"meatballhat.com/sylvilagus"
)
func main() {
connection, err := amqp.Dial(sylvilagus.AMQP_URI)
if err != nil {
log.Fatal("Failed to connect!: ", err)
}
defer connection.Close()
channel, err := sylvilagus.CreateHelloTopology(connection)
if err != nil {
log.Fatal("Failed to build topology!: ", err)
}
hellos, err := channel.Consume("hello-queue", "hello-consumer", false, false, false, false, nil)
if err != nil {
log.Fatal("Failed to start consuming!:", err)
}
quit := make(chan bool)
go func(quit chan bool) {
log.Println("Consuming...")
for hello := range hellos {
log.Printf("hello -> %v\n", string(hello.Body))
hello.Ack(false)
if string(hello.Body) == "quit" {
quit <- true
return
}
}
}(quit)
<-quit
}