Documentation
¶
Index ¶
- Constants
- func ComparePtrString(a, b *string) bool
- func ConvertFromGrams(weight float64, toUnit string) float64
- func ConvertToGrams(weight float64, fromUnit string) float64
- func ConvertWeightUnit(unit string) string
- func FormatWeight(weightInGrams float64, displayUnit string) string
- func GenerateRandomCode(length int) (string, error)
- func IsValidEmail(email string) bool
- func LogAndSanitize(err error, context string) string
- func StringToUint(s string) (uint, error)
- type EmailSender
- type SMTPClient
Constants ¶
View Source
const ( ErrMsgInternalServer = "Internal server error" ErrMsgNotFound = "Resource not found" ErrMsgBadRequest = "Invalid request" ErrMsgForbidden = "Access forbidden" )
Safe error messages for clients
View Source
const ( // Grams to other units GramsPerOunce = 28.3495 GramsPerPound = 453.592 )
Weight conversion constants
Variables ¶
This section is empty.
Functions ¶
func ComparePtrString ¶ added in v0.11.0
func ConvertFromGrams ¶ added in v0.9.0
ConvertFromGrams converts a weight from grams to the specified unit
func ConvertToGrams ¶ added in v0.9.0
ConvertToGrams converts a weight from any unit to grams
func ConvertWeightUnit ¶
func FormatWeight ¶ added in v0.9.0
FormatWeight formats a weight in grams to a human-readable string
func GenerateRandomCode ¶ added in v0.3.0
func IsValidEmail ¶ added in v0.4.1
func LogAndSanitize ¶ added in v0.16.0
LogAndSanitize logs the actual error internally and returns a safe message for the client
func StringToUint ¶
Types ¶
type EmailSender ¶ added in v0.3.0
EmailSender defines the interface for sending emails. Needed for testing without real SMTP server.
type SMTPClient ¶ added in v0.3.0
type SMTPClient struct {
Server config.MailServer
}
SMTPClient struct implements EmailSender interface.
func (*SMTPClient) SendEmail ¶ added in v0.3.0
func (s *SMTPClient) SendEmail(to, subject, body string) error
SendMail sends an email using the SMTP protocol.
Click to show internal directories.
Click to hide internal directories.