<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>Golang - 标签 - 研发日志 · R&amp;D Log</title><link>https://rd163.visword.com/tags/golang/</link><description>Golang - 标签 - 研发日志 · R&amp;D Log</description><generator>Hugo -- gohugo.io</generator><language>zh-CN</language><managingEditor>whutluohui@gmail.com (小智晖)</managingEditor><webMaster>whutluohui@gmail.com (小智晖)</webMaster><copyright>本作品采用知识共享署名-非商业性使用 4.0 国际许可协议进行许可。</copyright><lastBuildDate>Fri, 13 Jun 2025 00:00:00 +0800</lastBuildDate><atom:link href="https://rd163.visword.com/tags/golang/" rel="self" type="application/rss+xml"/><item><title>Markdown 转换为 HTML 的golang开源项目</title><link>https://rd163.visword.com/posts/golang-markdown-to-html/</link><pubDate>Fri, 13 Jun 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/golang-markdown-to-html/</guid><description><![CDATA[<p>在 Go 语言生态中，有不少优秀的开源项目可以将 Markdown 转换为 HTML。下面整理几款常见的工具和库，供选型参考。</p>
<h2 id="goldmark" class="headerLink">
    <a href="#goldmark" class="header-mark"></a>Goldmark</h2><p>GitHub：<a href="https://github.com/yuin/goldmark" target="_blank" rel="noopener noreferrer">https://github.com/yuin/goldmark</a></p>
