utilities

package
v2.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 3, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version      string
	Commit       string
	Date         string
	BuiltBy      string
	GoVersion    string
	PlatformOs   string
	PlatformArch string
)

Variables initialized from main package at runtime

View Source
var APIUrl = "https://endoflife.date/api/v1/"

Functions

func AnalyzeCacheProductsValidity

func AnalyzeCacheProductsValidity(cmd *cobra.Command)

func CheckCacheTimeAndUpdateGeneric

func CheckCacheTimeAndUpdateGeneric(modTime time.Time, maxAge time.Duration, cmd *cobra.Command)

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

func EnsureCacheExistsGeneric(cachePath string, cmd *cobra.Command) (os.FileInfo, error)

ensureCacheExistsGeneric checks if the cache file exists, creates it if missing using RefreshAllCaches, and returns its FileInfo or an error.

func FetchAndSaveCategories

func FetchAndSaveCategories(cmd *cobra.Command) error

func FetchAndSaveProducts

func FetchAndSaveProducts(cmd *cobra.Command) error

func FetchAndSaveTags

func FetchAndSaveTags(cmd *cobra.Command) error

func GetAPIResponse

func GetAPIResponse(url string) (*http.Response, error)

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 GetCategoriesPath() (string, error)

func GetLatestVersionFromGitHub

func GetLatestVersionFromGitHub() string

GetLatestVersionFromGitHub fetches the latest release tag from GitHub

func GetProductsPath

func GetProductsPath() (string, error)

GetProductsPath returns the path to the products.json file in the user's config directory.

func GetTagsPath

func GetTagsPath() (string, error)

func InitLogger

func InitLogger(logLevel string)

func RefreshAllCaches

func RefreshAllCaches(cmd *cobra.Command)

RefreshAllCaches runs all cache refresh functions and exits with code 1 if any fail.

func RemoveFileIfExists

func RemoveFileIfExists(path string) error

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

type CategoriesFile map[string]string

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 Category

type Category struct {
	Name string `json:"name"`
	Uri  string `json:"uri"`
}

type Product

type Product struct {
	Name    string   `json:"name"`
	Aliases []string `json:"aliases"`
}

Product represents a product with its name and aliases from the API.

type ProductsFile

type ProductsFile struct {
	Products map[string][]string `json:"products"`
}

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

type Tag struct {
	Name string `json:"name"`
	Uri  string `json:"uri"`
}

func ConvertTagStringsToTags

func ConvertTagStringsToTags(tagStrings []string) []Tag

ConvertTagStringsToTags converts a slice of tag strings to a slice of Tag structs

type TagsFile

type TagsFile map[string]string

func GetTagsWithCacheRefresh

func GetTagsWithCacheRefresh(cmd *cobra.Command, tagsPath string) (TagsFile, error)

GetTagsWithCacheRefresh tries to unmarshal tags from file, refreshes cache if needed, and returns the tags.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL