@@ -3,6 +3,7 @@ package main
33import (
44 "log"
55 "os"
6+ "strconv"
67 "sync"
78
89 "github.com/Voldemat/go-smtp-mock/server"
@@ -17,8 +18,12 @@ func main() {
1718 if smtpHost == "" {
1819 log .Fatal ("SMTP_HOST is not defined" )
1920 }
20- smtpPort := os .Getenv ("SMTP_PORT" )
21- if smtpPort == "" {
21+ smtpPortString := os .Getenv ("SMTP_PORT" )
22+ if smtpPortString == "" {
23+ log .Fatal ("SMTP_PORT is not defined" )
24+ }
25+ smtpPort , err := strconv .ParseInt (smtpPortString , 10 , 64 )
26+ if err != nil {
2227 log .Fatal ("SMTP_PORT is not defined" )
2328 }
2429 smtpUser := os .Getenv ("SMTP_USER" )
@@ -29,18 +34,27 @@ func main() {
2934 if smtpPassword == "" {
3035 log .Fatal ("SMTP_PASSWORD is not defined" )
3136 }
37+ httpPortString := os .Getenv ("SMTP_HTTP_PORT" )
38+ if httpPortString == "" {
39+ log .Fatal ("SMTP_HTTP_PORT is not defined" )
40+ }
41+ httpPort , err := strconv .ParseInt (httpPortString , 10 , 64 )
42+ if err != nil {
43+ log .Fatal ("SMTP_HTTP_PORT is not defined" )
44+ }
3245 var wg sync.WaitGroup
3346 wg .Add (2 )
3447
35- server .CreateServerRoutines (
36- & wg ,
37- queueSize ,
38- smtpHost ,
39- smtpPort ,
40- smtpUser ,
41- smtpPassword ,
42- os .Getenv ("HTTP_HOST" ),
43- os .Getenv ("HTTP_PORT" ),
44- )
45- wg .Wait ()
48+ server .CreateServerRoutines (server.CreateServerRoutinesArgs {
49+ Wg : & wg ,
50+ SmtpHost : smtpHost ,
51+ SmtpPort : int (smtpPort ),
52+ SmtpUser : smtpUser ,
53+ SmtpPassword : smtpPassword ,
54+ HttpHost : os .Getenv ("HTTP_HOST" ),
55+ HttpPort : int (httpPort ),
56+ QueueSize : queueSize ,
57+ },
58+ )
59+ wg .Wait ()
4660}
0 commit comments