<p>特点：</p>
<ul>
<li>高性能，完全符合 CommonMark 标准。</li>
<li>原生支持扩展（如表格、任务列表、删除线、脚注、数学公式等）。</li>
<li>被许多知名项目采用，Hugo 自 v0.60.0 起将其作为默认 Markdown 渲染器。</li>
<li>仅依赖标准库，API 简洁，易于集成。</li>
<li>提供 Playground：<a href="https://yuin.github.io/goldmark/playground/" target="_blank" rel="noopener noreferrer">https://yuin.github.io/goldmark/playground/</a></li>
</ul>
<div class="code-block highlight is-closed show-line-numbers  tw:group tw:my-2">
  <div class="
    
    tw:flex 
    tw:flex-row
    tw:flex-1 
    tw:justify-between 
    tw:w-full tw:bg-bgColor-secondary
    ">      
    <button 
      class="
        code-block-button
        tw:mx-2 
        tw:flex
        tw:flex-row
        tw:flex-1"
      aria-hidden="true">
          <span class="tw:group-[.is-open]:rotate-90 tw:transition-[transform] tw:duration-500 tw:ease-in-out tw:print:hidden! tw:w-min tw:h-min tw:my-1 tw:mx-1"><svg class="icon"
    xmlns="http://www.w3.org/2000/svg" viewBox="0 0 320 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path d="M285.476 272.971L91.132 467.314c-9.373 9.373-24.569 9.373-33.941 0l-22.667-22.667c-9.357-9.357-9.375-24.522-.04-33.901L188.505 256 34.484 101.255c-9.335-9.379-9.317-24.544.04-33.901l22.667-22.667c9.373-9.373 24.569-9.373 33.941 0L285.475 239.03c9.373 9.372 9.373 24.568.001 33.941z"/></svg></span>
          <span class="tw:select-none tw:my-1! tw:block">go</span>
      </button>

   <div class="tw:flex">
      <button 
        class="
          line-number-button
          tw:mx-2 
          tw:hidden 
          tw:group-[.is-open]:block 
          tw:group-[.show-line-numbers]:text-fgColor-link 
          tw:print:hidden!" 
        title="Toggle line numbers"><svg class="icon"
    xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path d="M61.77 401l17.5-20.15a19.92 19.92 0 0 0 5.07-14.19v-3.31C84.34 356 80.5 352 73 352H16a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8h22.83a157.41 157.41 0 0 0-11 12.31l-5.61 7c-4 5.07-5.25 10.13-2.8 14.88l1.05 1.93c3 5.76 6.29 7.88 12.25 7.88h4.73c10.33 0 15.94 2.44 15.94 9.09 0 4.72-4.2 8.22-14.36 8.22a41.54 41.54 0 0 1-15.47-3.12c-6.49-3.88-11.74-3.5-15.6 3.12l-5.59 9.31c-3.72 6.13-3.19 11.72 2.63 15.94 7.71 4.69 20.38 9.44 37 9.44 34.16 0 48.5-22.75 48.5-44.12-.03-14.38-9.12-29.76-28.73-34.88zM496 224H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zm0-160H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16V80a16 16 0 0 0-16-16zm0 320H176a16 16 0 0 0-16 16v32a16 16 0 0 0 16 16h320a16 16 0 0 0 16-16v-32a16 16 0 0 0-16-16zM16 160h64a8 8 0 0 0 8-8v-16a8 8 0 0 0-8-8H64V40a8 8 0 0 0-8-8H32a8 8 0 0 0-7.14 4.42l-8 16A8 8 0 0 0 24 64h8v64H16a8 8 0 0 0-8 8v16a8 8 0 0 0 8 8zm-3.91 160H80a8 8 0 0 0 8-8v-16a8 8 0 0 0-8-8H41.32c3.29-10.29 48.34-18.68 48.34-56.44 0-29.06-25-39.56-44.47-39.56-21.36 0-33.8 10-40.46 18.75-4.37 5.59-3 10.84 2.8 15.37l8.58 6.88c5.61 4.56 11 2.47 16.12-2.44a13.44 13.44 0 0 1 9.46-3.84c3.33 0 9.28 1.56 9.28 8.75C51 248.19 0 257.31 0 304.59v4C0 316 5.08 320 12.09 320z"/></svg></button>

      <button 
        class="
          wrap-code-button
          tw:select-none 
          tw:mx-2 
          tw:hidden 
          tw:group-[.is-open]:block 
          tw:group-[.is-wrap]:text-fgColor-link 
          tw:print:hidden!" 
        title="Toggle code wrap"><svg class="icon"
    xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path d="M16 132h416c8.837 0 16-7.163 16-16V76c0-8.837-7.163-16-16-16H16C7.163 60 0 67.163 0 76v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16zm0 160h416c8.837 0 16-7.163 16-16v-40c0-8.837-7.163-16-16-16H16c-8.837 0-16 7.163-16 16v40c0 8.837 7.163 16 16 16z"/></svg></button>
      
      <button 
        class="
          copy-code-button
          tw:select-none
          tw:mx-2 
          tw:hidden
          tw:group-[.is-open]:block
          tw:hover:text-fgColor-link 
          tw:print:hidden!"
        title="Copy code">
          <span class="copy-icon tw:block"><svg class="icon"
    xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path d="M433.941 65.941l-51.882-51.882A48 48 0 0 0 348.118 0H176c-26.51 0-48 21.49-48 48v48H48c-26.51 0-48 21.49-48 48v320c0 26.51 21.49 48 48 48h224c26.51 0 48-21.49 48-48v-48h80c26.51 0 48-21.49 48-48V99.882a48 48 0 0 0-14.059-33.941zM266 464H54a6 6 0 0 1-6-6V150a6 6 0 0 1 6-6h74v224c0 26.51 21.49 48 48 48h96v42a6 6 0 0 1-6 6zm128-96H182a6 6 0 0 1-6-6V54a6 6 0 0 1 6-6h106v88c0 13.255 10.745 24 24 24h88v202a6 6 0 0 1-6 6zm6-256h-64V48h9.632c1.591 0 3.117.632 4.243 1.757l48.368 48.368a6 6 0 0 1 1.757 4.243V112z"/></svg></span>
          <span class="check-icon tw:hidden"><svg class="icon"
    xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path d="M173.898 439.404l-166.4-166.4c-9.997-9.997-9.997-26.206 0-36.204l36.203-36.204c9.997-9.998 26.207-9.998 36.204 0L192 312.69 432.095 72.596c9.997-9.997 26.207-9.997 36.204 0l36.203 36.204c9.997 9.997 9.997 26.206 0 36.204l-294.4 294.401c-9.998 9.997-26.207 9.997-36.204-.001z"/></svg></span>
      </button>
        
      <button 
        class="
          tw:select-none 
          tw:mx-2 
          tw:block 
          tw:group-[.is-open]:hidden 
          tw:print:hidden!" 
        disabled
        aria-hidden="true"><svg class="icon"
    xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!-- Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) --><path d="M328 256c0 39.8-32.2 72-72 72s-72-32.2-72-72 32.2-72 72-72 72 32.2 72 72zm104-72c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72zm-352 0c-39.8 0-72 32.2-72 72s32.2 72 72 72 72-32.2 72-72-32.2-72-72-72z"/></svg></button>
    </div>
  </div>
  <pre style="counter-reset: codeblock;" class="tw:block tw:m-0 tw:p-0"><code 
    id="codeblock-id-1" 
    class="
      chroma 
      tw:block! 
      tw:p-0
      tw:m-0
      tw:transition-[max-height] 
      tw:duration-500 
      tw:ease-in-out 
      tw:group-[.is-closed]:max-h-0! 
      tw:group-[.is-wrap]:text-wrap
      tw:overflow-y-hidden
      tw:overflow-x-auto
      tw:scrollbar-thin
      "><span class="line"><span class="cl"><span class="kn">import</span><span class="w"> </span><span class="p">(</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="s">&#34;bytes&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="s">&#34;github.com/yuin/goldmark&#34;</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="p">)</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nx">md</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="nx">goldmark</span><span class="p">.</span><span class="nf">New</span><span class="p">()</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="kd">var</span><span class="w"> </span><span class="nx">buf</span><span class="w"> </span><span class="nx">bytes</span><span class="p">.</span><span class="nx">Buffer</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="k">if</span><span class="w"> </span><span class="nx">err</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="nx">md</span><span class="p">.</span><span class="nf">Convert</span><span class="p">([]</span><span class="nb">byte</span><span class="p">(</span><span class="s">&#34;# Hello&#34;</span><span class="p">),</span><span class="w"> </span><span class="o">&amp;</span><span class="nx">buf</span><span class="p">);</span><span class="w"> </span><span class="nx">err</span><span class="w"> </span><span class="o">!=</span><span class="w"> </span><span class="kc">nil</span><span class="w"> </span><span class="p">{</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="w">    </span><span class="nb">panic</span><span class="p">(</span><span class="nx">err</span><span class="p">)</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="p">}</span><span class="w">
</span></span></span><span class="line"><span class="cl"><span class="nx">html</span><span class="w"> </span><span class="o">:=</span><span class="w"> </span><span class="nx">buf</span><span class="p">.</span><span class="nf">String</span><span class="p">()</span></span></span></code></pre>
</div>
<h2 id="blackfriday" class="headerLink">
    <a href="#blackfriday" class="header-mark"></a>Blackfriday</h2><p>GitHub：<a href="https://github.com/russross/blackfriday" target="_blank" rel="noopener noreferrer">https://github.com/russross/blackfriday</a></p>]]></description></item><item><title>Go语言Web框架：Beego</title><link>https://rd163.visword.com/posts/golang-beego/</link><pubDate>Sat, 07 Jun 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/golang-beego/</guid><description><![CDATA[<h2 id="beego框架概述" class="headerLink">
    <a href="#beego%e6%a1%86%e6%9e%b6%e6%a6%82%e8%bf%b0" class="header-mark"></a>Beego框架概述</h2><p>Beego是一个用Go语言开发的全栈MVC框架，由国人谢孟军（Asta Xie）开发并维护。它借鉴了Python的Django和Flask等框架的设计思想，同时结合了Go语言的特性，为开发者提供了一套完整的Web开发解决方案。</p>]]></description></item><item><title>Golang 内存泄露定位</title><link>https://rd163.visword.com/posts/golang-mem-leak/</link><pubDate>Sun, 20 Apr 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/golang-mem-leak/</guid><description>&lt;p>Golang 作为自带垃圾回收（Garbage Collection，GC）机制的语言，可以自动管理内存。但在实际开发中，如果代码编写不当，仍然会出现内存泄漏的情况。&lt;/p></description></item><item><title>golang 性能优化工具</title><link>https://rd163.visword.com/posts/golang-perf-opti-tools/</link><pubDate>Mon, 14 Apr 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/golang-perf-opti-tools/</guid><description><![CDATA[<p>在 Golang 中，性能优化分析工具是定位瓶颈、优化代码的关键。以下是常用的工具及其使用场景和方法：</p>
