Files
2025-03-14 17:50:02 +03:00

27 lines
444 B
Go

package output
import "github.com/fatih/color"
func PrintError(value any) {
switch t := value.(type) {
case string:
color.Red(t)
case int:
color.Red("Код ошибки: %d", t)
case error:
color.Red(t.Error())
default:
color.Red("Неизвестный тип ошибки")
}
}
// Generic
func Sum[T int | float32 | float64 | string](a, b T) T {
return a + b
}
// Generic structs
type List[T any] struct {
elements []T
}