1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-07 14:12:28 +08:00

feat:add GetExeDllVersion for fileutil,random,package (#257)

* 增加GetExeDllVersion函数获取exe,dll版本号

* 多打文字

* 定位忘记...

* 单独剥离出来一个为windows的,增加RandNumLen为取指定长度随机数.

* ....

* 增加test测试
This commit is contained in:
今晚打打
2024-10-18 16:17:14 +08:00
committed by GitHub
parent 1671f7856a
commit ed93aae970
9 changed files with 171 additions and 5 deletions

View File

@@ -52,7 +52,7 @@ import (
- [ReadFile](#ReadFile)
- [ChunkRead](#ChunkRead)
- [ParallelChunkRead](#ParallelChunkRead)
- [GetVersion](#Version)
<div STYLE="page-break-after: always;"></div>
## 文档
@@ -1076,4 +1076,34 @@ func main() {
// Jim,21,male
// 2
}
```
### <span id="Version">GetExeDllVersion</span>
<p>返回exe,dll文件版本号(仅Window平台).</p>
<b>函数签名:</b>
```go
func GetExeDllVersion(filePath string) (string, error)
```
<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/s_Tl7lZoAaY)</span></b>
```go
package main
import (
"fmt"
"github.com/duke-git/lancet/v2/fileutil"
)
func main() {
v, err := fileutil.GetExeDllVersion(`C:\Program Files\Tencent\WeChat\WeChat.exe`)
if err != nil {
panic(err)
}
fmt.Println(v)
// Output:
// 3.9.10.19
}
```

View File

@@ -40,6 +40,7 @@ import (
- [RandStringSlice](#RandStringSlice)
- [RandBool](#RandBool)
- [RandBoolSlice](#RandBoolSlice)
- [RandNumLen](#RandNumLen)
<div STYLE="page-break-after: always;"></div>
@@ -522,4 +523,29 @@ func main() {
result := random.RandBoolSlice(2)
fmt.Println(result) // [true false] (random)
}
```
### <span id="RandNumLen">RandNumLen</span>
<p>生成指定长度的随机数</p>
<b>函数签名:</b>
```go
func RandNumLen(len int) int
```
<b>实例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/o-VSjPjnILI)</span></b>
```go
package main
import (
"fmt"
"github.com/duke-git/lancet/v2/random"
)
func main() {
i := random.RandNumLen(2)
fmt.Println(i)
}
```