Skip to content

Commit

Permalink
Update xutil
Browse files Browse the repository at this point in the history
  • Loading branch information
onanying committed May 5, 2023
1 parent 79a80f4 commit d36cf92
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
31 changes: 28 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ xstrings.IsNumeric(s string) bool

## xfmt

可以打印指针字段内部的数据结构,支持的方法与 `fmt` 系统库完全一致,[查看更多用法](xfmt/README.md)
可以打印结构体嵌套指针地址内部数据的格式化库,[查看更多](xfmt/README.md)

支持的方法与 `fmt` 系统库完全一致

- `Sprintf(format string, args ...interface{}) string`
- `Sprint(args ...interface{}) string`
Expand All @@ -65,11 +67,34 @@ xstrings.IsNumeric(s string) bool
- `Print(args ...interface{})`
- `Println(args ...interface{})`

动态停用和启用

```go
xfmt.Disable() // 停用后xfmt等同于fmt
xfmt.Enable()
```

## xenv

具有类型转换功能的环境配置库,[查看更多用法](xenv/README.md)
具有类型转换功能的环境配置库,[查看更多](xenv/README.md)

载入 `.env` 到环境变量

~~~go
_ = xenv.Load(".env")
_ = xenv.Overload(".env")
~~~

获取环境变量

~~~go
i := xenv.Getenv("key").String()
i := xenv.Getenv("key").Bool()
i := xenv.Getenv("key").Int64()
i := xenv.Getenv("key").Float64()
~~~

获取环境变量并设置默认值
设置默认值

~~~go
i := xenv.Getenv("key").String("default")
Expand Down
7 changes: 4 additions & 3 deletions xenv/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
> OpenMix 出品:[https://openmix.org](https://openmix.org/mix-go)
## Mix XEnv

基于 [GoDotEnv](https://github.com/joho/godotenv) 开发的具有**类型转换功能**的环境配置库
## Mix XENV

Based on GoDotEnv library, with type conversion function

基于 [GoDotEnv](https://github.com/joho/godotenv) 开发的具有**类型转换功能**的环境配置库

## Usage

载入 `.env` 到环境变量

~~~go
_ = xenv.Load(".env")
_ = xenv.Overload(".env")
~~~

获取环境变量
Expand Down
6 changes: 1 addition & 5 deletions xfmt/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@
## Mix XFMT

可以打印结构体嵌套指针地址内部数据的格式化库

Formatting library that can print the internal data of the nested pointer address of the struct

## Overview

在 Golang 中使用 `fmt` 打印结构体时,无法打印指针字段内部的数据结构,导致增加 debug 难度,该库可以解决这个问题。
可以打印结构体嵌套指针地址内部数据的格式化库

## Usage

Expand Down

0 comments on commit d36cf92

Please sign in to comment.