<hr>
<h2 id="性能剖析工具" class="headerLink">
    <a href="#%e6%80%a7%e8%83%bd%e5%89%96%e6%9e%90%e5%b7%a5%e5%85%b7" class="header-mark"></a>性能剖析工具</h2><h3 id="1" class="headerLink">
    <a href="#1" class="header-mark"></a><strong>1. <code>pprof</code> 性能剖析工具</strong></h3><p>Go 内置的 <code>pprof</code> 包提供 CPU、内存、Goroutine、阻塞等维度的性能分析，支持可视化（火焰图、调用链）。</p>]]></description></item><item><title>Gin 开发后台服务最佳实践</title><link>https://rd163.visword.com/posts/best-practice-for-gin/</link><pubDate>Sun, 12 Jan 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/best-practice-for-gin/</guid><description><![CDATA[<p><a href="https://github.com/gin-gonic/gin" target="_blank" rel="noopener noreferrer">gin</a> 是一个由 Go 语言实现的 HTTP Web 框架，基于 httprouter，主打高性能与简洁的 API 设计，常用于构建 REST API 与微服务。</p>
<p><a href="https://github.com/skyhee/gin-doc-cn" target="_blank" rel="noopener noreferrer">gin 中文文档</a> 系统介绍了路由、无缝重启、中间件、数据库接入等常用方法，可作为入门与速查参考。</p>]]></description></item><item><title>Go 语言 Web 框架：Macaron</title><link>https://rd163.visword.com/posts/golang-macaron/</link><pubDate>Sun, 12 Jan 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/golang-macaron/</guid><description><![CDATA[<p><a href="https://github.com/go-macaron/macaron" target="_blank" rel="noopener noreferrer">Macaron</a> 是一个用 Go 语言编写的高效、模块化 Web 框架，官方仓库自我定位为「a high productive and modular web framework in Go」。它与 Gin、Beego、Echo 等同属 Go 生态中较早期出现的一批 Web 框架，设计思路继承自 <a href="https://github.com/go-martini/martini" target="_blank" rel="noopener noreferrer">Martini</a>,底层依赖 <a href="https://github.com/codegangsta/inject" target="_blank" rel="noopener noreferrer">codegangsta/inject</a> 实现依赖注入，但在路由层做了重写，显著降低了反射开销与内存占用。详细的中文文档可参考:</p>]]></description></item><item><title>Golang web框架</title><link>https://rd163.visword.com/posts/golang-web-framework/</link><pubDate>Sun, 12 Jan 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/golang-web-framework/</guid><description><![CDATA[<h2 id="fiber" class="headerLink">
    <a href="#fiber" class="header-mark"></a>Fiber</h2><ul>
