cloudSky's 小站

[Go] defer学习

在 Go 语言中使用 defer 关键字可以将代码延迟到函数结束之前执行。在开发中,我们经常使用 defer 关键字完成善后工作,如关闭打开的文件描述符、关闭连接以及释放


环境 Unity 2021.3 Android Gradle Plugin(AGP): 4.0.1 Gradle: 6.1.1 APK 大小: 2.1G 系统版本: Android 12 使用adb安装报错如下 adb install /tmp/com.test.demo_0.0.1_18971.apk /tmp/com.test.demo_0.0.1_18971.apk Performing Streamed Install adb: failed to install /tmp/com.test.demo_0.0.1_18971.apk: Failure [INSTALL_PARSE_FAILED_NO_CERTIFICATES: Failed collecting certificates for /data/app/vmdl226784575.tmp/base.apk: Failed to collect certificates from /data/app/vmdl226784575.tmp/base.apk using APK Signature Scheme v2: integer overflow] 之前 APK 安装

git clone Out of memory, malloc failed

报错如下 [root@localhost ~]# git clone xxx/iOSClient.git Cloning into 'iOSClient'... remote: Enumerating objects: 4455, done. remote: Counting objects: 100% (4455/4455), done. remote: warning: suboptimal pack - out of memory remote: error: Out of memory, malloc failed (tried to allocate 343057209 bytes) remote: fatal: packed object 98d3df78eb15e9010125e8d6c005f2e0a3792164 (stored in ./objects/pack/pack-c077e52335fd57f98e2fbe83ed034dde18fd6071.pack) is corrupt remote: aborting due to possible repository corruption on the remote side. error: git upload-pack: git-pack-objects died with

[Go] mTLS client示例

环境 go 1.20 GET请求示例 package main import ( "crypto/tls" "crypto/x509" "io" "log" "net/http" "os" ) func main() { // 加载证书和密钥 cert, err := tls.LoadX509KeyPair("client.crt", "client.key") if err != nil { log.Fatal(err) } // 加载服务器的根证书 caCert, err := os.ReadFile("ca.crt") if err != nil { log.Fatal(err) } caCertPool := x509.NewCertPool() caCertPool.AppendCertsFromPEM(caCert)

[Go] slice删除元素的性能对比

环境 MacBook Pro (Retina, 13-inch, Mid 2014) Intel(R) Core(TM) i5-4278U CPU @ 2.60GHz go 1.20 代码如下 package bechmark import ( "testing" ) var ( // 原始slice origin = []string{"a", "b", "c", "d", "e", "f", "g", "h"} // 需要删除的元素 targetEle = "e" ) // 第一种 func BenchmarkMake(t *testing.B) { t.ResetTimer() for i :=