golang
已收录文章:14018篇
-
Go中map传参表现如引用,因其本质是指向hmap的指针包装体,传参时值拷贝该指针,故函数内外操作同一底层数组,实现共享访问。472 收藏
-
算法选择是提升Golang程序性能的根本,如用O(logN)二分查找替代O(N)线性查找,或用O(NlogN)排序替代O(N²)算法,可实现数量级的效率提升。472 收藏
-
编写安全Go代码需验证输入、使用预编译语句、避免硬编码密钥、启用静态分析并配置强TLS;2.构建安全镜像应采用多阶段构建、使用distroless/alpine基础镜像、移除调试工具、以非root用户运行并限制系统调用;3.Kubernetes部署需设置非root运行、禁用特权模式、启用只读文件系统、合理配置SecurityContext和Secret管理,并通过NetworkPolicy控制网络通信;4.运行时防护包括集成结构化日志、暴露Prometheus指标、实施API认证与访问控制、在Ingres472 收藏
-
Tidy makes sure go.mod matches the source code in the module. It adds any missing modules necessary to build the current module's packages and dependencies, and it removes unused modules that don't provide any relevant packages. It also adds any missing471 收藏
-
如何调用自己写的本地模块 在项目根目录$ go mod init 任意名称(比如abc.com/cde)编写本地模块,在其他文件里import该模块(abc.com/cde/该模块的路径)并使用 其他注意点: 被调用模块里包名不要写mai471 收藏
-
Go语言和其他语言不一样,它只有一种循环方式,就是for语句 可以参考如下公式: for initialisation; condition; post{ //Do Something } 执行顺序 a.执行一次initialisation,初始化b.判断conditionc.条件为true,471 收藏