tech
Go 1.24: New STD-lib synctest
Go 1.24 introduces `testing/synctest`, enhancing concurrent testing by using virtual clocks for faster, reliable results. #Golang #Testing
tech
Go 1.24 introduces `testing/synctest`, enhancing concurrent testing by using virtual clocks for faster, reliable results. #Golang #Testing
tech
Go 1.24: 新的官方库 synctest. 在Go语言中,测试并发代码一直是一个具有挑战性的任务。尤其是测试一些需要跟时间相关的case的时候,传统的测试方法通常依赖于真实的系统时钟和同步机制,这会导致测试变得缓慢且容易出现不确定性。 假设我们需要测试 go-cache 的过期删除功能,我们可能会写出这。
tech
【译】“安全是我们的首要任务”--这是一句废话. 原文链接: "Security Is Our Top Priority" is BS 几年前,我被邀请去做一个关于软件安全的会议演讲。其实,我并没有真正被邀请,而是我的公司购买了一个包含演讲席位的赞助包,我回复了一封内部邮件,自愿参与了这个活动 🤣 无论如何。
tech
Previously, I wrote an article about the runtime.SetFinalizer that is used to be called when an object is cleaned up, but some issues with this function cause it to be used less frequently. https://github.com/golang/go/issues/67535 * SetFinalizer must always refer to the first word of
tech
Golang 1.24 introduces `runtime.AddCleanup`, improving upon `runtime.SetFinalizer` by allowing multiple cleanup functions and better handling of object references, thus preventing memory leaks and enabling timely cleanup. #Golang #Go1_24
tech
Go 1.24 introduces the `weak` package for managing memory more flexibly with weak pointers, preventing GC issues. Ideal for caching! 💻✨
tech
Weak 是什么? Golang 在1.24 中带来了一个新的std-lib weak。 可以为*T 创建一个安全的引用,但是不会阻止 *T 被GC 回收。 Package weak provides ways to safely reference memory weakly, that is, without preventing its reclamation. 跟 OS.ROOT 一样, weak 也是一个在其他语言中存在很久的功能,比如: * Java 的 WeakReference 和 SoftReference 是经典实现,主要用于缓存和对象池。它们能够在 JVM 检测到内存不足时自动回收。 * Python 提供了 weakref
tech
Golang 1.24 introduces `os.Root`, enhancing file safety by limiting access to specified directories. This prevents directory traversal vulnerabilities. #GoLang #osRoot
tech
go1.24: 新的标准库 os.Root. Backlink | |Photo by Kaleidico on Unsplash Golang 1.24 已经进入冻结期了,目前很多特性我们在 Go 1.24 Release Notes 能够看到,接下来一段时间我会学习Golang1.24将会添加的新功能以及。
tech
VPNs face limitations in remote work security. Explore 9 alternative technologies like Zero Trust, SASE, & IAM for better protection! 🛡️ #Cybersecurity #RemoteWork
tech
BigCache: High-Performance Memory Caching in Go. BigCache [1] is a high-performance in-memory caching library designed for applications that demand high co。
tech
bigcache是一个高性能的内存缓存库,专为需要高并发访问和低延迟响应的应用场景设计。本文将深入探讨 BigCache 的性能优化手段,包括分片机制、高效哈希算法、读写锁的使用等,并引用相关源码进行详细说明。 分段加锁 从使用者的角度来看cache就像一个大的hashtable,可以存储k/v 格式的数据。 那么,是不是可以使用一个map[string][]byte + sync.RWMutex 实现满足需求的cache呢? 如果性能要求不高,的确可以这么做。 sync.RWMutex虽然对读写进行了优化,但是对于并发的读,最终还是把写变成了串行,一旦写的并发量大的时候,即使写不同的key, 对应的goroutine也会block,只允许一个写执行,这是一个瓶颈,并且不可控。 bigcache 参考了 java ConcurrentMap 的实现方式,将一个大hashtable 分成多个小的 shard,每个分片一把锁,很多大并发场景下为了减小并发的压力都会采用这种方法,比如MongoDB的sharding等。Golang也有一个第三方的 ConcurrentMap