ʕ◔ϖ◔ʔ
ʕ◔ϖ◔ʔ
## 这样算不算😄 ```go for { time.Sleep(math.MaxInt64) } ```
既然范型正式进入标准库,个人感觉 `min` 和 `max` 作为内建函数,不如做成工具类函数比如:`math.Min` `math.Max`,或者为了 Go1 兼容性换个别的名字。 有以下两点: 1. `min` `max` 应该是程序员编程中常用的局部变量名,用 `min` `max` 时 IDE 就会提示警告,同时也会在当前代码块中覆盖掉 `min` `max` 这俩内建函数。 2. `min` `max` 这种函数不同于 `append` `delete` 一样与 Go 语言特性强相关(slice...
一言不发,连肝两篇
直接通过指针偏移量改,更方便: ```go var mu sync.Mutex mu.Lock() *((*int32)(unsafe.Pointer(&mu))) = 0 mu.Lock() ```
In scenarios where there is network isolation or restrictions, it is necessary to provide a custom `http.Client` to define a proxy. It may also be required to use a custom...
当前在 server.NewServer() 时可以配置监听系统信号关闭 server: ```go internalSignal := true shutdownCfg := &global.ShutdownConfig{ InternalSignal: &internalSignal, } srv, _ := server.NewServer( server.SetServerShutdown(shutdownCfg), ) srv.Serve() ``` 当前提供的方式还不够优雅: 1. 不能使用自定义的 context 2. NewServer() 时就启动了一个 go...
在 [简单请求](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Guides/CORS#%E7%AE%80%E5%8D%95%E8%AF%B7%E6%B1%82) 或 浏览器预检之后实际发起请求 的情况下,如果 req 的 Origin 不被允许,此时 CORS 中间件应该怎么做呢? 1. 只添加 CORS 响应头,不阻止非法跨域请求继续传入业务层。 2. 403 阻止非法跨域请求传入到业务层。
还有一个跨域的问题讨论一下: >在 [简单请求](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Guides/CORS#%E7%AE%80%E5%8D%95%E8%AF%B7%E6%B1%82) 或 浏览器预检之后实际发起请求 的情况下,如果 req 的 Origin 不被允许,此时 CORS 中间件应该怎么做呢? > **_Ship 的策略_**:只添加 CORS 响应头,不阻止非法跨域请求继续传入业务层。 > **_Gin 的策略_**: 403 阻止非法跨域请求传入到业务层。 对与第一种只添加 Header 不阻止的宽松策略,并非 Ship 一个框架这么做,但我个人更倾向于 Gin CORS 的严格做法,...