shared

package
v0.0.0-...-df769fd Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package shared provides common helper functions used across commands, mcpserver, and tui packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractNutritionBlock

func ExtractNutritionBlock(payload any) any

ExtractNutritionBlock walks a JSON payload recursively and returns the first value whose key contains "nutrition", "nutri", or "odzyw" (case-insensitive).

func FormatMoneyValue

func FormatMoneyValue(v any) string

FormatMoneyValue formats a single numeric or string value as a money string. Unlike MoneyString, this does not recurse into maps with domain-specific keys like "_total" or "FRS"; it only handles the leaf value types and a generic map with "price"/"gross"/"amount"/"value" keys.

func LocalizedString

func LocalizedString(v any) string

LocalizedString extracts a string from a value that may be a plain string, a locale map (e.g. {"pl": "...", "en": "..."}), or another nested structure. It prefers "pl", then "en".

func MoneyString

func MoneyString(v any) string

MoneyString converts a value (number, string, or nested price map) to a formatted money string like "12.34". Returns "" when no value can be extracted.

func ProductNameFromMap

func ProductNameFromMap(m map[string]any) string

ProductNameFromMap extracts a human-readable product name from a map, trying common Frisco API key names in priority order.

func StringFieldFromMap

func StringFieldFromMap(m map[string]any, keys ...string) string

StringFieldFromMap looks up the first non-empty string value from a map trying each key in order.

func TruncateText

func TruncateText(s string, maxLen int) string

TruncateText truncates a string to max runes, appending "..." if shortened.

Types

This section is empty.

Jump to

Keyboard shortcuts

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