func (s *Server) Start(ctx context.Context) {
	slog := log.With().Str("module", "pop3").Str("phase", "startup").Logger()
	addr, err := net.ResolveTCPAddr("tcp4", s.config.Addr)
	if err != nil {
		slog.Error().Err(err).Msg("Failed to build tcp4 address")
		s.emergencyShutdown()
		return
	}
	slog.Info().Str("addr", addr.String()).Msg("POP3 listening on tcp4")
	s.listener, err = net.ListenTCP("tcp4", addr)
	if err != nil {
		slog.Error().Err(err).Msg("Failed to start tcp4 listener")
		s.emergencyShutdown()
		return
	}
	go s.serve(ctx)
	select {
	case _ = <-ctx.Done():
	}
	slog = log.With().Str("module", "pop3").Str("phase", "shutdown").Logger()
	slog.Debug().Msg("POP3 shutdown requested, connections will be drained")
	if err := s.listener.Close(); err != nil {
		slog.Error().Err(err).Msg("Failed to close POP3 listener")
	}
}
Start the server and listen for connections
package pop3
import (
	"context"
	"net"
	"sync"
	"time"
	"github.com/inbucket/inbucket/pkg/config"
	"github.com/inbucket/inbucket/pkg/storage"
	"github.com/rs/zerolog/log"
)
type Server struct {
	config         config.POP3      
	store          storage.Store    
	listener       net.Listener     
	globalShutdown chan bool        
	wg             *sync.WaitGroup  
}
func New(pop3Config config.POP3, shutdownChan chan bool, store storage.Store) *Server {
	return &Server{
		config:         pop3Config,
		store:          store,
		globalShutdown: shutdownChan,
		wg:             new(sync.WaitGroup),
	}
}