-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
43 lines (36 loc) · 864 Bytes
/
config.go
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
package gol
import (
"strings"
"github.com/go-ozzo/ozzo-validation"
)
// Config represents the redis configuration for golw logger.
type Config struct {
ListName string
LogService *Service
}
// Validate validates the struct.
func (c Config) Validate() error {
return validation.ValidateStruct(
&c,
validation.Field(&c.ListName, validation.Required),
validation.Field(&c.LogService),
)
}
// Service represents the service configuration
type Service struct {
Host string
Port string
Path string
}
// Validate validates the struct.
func (s Service) Validate() error {
return validation.ValidateStruct(
&s,
validation.Field(&s.Host, validation.Required),
validation.Field(&s.Port, validation.Required),
)
}
// Domain returns the service's domain.
func (s Service) Domain() string {
return strings.Join([]string{s.Host, s.Port}, ":")
}