Search by
Posted by
u/ncruces
over 5 years ago

Replacing net.DefaultResolver with a caching DNS over TLS/HTTPS resolver

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(
Posted by
u/mknycha
over 5 years ago

How to do something every 5 minutes in Go?

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)
   }
}()
Posted by
u/yuchanns
over 5 years ago

使用Jenkins(一)

Posted by
u/yuchanns
over 5 years ago

用redis做队列

最近做一个小型项目,因为rabbitMQ等专业软件比较重,故团队决定采用redis实现一个轻量的队列。

目标

在这篇文章中,你可以获得:

  • redigo包的基本用法
  • 初步认知context包的作用
  • 了解一个功能模块的实现思路以及如何逐步完善的步骤
  • Go特性(selectchannelgoroutine)的利用

最终代码量大概265行左右。

Posted by
u/yuchanns
about 6 years ago

读《Go语言学习笔记》

阅读《Go语言学习笔记》随手摘抄——

数据

  • 退化赋值操作:前提条件:至少有一个新变量被定义,且必须是同一作用域

    func main() {
      x := 100  // 定义新变量
      println(&x)
    
      x, y := 200, "abc"  // 只有y是被定义的新变量
    
      println(&x, x)
      println(y)
    

Awesome Links

a/Reddit

Condé Nast Digital

a/Gatsby

Gatsbyjs