<li><a href="https://github.com/gofiber/fiber" target="_blank" rel="noopener noreferrer">Fiber</a>:受 Express.js 启发的 Go Web 框架，底层基于 fasthttp，主打零内存分配与高性能。</li>
</ul>
<p>基于 Fiber 的开源项目:</p>
<ul>
<li><a href="https://github.com/Finb/bark-server" target="_blank" rel="noopener noreferrer">bark-server</a>:iOS 推送通知服务 Bark 的后端。</li>
</ul>
<h2 id="macaron" class="headerLink">
    <a href="#macaron" class="header-mark"></a>Macaron</h2><ul>
<li><a href="https://github.com/go-macaron/macaron" target="_blank" rel="noopener noreferrer">Macaron</a>:高生产力、模块化的 Go Web 框架。目前已进入维护模式，不再新增功能，官方推荐其后继者 <a href="https://github.com/flamego/flamego" target="_blank" rel="noopener noreferrer">Flamego</a>。</li>
</ul>
<h2 id="beego" class="headerLink">
    <a href="#beego" class="header-mark"></a>Beego</h2><ul>
<li><a href="https://github.com/beego/beego" target="_blank" rel="noopener noreferrer">Beego</a>:老牌高性能 Go Web 框架，提供 ORM、缓存、日志、配置、任务等一整套模块。注：原作者仓库 <code>astaxie/beego</code> 已迁移至 <code>beego/beego</code> 组织，请使用新地址。</li>
</ul>
<h2 id="gin" class="headerLink">
    <a href="#gin" class="header-mark"></a>Gin</h2><ul>
<li><a href="https://github.com/gin-gonic/gin" target="_blank" rel="noopener noreferrer">Gin</a>:使用最广泛的 Go Web 框架，采用 httprouter 改造的路由，性能高、API 简洁，中间件生态丰富。</li>
</ul>
<h2 id="echo" class="headerLink">
    <a href="#echo" class="header-mark"></a>Echo</h2><ul>
<li><a href="https://github.com/labstack/echo" target="_blank" rel="noopener noreferrer">Echo</a>:高性能、极简的 Go Web 框架，自动 TLS、HTTP/2、可扩展中间件支持完善。</li>
</ul>
<h2 id="chi" class="headerLink">
    <a href="#chi" class="header-mark"></a>Chi</h2><ul>
<li><a href="https://github.com/go-chi/chi" target="_blank" rel="noopener noreferrer">chi</a>:轻量、兼容 <code>net/http</code> 的路由库，API 与标准库无缝衔接，适合构建可组合的 HTTP 服务。</li>
</ul>
<h2 id="gorilla" class="headerLink">
    <a href="#gorilla" class="header-mark"></a>Gorilla</h2><ul>
