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 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 ApiUrl = "https://endoflife.date/api/v1/"
Functions ¶
func AnalyzeCacheProductsValidity ¶ added in v1.1.0
func CheckCacheTimeAndUpdateGeneric ¶ added in v1.1.0
CheckCacheTimeAndUpdateGeneric logs the cache mod time and updates the cache if older than maxAge using RefreshAllCaches.
func CreateDoNotEditFile ¶ added in v1.1.0
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 ¶ added in v1.3.0
ensureCacheExistsGeneric checks if the cache file exists, creates it if missing using RefreshAllCaches, and returns its FileInfo or an error.
func FetchAndSaveCategories ¶ added in v1.1.0
func FetchAndSaveProducts ¶
func FetchAndSaveTags ¶ added in v1.1.0
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 ¶ added in v1.1.0
func GetProductsPath ¶
GetProductsPath returns the path to the products.json file in the user's config directory.
func GetTagsPath ¶ added in v1.1.0
func InitLogger ¶
func InitLogger(logLevel string)
func RefreshAllCaches ¶ added in v1.1.0
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 ¶ added in v1.1.0
func GetCategoriesWithCacheRefresh ¶ added in v1.1.0
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.