Starting work on go version of chapter 2 examples
This commit is contained in:
parent
18a9674ec2
commit
1991c87ba9
@ -1,2 +1,2 @@
|
|||||||
export GOPATH="$GOROOT:$HOME/src/box-o-sand/src/sylvilagus"
|
export GOPATH="$GOROOT:$HOME/src/box-o-sand/src/sylvilagus/go"
|
||||||
test -n "$GOROOT" && source "$GOROOT/misc/bash/go"
|
test -n "$GOROOT" && source "$GOROOT/misc/bash/go"
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
CLEAN_GOPATH := $(shell echo $(GOPATH) | tr ":" "\n" | grep -v '^$$' | grep -v $(PWD) | tr "\n" ":")
|
CLEAN_GOPATH := $(shell echo $(GOPATH) | tr ":" "\n" | grep -v '^$$' | grep -v $(PWD) | tr "\n" ":")
|
||||||
GOPATH := $(PWD):$(CLEAN_GOPATH)
|
GOPATH := $(PWD):$(CLEAN_GOPATH)
|
||||||
PACKAGES := meatballhat.com/sylvilagus-conntest
|
PACKAGES := \
|
||||||
|
meatballhat.com/sylvilagus-conntest \
|
||||||
|
meatballhat.com/sylvilagus-chapter02-hello-world-consumer
|
||||||
|
|
||||||
export GOPATH
|
export GOPATH
|
||||||
|
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
)
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/streadway/amqp"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
connection, err := amqp.Dial("amqp://guest:guest@localhost:5672")
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Failed to connect!: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer connection.Close()
|
||||||
|
|
||||||
|
channel, err := connection.Channel()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Failed to get channel!: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = channel.ExchangeDeclare("hello-exchange", "direct", true, false, false, false, nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Failed to declare exchange!: ", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = channel.QueueBind("hello-queue", "hola", "hello-exchange", false, nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Failed to bind to queue!: ", err)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user