<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 静态站点生成器）使用。</li>
<li>提供 Playground：https://yuin.github.io/goldmark/playground/</li>
</ul>
<div class="code-block highlight is-open 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">text</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-13" 
    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="n">import</span> <span class="s2">&#34;github.com/yuin/goldmark&#34;</span>
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"><span class="n">md</span> <span class="p">:</span><span class="o">=</span> <span class="n">goldmark</span><span class="o">.</span><span class="n">New</span><span class="p">()</span>
</span></span><span class="line"><span class="cl"><span class="k">var</span> <span class="n">buf</span> <span class="n">bytes</span><span class="o">.</span><span class="n">Buffer</span>
</span></span><span class="line"><span class="cl"><span class="n">err</span> <span class="p">:</span><span class="o">=</span> <span class="n">md</span><span class="o">.</span><span class="n">Convert</span><span class="p">([]</span><span class="n">byte</span><span class="p">(</span><span class="s2">&#34;# Hello&#34;</span><span class="p">),</span> <span class="o">&amp;</span><span class="n">buf</span><span class="p">)</span>
</span></span><span class="line"><span class="cl"><span class="n">html</span> <span class="p">:</span><span class="o">=</span> <span class="n">buf</span><span class="o">.</span><span class="n">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[<h1 id="gin-开发后台服务最佳实践" class="headerLink">
    <a href="#gin-%e5%bc%80%e5%8f%91%e5%90%8e%e5%8f%b0%e6%9c%8d%e5%8a%a1%e6%9c%80%e4%bd%b3%e5%ae%9e%e8%b7%b5" class="header-mark"></a>Gin 开发后台服务最佳实践</h1><p><a href="https://github.com/gin-gonic/gin" target="_blank" rel="noopener noreferrer">gin</a> 是一个 golang 实现的 http web 框架。</p>
<p><a href="https://github.com/skyhee/gin-doc-cn" target="_blank" rel="noopener noreferrer">go 语言框架 gin 的中文文档</a> 介绍了 路由、无缝重启、中间件、db接入常用方法。</p>
<h2 id="脚手架项目" class="headerLink">
    <a href="#%e8%84%9a%e6%89%8b%e6%9e%b6%e9%a1%b9%e7%9b%ae" class="header-mark"></a>脚手架项目</h2><p>github上有这么些 stars 数排名较高的：</p>
<ul>
<li>
<p><a href="https://github.com/flipped-aurora/gin-vue-admin" target="_blank" rel="noopener noreferrer">gin-vue-admin</a> Vite+Vue3+Gin拥有AI辅助的基础开发平台，支持TS和JS混用。它集成了JWT鉴权、权限管理、动态路由、casbin鉴权、显隐可控组件、分页封装、多点登录拦截、资源权限、上传下载、代码生成器、表单生成器和可配置的导入导出等开发必备功能。</p>]]></description></item><item><title>golang web framework - 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[<h1 id="golang-web-framework---macaron" class="headerLink">
    <a href="#golang-web-framework---macaron" class="header-mark"></a>golang web framework - macaron</h1><p><a href="https://github.com/go-macaron/macaron" target="_blank" rel="noopener noreferrer">macaron</a> 是 Golang 开发的 Web Framework， 与 gin、beego 起名。详细的中文文档参考这里：</p>
<ul>
<li><a href="https://go-macaron.com/zh-cn" target="_blank" rel="noopener noreferrer">macaron 文档</a></li>
</ul>
<p>提供了子网址的强大路由，可以嵌套多组路由器，提供热加载，修改模板就会立刻在页面修改，采用模块化设计，可以非常方便替换组件，采用依赖注入加载组件，非常适合现代化工程项目，代码松耦合，适合开发大型团队项目。</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[<h1 id="golang-web框架" class="headerLink">
    <a href="#golang-web%e6%a1%86%e6%9e%b6" class="header-mark"></a>Golang web框架</h1><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 inspired web framework written in Go</li>
</ul>
<p>基于Fiber的开源项目</p>
<ul>
<li><a href="https://github.com/Finb/bark-server" target="_blank" rel="noopener noreferrer">bark-server</a></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></li>
</ul>
<h2 id="beego" class="headerLink">
    <a href="#beego" class="header-mark"></a>beego</h2><ul>
<li><a href="https://github.com/astaxie/beego" target="_blank" rel="noopener noreferrer">beego</a></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></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></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></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</a></li>
<li><a href="https://github.com/gorilla/websocket" target="_blank" rel="noopener noreferrer">websocket</a> 最广泛使用的 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></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></li>
</ul>
<h2 id="hertz" class="headerLink">
    <a href="#hertz" class="header-mark"></a>Hertz</h2><p>Hertz[həːts] 是一个 Golang 微服务 HTTP 框架，最初fork自fasthttp，并在设计时参考了其他开源框架gin、echo 的优势，并结合字节跳动内部的需求，使其具有高易用性、高 性能、高扩展性等特点，目前在字节跳动内部已广泛使用。如今越来越多的微服务选择使用 Golang，如果对微服务性能有要求，又希望框架能够充分满足内部的可定制化需求，Hertz 会是一个不错的选择。</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><![CDATA[<h1 id="golang-常用的程序库" class="headerLink">
    <a href="#golang-%e5%b8%b8%e7%94%a8%e7%9a%84%e7%a8%8b%e5%ba%8f%e5%ba%93" class="header-mark"></a>Golang 常用的程序库</h1><h2 id="通用库" class="headerLink">
    <a href="#%e9%80%9a%e7%94%a8%e5%ba%93" class="header-mark"></a>通用库</h2><ul>
<li><a href="https://github.com/duke-git/lancet" target="_blank" rel="noopener noreferrer">lancet（柳叶刀</a> 是一个全面、高效、可复用的go语言工具函数库。 lancet受到了java apache common包和lodash.js的启发。</li>
</ul>
<h2 id="类型转换" class="headerLink">
    <a href="#%e7%b1%bb%e5%9e%8b%e8%bd%ac%e6%8d%a2" class="header-mark"></a>类型转换</h2><p><strong>cast</strong></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[<h1 id="golang-常用日志库" class="headerLink">
    <a href="#golang-%e5%b8%b8%e7%94%a8%e6%97%a5%e5%bf%97%e5%ba%93" class="header-mark"></a>Golang 常用日志库</h1><ul>
<li><a href="https://github.com/golang/glog" target="_blank" rel="noopener noreferrer">Google Glog 的Go语言版本</a></li>
<li><a href="https://github.com/uber-go/zap" target="_blank" rel="noopener noreferrer">zap 日志</a></li>
<li><a href="https://github.com/sirupsen/logrus" target="_blank" rel="noopener noreferrer">logrus</a></li>
<li><a href="https://github.com/mix-go/logrus" target="_blank" rel="noopener noreferrer">logrus 扩展</a></li>
</ul>]]></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[<h1 id="golang-程序加载配置最佳实践" class="headerLink">
    <a href="#golang-%e7%a8%8b%e5%ba%8f%e5%8a%a0%e8%bd%bd%e9%85%8d%e7%bd%ae%e6%9c%80%e4%bd%b3%e5%ae%9e%e8%b7%b5" class="header-mark"></a>Golang 程序加载配置最佳实践</h1><h2 id="常用配置文件读取方式" class="headerLink">
    <a href="#%e5%b8%b8%e7%94%a8%e9%85%8d%e7%bd%ae%e6%96%87%e4%bb%b6%e8%af%bb%e5%8f%96%e6%96%b9%e5%bc%8f" class="header-mark"></a>常用配置文件读取方式</h2><h3 id="1-json" class="headerLink">
    <a href="#1-json" class="header-mark"></a>1. json</h3><ul>
<li>内置</li>
<li><a href="https://github.com/json-iterator/go" target="_blank" rel="noopener noreferrer">json-iterator for go</a></li>
<li><a href="https://github.com/tidwall/gjson" target="_blank" rel="noopener noreferrer">GJSON </a></li>
</ul>
<h3 id="2-yaml" class="headerLink">
    <a href="#2-yaml" class="header-mark"></a>2. yaml</h3><ul>
<li><a href="https://github.com/go-yaml/yaml" target="_blank" rel="noopener noreferrer">YAML</a></li>
</ul>
<h3 id="3-toml" class="headerLink">
    <a href="#3-toml" class="header-mark"></a>3. toml</h3><ul>
<li><a href="https://github.com/BurntSushi/toml" target="_blank" rel="noopener noreferrer">TOML</a></li>
</ul>
<h3 id="4-ini" class="headerLink">
    <a href="#4-ini" class="header-mark"></a>4. ini</h3><ul>
<li><a href="https://github.com/go-ini/ini" target="_blank" rel="noopener noreferrer">INI</a></li>
</ul>
<h3 id="5-hcl" class="headerLink">
    <a href="#5-hcl" class="header-mark"></a>5. HCL</h3><ul>
<li><a href="https://github.com/hashicorp/hcl" target="_blank" rel="noopener noreferrer">HCL</a></li>
</ul>
<h3 id="其它库" class="headerLink">
    <a href="#%e5%85%b6%e5%ae%83%e5%ba%93" class="header-mark"></a>其它库</h3><ul>
<li><a href="https://github.com/spf13/viper" target="_blank" rel="noopener noreferrer">Viper</a> Viper是一个完全配置解析库，可以支持上面所有类型的配置文件的解析。</li>
</ul>
<h2 id="最佳实践" class="headerLink">
    <a href="#%e6%9c%80%e4%bd%b3%e5%ae%9e%e8%b7%b5" class="header-mark"></a>最佳实践</h2><p>最好的方式应该是能够同时支持 从 命令行参数、配置文件、环境变量 三种方式加载参数写入到特定的结构中。</p>]]></description></item></channel></rss>