Documentation
¶
Index ¶
- func CalculatePercentage(value, total int, decimalPlaces int) float64
- func FindFileInSourceDirs(relativePath string, sourceDirs []string, reader filereader.Reader, ...) (string, error)
- func FormatPercentage(percentage float64, decimalPlaces int) string
- func IsValidUnixSeconds(ts int64) bool
- func SortByLineAndName[T SortableByLineAndName](slice []T)
- type SortableByLineAndName
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CalculatePercentage ¶
CalculatePercentage calculates (value / total) * 100 with specific truncation. decimalPlaces controls the number of decimal places in the result. Mimics C# ReportGenerator.Core.Common.MathExtensions.CalculatePercentage.
func FindFileInSourceDirs ¶
func FindFileInSourceDirs(relativePath string, sourceDirs []string, reader filereader.Reader, logger *slog.Logger) (string, error)
FindFileInSourceDirs resolves a file path from a report against a list of source directories.
func FormatPercentage ¶
FormatPercentage formats a float64 percentage value (0-100) as a string with a specific number of decimal places, appending "%". Handles NaN by returning "N/A".
func IsValidUnixSeconds ¶
isValidUnixSeconds checks if a timestamp (in seconds) is within a reasonable range. E.g., between 1975-01-01 and 2100-01-01.
func SortByLineAndName ¶
func SortByLineAndName[T SortableByLineAndName](slice []T)
SortByLineAndName sorts a slice of items that implement SortableByLineAndName. Items are sorted by their first line number, then by their sortable name. Items with a FirstLine of 0 (or less) are typically pushed to the end or handled as per specific needs. This implementation pushes items with FirstLine 0 to the end if other items have non-zero FirstLine.
Types ¶
type SortableByLineAndName ¶
type SortableByLineAndName interface {
GetFirstLine() int
GetSortableName() string // This should return a name suitable for lexicographical sorting.
}
SortableByLineAndName defines an interface for items that can be sorted primarily by their first line number and secondarily by a sortable name.