<li><a href="https://github.com/gorilla/mux" target="_blank" rel="noopener noreferrer">gorilla/mux</a>:强大的 HTTP 路由与请求匹配器，功能丰富。Gorilla 工具集曾在 2022 年底被归档，后由新的维护者团队接管并恢复维护。</li>
<li><a href="https://github.com/gorilla/websocket" target="_blank" rel="noopener noreferrer">gorilla/websocket</a>:Go 社区应用最广泛的 WebSocket 库。</li>
</ul>
<h2 id="fasthttp" class="headerLink">
    <a href="#fasthttp" class="header-mark"></a>fasthttp</h2><ul>
<li><a href="https://github.com/valyala/fasthttp" target="_blank" rel="noopener noreferrer">fasthttp</a>:为极端性能优化的 HTTP 实现，吞吐量与内存占用均显著优于标准库 <code>net/http</code>,但 API 与 <code>net/http</code> 不兼容。</li>
</ul>
<h2 id="httprouter" class="headerLink">
    <a href="#httprouter" class="header-mark"></a>httprouter</h2><ul>
<li><a href="https://github.com/julienschmidt/httprouter" target="_blank" rel="noopener noreferrer">httprouter</a>:基于 radix tree 的高性能路由，是众多 Go Web 框架（含 Gin）的底层路由原型。</li>
</ul>
<h2 id="hertz" class="headerLink">
    <a href="#hertz" class="header-mark"></a>Hertz</h2><p>Hertz(发音 [həːts],赫兹)是字节跳动开源的 Golang 微服务 HTTP 框架，由 <a href="https://github.com/cloudwego" target="_blank" rel="noopener noreferrer">CloudWeGo</a> 社区维护。它最初 fork 自 fasthttp，在设计上参考了 Gin、Echo 等开源框架的优势，并结合字节跳动内部对高性能与可扩展性的诉求进行了重构与演进。其默认网络库使用 CloudWeGo 自研的 <a href="https://github.com/cloudwego/netpoll" target="_blank" rel="noopener noreferrer">Netpoll</a>(基于 epoll),并保留了切换至 Go 标准网络库的能力，具有高易用性、高性能、高扩展性等特点，目前在字节跳动内部已大规模使用。</p>]]></description></item><item><title>Golang 常用的工具与功能库</title><link>https://rd163.visword.com/posts/golang-util-libs/</link><pubDate>Sun, 12 Jan 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/golang-util-libs/</guid><description>&lt;p>Go 标准库覆盖面相当广，但工程实践中仍有许多「写起来啰嗦、但又避不开」的常见需求：类型之间的安全转换、切片去重、字符串处理、优雅重启、后台任务编排、网络报文解析等。本文梳理几款在 Go 项目里出现频率较高的工具与功能库，介绍其定位、核心特性和维护状态，便于选型时参考。所有库均在 GitHub 上开源，文末附官方链接。&lt;/p></description></item><item><title>Golang 常用日志库</title><link>https://rd163.visword.com/posts/golang-log-libs/</link><pubDate>Sun, 12 Jan 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/golang-log-libs/</guid><description><![CDATA[<p>日志是服务可观测性的基石。Go 生态中,日志库大致经历了「标准库 <code>log</code> → 第三方结构化日志库(<code>logrus</code>、<code>zap</code>、<code>zerolog</code>) → 标准库 <code>log/slog</code>」三个阶段。本文梳理几款在工程中常见的 Go 日志库,介绍其定位、特性与基础用法,便于在实际选型时参考。</p>]]></description></item><item><title>Golang 程序加载配置最佳实践</title><link>https://rd163.visword.com/posts/best-practice-for-go-conf/</link><pubDate>Sun, 12 Jan 2025 00:00:00 +0800</pubDate><author><name>小智晖</name></author><guid>https://rd163.visword.com/posts/best-practice-for-go-conf/</guid><description><![CDATA[<p>程序的配置（key、连接串、端口、特性开关等）往往会随部署环境（dev / staging / prod）变化，而代码本身不变。这正是 <a href="https://12factor.net/config" target="_blank" rel="noopener noreferrer">Twelve-Factor App</a> 中「配置（Config）」一章的核心观点:<strong>配置应与代码严格分离</strong>,且推荐将环境相关的配置放进环境变量（env vars）,因为它们易于在不同部署间切换、不易被误提交进版本库，并且与语言和操作系统无关。</p>]]></description></item></channel></rss>