From 704d34eeaa363069810099c465de694243426077 Mon Sep 17 00:00:00 2001 From: Zapharaos Date: Wed, 29 Jan 2025 05:07:33 +0100 Subject: [PATCH] feat(docs): pkg doc files --- pkg/email/doc.go | 27 +++++++++++++++++++++++++++ pkg/email/templates/doc.go | 31 +++++++++++++++++++++++++++++++ pkg/env/doc.go | 32 ++++++++++++++++++++++++++++++++ pkg/translation/doc.go | 30 ++++++++++++++++++++++++++++++ 4 files changed, 120 insertions(+) create mode 100644 pkg/email/doc.go create mode 100644 pkg/email/templates/doc.go create mode 100644 pkg/env/doc.go create mode 100644 pkg/translation/doc.go diff --git a/pkg/email/doc.go b/pkg/email/doc.go new file mode 100644 index 0000000..f4e0883 --- /dev/null +++ b/pkg/email/doc.go @@ -0,0 +1,27 @@ +// Package email provides functionality for sending emails. +// +// This package defines an interface for email services, allowing for different implementations. +// The default implementation uses the SendGrid service to send emails. +// +// In your main.go or application initialization file, you can initialize the email service like this: +// +// package main +// +// import ( +// "github.com/Zapharaos/fihub-backend/pkg/email" +// ) +// +// func main() { +// // Initialize the email service +// emailService := email.NewSendgridService() +// +// // Replace the global email service instance +// email.ReplaceGlobals(emailService) +// } +// +// To send an email: +// +// err := service.Send("recipient@example.com", "Subject", "Plain text content", "HTML content") +// +// For more information, see the documentation for the SendGrid library. +package email diff --git a/pkg/email/templates/doc.go b/pkg/email/templates/doc.go new file mode 100644 index 0000000..c6ef74b --- /dev/null +++ b/pkg/email/templates/doc.go @@ -0,0 +1,31 @@ +// Package templates provides functionality for managing email templates. +// +// This package provides a main HTML email layout. Multiple content templates can be created +// to be used as the main item inside the initial email layout. +// +// Usage: +// +// To define the main HTML content and set up its structure: +// +// htmlContentTemplate := templates.NewCustomTemplate(templates.CustomData{ +// Field1: "Hello", +// Field2: "$123456789", +// Field3: "29/01/2025", +// }) +// +// To set the variables for the initial email layout: +// +// labels := templates.LayoutLabels{ +// Help: "Help", +// Copyrights: "Copyrights", +// } +// +// To build the full email HTML content with the specified data: +// +// htmlContent, err := htmlContentTemplate.Build(labels) +// if err != nil { +// // Handle error +// } +// +// For more information, see the documentation for the text/template and html/template packages. +package templates diff --git a/pkg/env/doc.go b/pkg/env/doc.go new file mode 100644 index 0000000..df0ce7e --- /dev/null +++ b/pkg/env/doc.go @@ -0,0 +1,32 @@ +// Package env provides utilities for loading and retrieving environment variables. +// +// This package offers functions to load environment variables from a `.env` file and retrieve them +// as different types such as string, integer, boolean, and duration. +// +// Usage: +// +// To load environment variables from a `.env` file: +// +// err := env.Load() +// if err != nil { +// log.Fatal("Error loading .env file") +// } +// +// To retrieve an environment variable as a string: +// +// value := env.GetString("KEY", "default") +// +// To retrieve an environment variable as an integer: +// +// value := env.GetInt("KEY", 42) +// +// To retrieve an environment variable as a boolean: +// +// value := env.GetBool("KEY", true) +// +// To retrieve an environment variable as a duration: +// +// value := env.GetDuration("KEY", time.Second) +// +// For more information, see the documentation for the `github.com/joho/godotenv` library. +package env diff --git a/pkg/translation/doc.go b/pkg/translation/doc.go new file mode 100644 index 0000000..6a16604 --- /dev/null +++ b/pkg/translation/doc.go @@ -0,0 +1,30 @@ +// Package translation provides functionality for internationalization and localization. +// +// This package defines an interface for translation services, allowing for different implementations. +// The default implementation uses the go-i18n library to manage translations and localize messages. +// It supports multiple languages and allows for easy addition of new translations. +// +// In your main.go or application initialization file, you can initialize the translation service like this: +// +// package main +// +// import ( +// "github.com/Zapharaos/fihub-backend/pkg/translation" +// "golang.org/x/text/language" +// ) +// +// func main() { +// // Initialize the translation service +// translationService := translation.NewI18nService(language.English) +// +// // Replace the global translation service instance +// translation.ReplaceGlobals(translationService) +// } +// +// To get a localized message: +// +// localizer, _ := translation.S().Localizer(language.French) +// message := translation.S().Message(localizer, &translation.Message{ID: "HelloWorld"}) +// +// For more information, see the documentation for the go-i18n library. +package translation