-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
50 lines (40 loc) · 824 Bytes
/
main.go
File metadata and controls
50 lines (40 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"fmt"
"os"
"github.com/joho/godotenv"
"github.com/pkg/errors"
"github.com/streadway/amqp"
)
func main() {
if err := run(); err != nil {
fmt.Fprintf(os.Stderr, "%s\n", err)
os.Exit(1)
}
}
func run() error {
err := godotenv.Load(".env")
if err != nil {
return errors.Wrap(err, "environment variables")
}
amqpConn, err := newRabbitMQConn()
if err != nil {
return errors.Wrap(err, "rabbitmq")
}
defer amqpConn.Close()
srv := newServer(amqpConn)
return srv.run()
}
// The server type contains the dependencies of our server.
type server struct {
amqpConn *amqp.Connection
}
func newServer(amqpConn *amqp.Connection) *server {
return &server{amqpConn: amqpConn}
}
func (s *server) run() error {
forever := make(chan bool)
fmt.Println("Running")
<-forever
return nil
}