在 Go 语言中使用 defer 关键字可以将代码延迟到函数结束之前执行。在开发中,我们经常使用 defer 关键字完成善后工作,如关闭打开的文件描述符、关闭连接以及释放
最近为了优化执行效率,使用goroutine并发处理,同时使用channel来采集 error 信息,结果踩坑了。示例代码如下: package main import ( "errors" "fmt" "sync" ) func demo() error {
背景 最近要获取 jira 返回数据更新关注列表,jira 服务器的请求和返回的数据默认进行了 gzip 压缩。目前有 2 种方式 jira 设置中关闭 gzip 压缩 使用 lua 对 gzip 进行解压,
环境 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 安装
基础用法 Go语言中的database/sql包提供了保证SQL或类SQL数据库的泛用接口,并不提供具体的数据库驱动。使用database/s
报错如下 [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 1.20 需求 比如要请求一个域名test.com, 希望DNS解析到指定IP1.1.1.1,如何设置http.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)
前几日发布的gin v1.9.0版本json库多了个选择,就是字节开源的sonic,支持JIT(just-in-time compiling)和
环境 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 :=