You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: listener.go
    path of file: ./repos/inbucket/pkg/server/smtp
    
    the code of the file until where you have to start completion: package smtp

import (
	"container/list"
	"context"
	"crypto/tls"
	"expvar"
	"net"
	"sync"
	"time"

	"github.com/inbucket/inbucket/v3/pkg/config"
	"github.com/inbucket/inbucket/v3/pkg/extension"
	"github.com/inbucket/inbucket/v3/pkg/message"
	"github.com/inbucket/inbucket/v3/pkg/metric"
	"github.com/inbucket/inbucket/v3/pkg/policy"
	"github.com/rs/zerolog/log"
)

var (
	// Raw stat collectors
	expConnectsTotal   = new(expvar.Int)
	expConnectsCurrent = new(expvar.Int)
	expReceivedTotal   = new(expvar.Int)
	expErrorsTotal     = new(expvar.Int)
	expWarnsTotal      = new(expvar.Int)

	// History of certain stats
	deliveredHist = list.New()
	connectsHist  = list.New()
	errorsHist    = list.New()
	warnsHist     = list.New()

	// History rendered as comma delim str
    
func (s *Server) Start(ctx context.Context, readyFunc func()) {
	slog := log.With().Str("module", "smtp").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.notify <- err
		close(s.notify)
		return
	}
	slog.Info().Str("addr", addr.String()).Msg("SMTP listening on tcp4")
	if s.config.ForceTLS {
		s.listener, err = tls.Listen("tcp4", addr.String(), s.tlsConfig)
	} else {
		s.listener, err = net.ListenTCP("tcp4", addr)
	}
	if err != nil {
		slog.Error().Err(err).Msg("Failed to start tcp4 listener")
		s.notify <- err
		close(s.notify)
		return
	}

	// Start listener go routine.
	go s.serve(ctx)
	readyFunc()

	// Wait for shutdown.
	<-ctx.Done()
	slog = log.With().Str("module", "smtp").Str("phase", "shutdown").Logger()
	slog.Debug().Msg("SMTP shutdown requested, connections will be drained")

	// Closing the listener will cause the serve() go routine to exit.
	if err := s.listener.Close(); err != nil {
		slog.Error().Err(err).Msg("Failed to close SMTP listener")
	}
}