Documentation
¶
Index ¶
- Variables
- func AnalyzeCacheProductsValidity(cmd *cobra.Command)
- func CheckCacheTimeAndUpdateGeneric(modTime time.Time, maxAge time.Duration, cmd *cobra.Command)
- func CreateDoNotEditFile() error
- func EnsureCacheExistsGeneric(cachePath string, cmd *cobra.Command) (os.FileInfo, error)
- func FetchAndSaveCategories(cmd *cobra.Command) error
- func FetchAndSaveProducts(cmd *cobra.Command) error
- func FetchAndSaveTags(cmd *cobra.Command) error
- func GetAPIResponse(url string) (*http.Response, error)
- func GetCategoriesPath() (string, error)
- func GetLatestVersionFromGitHub() string
- func GetProductsPath() (string, error)
- func GetTagsPath() (string, error)
- func InitLogger(logLevel string)
- func RefreshAllCaches(cmd *cobra.Command)
- func RemoveFileIfExists(path string) error
- func TodayDateString() string
- type CategoriesFile
- type Category
- type Product
- type ProductsFile
- type Tag
- type TagsFile
Constants ¶
This section is empty.
Variables ¶
var ( Version string Commit string Date string BuiltBy string GoVersion string PlatformOs string PlatformArch string )
Variables initialized from main package at runtime
var APIUrl = "https://endoflife.date/api/v1/"
Functions ¶
func CheckCacheTimeAndUpdateGeneric ¶
CheckCacheTimeAndUpdateGeneric logs the cache mod time and updates the cache if older than maxAge using RefreshAllCaches.
func CreateDoNotEditFile ¶
func CreateDoNotEditFile() error
CreateDoNotEditFile creates a DO_NOT_EDIT_ANYTHING file in the geol config directory to warn users not to edit anything there.
func EnsureCacheExistsGeneric ¶
ensureCacheExistsGeneric checks if the cache file exists, creates it if missing using RefreshAllCaches, and returns its FileInfo or an error.
func FetchAndSaveCategories ¶
func FetchAndSaveProducts ¶
func FetchAndSaveTags ¶
func GetAPIResponse ¶
GetAPIResponse performs an HTTP GET request to the given URL and returns the response if status is 200. The caller is responsible for closing the response body.
func GetCategoriesPath ¶
func GetLatestVersionFromGitHub ¶
func GetLatestVersionFromGitHub() string
GetLatestVersionFromGitHub fetches the latest release tag from GitHub
func GetProductsPath ¶
GetProductsPath returns the path to the products.json file in the user's config directory.
func GetTagsPath ¶
func InitLogger ¶
func InitLogger(logLevel string)
func RefreshAllCaches ¶
RefreshAllCaches runs all cache refresh functions and exits with code 1 if any fail.
func RemoveFileIfExists ¶
RemoveFileIfExists removes the file at the given path if it exists. Returns nil if the file does not exist or is successfully removed.
func TodayDateString ¶
func TodayDateString() string
TodayDateString retourne la date du jour au format YYYY-MM-DD
Types ¶
type CategoriesFile ¶
func GetCategoriesWithCacheRefresh ¶
func GetCategoriesWithCacheRefresh(cmd *cobra.Command, categoriesPath string) (CategoriesFile, error)
GetCategoriesWithCacheRefresh tries to unmarshal categories from file, refreshes cache if needed, and returns the categories.
type ProductsFile ¶
func GetProductsWithCacheRefresh ¶
func GetProductsWithCacheRefresh(cmd *cobra.Command, productsPath string) (ProductsFile, error)
GetProductsWithCacheRefresh tries to unmarshal products from file, refreshes cache if needed, and returns the products.
type Tag ¶
func ConvertTagStringsToTags ¶
ConvertTagStringsToTags converts a slice of tag strings to a slice of Tag structs