lancet
lancet copied to clipboard
A comprehensive, efficient, and reusable util function library of Go.
Functions that make HTTP requests should accept context for cancellation. Even worse, an http client with default options is used. Not only it doesn't have any timeouts, creating a new...
执行方法Maputil.MapTo,当dst指向的对象内嵌对象为指针时会报错。比如: type MerchantModelMsg struct { Id string `json:"_id"` InsertTime int64 `json:"insert_time"` UpdateTime int64 `json:"update_time"` DeleteTime int64 `json:"delete_time"` LastVersion int64 `json:"last_version"` DataVersion int64 `json:"data_version"` Data *MerchantModelMsg_Data `json:"data"` //此处会报错,如果为MerchantModelMsg_Data类型则不会。 } type MerchantModelMsg_Data...
version: v2.2.9
#### 版本号: v2.2.9 #### 问题描述 strutil中是否可以增加SubBetween方法? 方法的思路大概是,截取指定字符串中间的内容,且不包含指定的字符串。 #### 代码示例 ``` go package main import ( "fmt" "strings" ) func main() { str := "abcdefgh" // 输出cde fmt.Println(SubBetween(str, "b", "f")) }...
1第一个问题: AesEcbDecrypt : AesEcbDecrypt([]byte("12312"), []byte("1234123412341234")) 里面用到了:bs:be 的问题: cipher.Decrypt(decrypted[bs:be], encrypted[bs:be]) 如果说bs 的be 超过了encrypted 的长度, 那么最喜欢的painc 来了! 第二个问题 slice.deleteat(slicedata,slicedata.indexof(slicedata,"123123")) 存在一种可能。 slice的底层数据没有删除干净。
修改promise内存布局,提高了安全性,减少了内存占用
Promise由于其特殊性,必须是pin的,不能够移动在内存中的位置,所以new函数返回一个Promise指针依旧有可能不安全,且*sync.Mutex和*sync.WaitGroup虽然为了内存不可移动声明为指针类型,但是占用了更多内存,且*sync.Mutex是不必要的,建议将代码修改为如下布局,更安全,并节约资源 ``` type Promise[T any] struct { *promise[T] } type promise[T any] struct { runnable func(resolve func(T), reject func(error)) result T err error wait sync.WaitGroup pending atomic.Bool } ```
去看了下不同地方的iv算法,发现各有不同,目前采取写法是: ` iv := encrypted[:aes.BlockSize]` 希望这个能开放自定义