Skip to content

Commit

Permalink
Refactor TLSPolicy documentation and String method
Browse files Browse the repository at this point in the history
Updated the TLSPolicy type documentation to improve clarity and consistency. Enhanced the String method with detailed commentary and return value explanation, ensuring it better adheres to the fmt.Stringer interface.
  • Loading branch information
wneessen committed Oct 6, 2024
1 parent 6ce5c2a commit f0388ec
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,32 @@

package mail

// TLSPolicy type describes a int alias for the different TLS policies we allow
// TLSPolicy is a type wrapper for an int type and describes the different TLS policies we allow.
type TLSPolicy int

const (
// TLSMandatory requires that the connection to the server is
// encrypting using STARTTLS. If the server does not support STARTTLS
// the connection will be terminated with an error
// the connection will be terminated with an error.
TLSMandatory TLSPolicy = iota

// TLSOpportunistic tries to establish an encrypted connection via the
// STARTTLS protocol. If the server does not support this, it will fall
// back to non-encrypted plaintext transmission
// back to non-encrypted plaintext transmission.
TLSOpportunistic

// NoTLS forces the transaction to be not encrypted
// NoTLS forces the transaction to be not encrypted.
NoTLS
)

// String is a standard method to convert a TLSPolicy into a printable format
// String satisfies the fmt.Stringer interface for the TLSPolicy type.
//
// This function returns a string representation of the TLSPolicy. It matches the policy
// value to predefined constants and returns the corresponding string. If the policy does
// not match any known values, it returns "UnknownPolicy".
//
// Returns:
// - A string representing the TLSPolicy.
func (p TLSPolicy) String() string {
switch p {
case TLSMandatory:
Expand Down

0 comments on commit f0388ec

Please sign in to comment.