1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-18 11:42:26 +08:00

Compare commits

..

4 Commits

Author SHA1 Message Date
IceCafeCup
c95db23d2c feat: Set struct uses empty struct as value (#55) 2022-08-13 12:39:30 +08:00
Abirdcfly
fbf251d805 delete minor unreachable code caused by log.Fatal (#54)
Signed-off-by: Abirdcfly <fp544037857@gmail.com>
2022-08-10 14:19:21 +08:00
dudaodong
337f08a04b fix: issue #53 2022-08-06 17:41:45 +08:00
dudaodong
c6a7371049 change lastest v1 version 2022-08-03 10:02:46 +08:00
4 changed files with 4 additions and 13 deletions

View File

@@ -37,7 +37,7 @@ go get github.com/duke-git/lancet/v2 // will install latest version of v2.x.x
2. <b>For users who use version below go1.18, you should install v1.x.x. now latest v1 is v1.3.1. </b> 2. <b>For users who use version below go1.18, you should install v1.x.x. now latest v1 is v1.3.1. </b>
```go ```go
go get github.com/duke-git/lancet@v1.3.0 // below go1.18, install latest version of v1.x.x go get github.com/duke-git/lancet@v1.3.1 // below go1.18, install latest version of v1.x.x
``` ```
## Usage ## Usage

View File

@@ -37,7 +37,7 @@ go get github.com/duke-git/lancet/v2 //安装v2最新版本v2.x.x
2. <b>使用go1.18以下版本的用户必须安装v1.x.x。目前最新的v1版本是v1.3.1。</b> 2. <b>使用go1.18以下版本的用户必须安装v1.x.x。目前最新的v1版本是v1.3.1。</b>
```go ```go
go get github.com/duke-git/lancet@v1.3.0 // 使用go1.18以下版本, 必须安装v1.x.x版本 go get github.com/duke-git/lancet@v1.3.1 // 使用go1.18以下版本, 必须安装v1.x.x版本
``` ```
## 用法 ## 用法
@@ -489,7 +489,6 @@ import "github.com/duke-git/lancet/v2/validator"
- [IsUrl](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsUrl) - [IsUrl](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsUrl)
- [IsWeakPassword](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsWeakPassword) - [IsWeakPassword](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsWeakPassword)
validator.md#IsWeakPassword)
### 19. xerror包实现一些错误处理函数 ### 19. xerror包实现一些错误处理函数
```go ```go

View File

@@ -1,7 +1,7 @@
package datastructure package datastructure
// Set is a data container, like slice, but element of set is not duplicate // Set is a data container, like slice, but element of set is not duplicate
type Set[T comparable] map[T]bool type Set[T comparable] map[T]struct{}
// NewSet return a instance of set // NewSet return a instance of set
func NewSet[T comparable](values ...T) Set[T] { func NewSet[T comparable](values ...T) Set[T] {
@@ -13,7 +13,7 @@ func NewSet[T comparable](values ...T) Set[T] {
// Add value to set // Add value to set
func (s Set[T]) Add(values ...T) { func (s Set[T]) Add(values ...T) {
for _, v := range values { for _, v := range values {
s[v] = true s[v] = struct{}{}
} }
} }

View File

@@ -18,7 +18,6 @@ func TestHttpGet(t *testing.T) {
resp, err := HttpGet(url, header) resp, err := HttpGet(url, header)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
t.FailNow()
} }
body, _ := ioutil.ReadAll(resp.Body) body, _ := ioutil.ReadAll(resp.Body)
@@ -40,7 +39,6 @@ func TestHttpPost(t *testing.T) {
resp, err := HttpPost(url, header, nil, bodyParams) resp, err := HttpPost(url, header, nil, bodyParams)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
t.FailNow()
} }
body, _ := ioutil.ReadAll(resp.Body) body, _ := ioutil.ReadAll(resp.Body)
t.Log("response: ", resp.StatusCode, string(body)) t.Log("response: ", resp.StatusCode, string(body))
@@ -67,7 +65,6 @@ func TestHttpPostFormData(t *testing.T) {
resp, err := HttpPost(apiUrl, header, postData, nil) resp, err := HttpPost(apiUrl, header, postData, nil)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
t.FailNow()
} }
body, _ := ioutil.ReadAll(resp.Body) body, _ := ioutil.ReadAll(resp.Body)
t.Log("response: ", resp.StatusCode, string(body)) t.Log("response: ", resp.StatusCode, string(body))
@@ -89,7 +86,6 @@ func TestHttpPut(t *testing.T) {
resp, err := HttpPut(url, header, nil, bodyParams) resp, err := HttpPut(url, header, nil, bodyParams)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
t.FailNow()
} }
body, _ := ioutil.ReadAll(resp.Body) body, _ := ioutil.ReadAll(resp.Body)
t.Log("response: ", resp.StatusCode, string(body)) t.Log("response: ", resp.StatusCode, string(body))
@@ -111,7 +107,6 @@ func TestHttpPatch(t *testing.T) {
resp, err := HttpPatch(url, header, nil, bodyParams) resp, err := HttpPatch(url, header, nil, bodyParams)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
t.FailNow()
} }
body, _ := ioutil.ReadAll(resp.Body) body, _ := ioutil.ReadAll(resp.Body)
t.Log("response: ", resp.StatusCode, string(body)) t.Log("response: ", resp.StatusCode, string(body))
@@ -122,7 +117,6 @@ func TestHttpDelete(t *testing.T) {
resp, err := HttpDelete(url) resp, err := HttpDelete(url)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
t.FailNow()
} }
body, _ := ioutil.ReadAll(resp.Body) body, _ := ioutil.ReadAll(resp.Body)
t.Log("response: ", resp.StatusCode, string(body)) t.Log("response: ", resp.StatusCode, string(body))
@@ -148,7 +142,6 @@ func TestParseResponse(t *testing.T) {
resp, err := HttpGet(url, header) resp, err := HttpGet(url, header)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
t.FailNow()
} }
type Todo struct { type Todo struct {
@@ -162,7 +155,6 @@ func TestParseResponse(t *testing.T) {
err = ParseHttpResponse(resp, toDoResp) err = ParseHttpResponse(resp, toDoResp)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
t.FailNow()
} }
t.Log("response: ", toDoResp) t.Log("response: ", toDoResp)
} }