formatter

package
v0.1.13 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT, MIT Imports: 5 Imported by: 0

Documentation

Overview

Package formatter implements some functions to format string, struct.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Comma

func Comma[T constraints.Float | constraints.Integer | string](value T, symbol string) string

Comma add comma to a number value by every 3 numbers from right. ahead by symbol char. if value is invalid number string eg "aa", return empty string Comma("12345", "$") => "$12,345", Comma(12345, "$") => "$12,345" Play: https://golang.ir/play/p/eRD5k2vzUVX

Example
result1 := Comma("123", "")
result2 := Comma("12345", "$")
result3 := Comma(1234567, "¥")

fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
Output:

123
$12,345
¥1,234,567

Types

This section is empty.

Jump to

Keyboard shortcuts

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