Added error to return values in some functions
This commit is contained in:
parent
1881298825
commit
f7b37a7666
@ -5,10 +5,13 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func ParseAddr(addr string) (string, int) {
|
||||
func ParseAddr(addr string) (string, int, error) {
|
||||
p := strings.Split(addr, ":")
|
||||
fHost := p[0]
|
||||
fPort, _ := strconv.Atoi(p[1])
|
||||
|
||||
return fHost, fPort
|
||||
fPort, err := strconv.Atoi(p[1])
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return fHost, fPort, nil
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ type Logger struct {
|
||||
appName string
|
||||
}
|
||||
|
||||
func NewLogger(appName, fHost string, fPort int) *Logger {
|
||||
func NewLogger(appName, fHost string, fPort int) (*Logger, error) {
|
||||
config := fluent.Config{
|
||||
FluentHost: fHost,
|
||||
FluentPort: fPort,
|
||||
@ -20,10 +20,10 @@ func NewLogger(appName, fHost string, fPort int) *Logger {
|
||||
}
|
||||
fluent, err := fluent.New(config)
|
||||
if err != nil {
|
||||
log.Panicf("Error connecting to %s: %v", fHost, err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Logger{fluent, appName}
|
||||
return &Logger{fluent, appName}, nil
|
||||
}
|
||||
|
||||
func (l *Logger) Log(format string, v ...any) {
|
||||
|
@ -21,6 +21,6 @@ func Open(url string) (*amqp.Connection, *amqp.Channel, error) {
|
||||
return conn, ch, nil
|
||||
}
|
||||
|
||||
func Close(conn *amqp.Connection) {
|
||||
conn.Close()
|
||||
func Close(conn *amqp.Connection) error {
|
||||
return conn.Close()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user