DNS caching has been discussed multiple times in the past. The consensus seems to be that Go won't go there: github.com/golang/go/issues/24796
I've seen a few DNS caching solutions for Go (one, two), however, I haven't seen any implementations that allow replacing the net.DefaultResolver?
Package github.com/artyom/dot got me thinking if I could do the same for DNS caching, and also DNS over HTTPS.
So github.com/ncruces/go-dns is my attempt. Replacing net.DefaultResolver with a caching DNS over HTTPS resolver using 1.1.1.1 as the name server should be this simple:
net.DefaultResolver = dns.NewCachingResolver(dns.NewHTTPSResolver(
I feel like it's a dummy question, but I want to ask it anyway since I do not have much experience with concurrent programming.
In the app I am currently working on, someone wrote a code that should do something (in this case, printing "TICK!") every, let's say 5 minutes:
go func() {
for {
fmt.Println("TICK!")
time.Sleep(5 * time.Minute)
}
}()

最近做一个小型项目,因为rabbitMQ等专业软件比较重,故团队决定采用redis实现一个轻量的队列。
在这篇文章中,你可以获得:
redigo包的基本用法context包的作用select、channel和goroutine)的利用最终代码量大概265行左右。
阅读《Go语言学习笔记》随手摘抄——
退化赋值操作:前提条件:至少有一个新变量被定义,且必须是同一作用域
func main() {
x := 100 // 定义新变量
println(&x)
x, y := 200, "abc" // 只有y是被定义的新变量
println(&x, x)
println(y)