From 739113ef9e9359aa745eb5d0b25632a5b5e932d3 Mon Sep 17 00:00:00 2001 From: dudaodong Date: Sun, 30 Jan 2022 19:04:07 +0800 Subject: [PATCH] docs: add doc for package formatter --- docs/formatter.md | 53 +++++++++++++++++++++++++++++++++++++++++ docs/formatter_zh-CN.md | 52 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 docs/formatter.md create mode 100644 docs/formatter_zh-CN.md diff --git a/docs/formatter.md b/docs/formatter.md new file mode 100644 index 0000000..c07e940 --- /dev/null +++ b/docs/formatter.md @@ -0,0 +1,53 @@ +# Formatter +formatter contains some functions for data formatting. + +
+ +## Source: + +[https://github.com/duke-git/lancet/blob/main/formatter/formatter.go](https://github.com/duke-git/lancet/blob/main/formatter/formatter.go) + +
+ +## Usage: +```go +import ( + "github.com/duke-git/lancet/formatter" +) +``` + +
+ +## Index +- [Comma](#Comma) + +
+ +## Documentation + + + +### Comma +

Add comma to number by every 3 numbers from right. ahead by symbol char. +Param should be number or numberic string.

+ +Signature: + +```go +func Comma(v interface{}, symbol string) string +``` +Example: + +```go +package main + +import ( + "fmt" + "github.com/duke-git/lancet/formatter" +) + +func main() { + fmt.Println(formatter.Comma("12345", "")) // "12,345" + fmt.Println(formatter.Comma(12345.67, "¥")) // "¥12,345.67" +} +``` diff --git a/docs/formatter_zh-CN.md b/docs/formatter_zh-CN.md new file mode 100644 index 0000000..4b178ae --- /dev/null +++ b/docs/formatter_zh-CN.md @@ -0,0 +1,52 @@ +# Formatter +formatter格式化器包含一些数据格式化处理方法。 + +
+ +## 源码: + +[https://github.com/duke-git/lancet/blob/main/formatter/formatter.go](https://github.com/duke-git/lancet/blob/main/formatter/formatter.go) + +
+ +## 用法: +```go +import ( + "github.com/duke-git/lancet/formatter" +) +``` + +
+ +## 目录 +- [Comma](#Comma) + +
+ +## 文档 + + + +### Comma +

用逗号每隔3位分割数字/字符串,签名添加符号。参数必须是数字或者可以转为数字的字符串

+ +函数签名: + +```go +func Comma(v interface{}, symbol string) string +``` +例子: + +```go +package main + +import ( + "fmt" + "github.com/duke-git/lancet/formatter" +) + +func main() { + fmt.Println(formatter.Comma("12345", "")) // "12,345" + fmt.Println(formatter.Comma(12345.67, "¥")) // "¥12,345.67" +} +```