fix: change directory and add readme
This commit is contained in:
parent
f4beaae3de
commit
619e954daa
|
@ -0,0 +1,56 @@
|
|||
<!--
|
||||
* @Date: 2021-03-21 19:54:57
|
||||
* @LastEditors: viletyy
|
||||
* @LastEditTime: 2021-06-10 14:29:28
|
||||
* @FilePath: /yolk/README.md
|
||||
-->
|
||||
# Yolk
|
||||
|
||||
[![viletyy yolk](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/viletyy/yolk)
|
||||
|
||||
Go项目公共包
|
||||
|
||||
在开发项目中,经常使用的方法。
|
||||
|
||||
本公共包包含以下内容:
|
||||
|
||||
1. 数据类型转换。
|
||||
2. 常用加解密算法。
|
||||
3. 文件夹辅助方法。
|
||||
4. 分页。
|
||||
5. 随机字符串。
|
||||
|
||||
## 内容列表
|
||||
|
||||
- [Yolk](#yolk)
|
||||
- [内容列表](#内容列表)
|
||||
- [安装](#安装)
|
||||
- [使用说明](#使用说明)
|
||||
- [如何贡献](#如何贡献)
|
||||
- [使用许可](#使用许可)
|
||||
|
||||
## 安装
|
||||
|
||||
这个项目使用 [go](https://golang.org/) 。请确保你本地安装了它。
|
||||
|
||||
```sh
|
||||
$ tar -C /usr/local -xzf go1.4.linux-amd64.tar.gz
|
||||
$ export PATH=$PATH:/usr/local/go/bin
|
||||
```
|
||||
|
||||
## 使用说明
|
||||
|
||||
```sh
|
||||
$ go get -u github.com/viletyy/yolk
|
||||
$ go mod tidy
|
||||
$ go mod vendor
|
||||
```
|
||||
|
||||
## 如何贡献
|
||||
|
||||
非常欢迎你的加入![提一个 Issue](https://github.com/viletyy/yolk/issues/new) 或者提交一个 Pull Request。
|
||||
|
||||
|
||||
## 使用许可
|
||||
|
||||
[MIT](LICENSE) © Viletyy
|
|
@ -1,28 +1,17 @@
|
|||
/*
|
||||
* @Date: 2021-03-12 17:37:03
|
||||
* @Date: 2021-06-10 14:20:53
|
||||
* @LastEditors: viletyy
|
||||
* @LastEditTime: 2021-04-27 16:05:14
|
||||
* @FilePath: /yolk/helper.go
|
||||
* @LastEditTime: 2021-06-10 14:21:09
|
||||
* @FilePath: /yolk/convert/str_to.go
|
||||
*/
|
||||
package yolk
|
||||
package convert
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"reflect"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func GetRandomString(n int) string {
|
||||
const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
var bytes = make([]byte, n)
|
||||
rand.Read(bytes)
|
||||
for i, b := range bytes {
|
||||
bytes[i] = alphanum[b%byte(len(alphanum))]
|
||||
}
|
||||
return string(bytes)
|
||||
}
|
||||
|
||||
type StrTo string
|
||||
|
||||
func (f *StrTo) Set(v string) {
|
|
@ -1,10 +1,10 @@
|
|||
/*
|
||||
* @Date: 2021-03-22 10:45:37
|
||||
* @LastEditors: viletyy
|
||||
* @LastEditTime: 2021-04-29 11:44:54
|
||||
* @FilePath: /yolk/directory.go
|
||||
* @LastEditTime: 2021-06-10 14:25:28
|
||||
* @FilePath: /yolk/directory/directory.go
|
||||
*/
|
||||
package yolk
|
||||
package directory
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
@ -24,7 +24,7 @@ func PathExists(path string) (bool, error) {
|
|||
|
||||
func IsDir(f string) bool {
|
||||
fi, err := os.Stat(f)
|
||||
if err != nil {
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
return fi.IsDir()
|
|
@ -1,16 +1,18 @@
|
|||
/*
|
||||
* @Date: 2021-04-27 13:50:37
|
||||
* @LastEditors: viletyy
|
||||
* @LastEditTime: 2021-04-27 14:31:42
|
||||
* @FilePath: /yolk/paginator.go
|
||||
* @LastEditTime: 2021-06-10 14:23:35
|
||||
* @FilePath: /yolk/paginator/paginator.go
|
||||
*/
|
||||
package yolk
|
||||
package paginator
|
||||
|
||||
import (
|
||||
"math"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"github.com/viletyy/yolk/convert"
|
||||
)
|
||||
|
||||
type Paginator struct {
|
||||
|
@ -40,7 +42,7 @@ func (p *Paginator) Nums() int64 {
|
|||
}
|
||||
|
||||
func (p *Paginator) SetNums(nums interface{}) {
|
||||
p.nums, _ = ToInt64(nums)
|
||||
p.nums, _ = convert.ToInt64(nums)
|
||||
}
|
||||
|
||||
func (p *Paginator) Page() int {
|
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* @Date: 2021-06-10 14:24:22
|
||||
* @LastEditors: viletyy
|
||||
* @LastEditTime: 2021-06-10 14:24:36
|
||||
* @FilePath: /yolk/random/random.go
|
||||
*/
|
||||
package random
|
||||
|
||||
import "crypto/rand"
|
||||
|
||||
func RandomString(n int) string {
|
||||
const alphanum = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
|
||||
var bytes = make([]byte, n)
|
||||
rand.Read(bytes)
|
||||
for i, b := range bytes {
|
||||
bytes[i] = alphanum[b%byte(len(alphanum))]
|
||||
}
|
||||
return string(bytes)
|
||||
}
|
Loading…
Reference in New Issue