当前位置:首页 > 文章列表 > Golang > Go教程 > Golang高效XML解析技巧分享

Golang高效XML解析技巧分享

2025-09-07 10:13:45 0浏览 收藏

在Golang中处理大型XML文件时,传统的`xml.Unmarshal`方法可能会因一次性加载整个文档到内存而导致较高的内存开销。本文将深入探讨如何利用`xml.Decoder`实现内存高效的XML解析。`xml.Decoder`采用流式解析机制,边读边处理,避免了将整个XML文档加载到内存,显著降低内存占用。通过`DecodeElement`结合结构体解析局部节点,并及时跳过无关内容,进一步优化内存使用。本文将详细介绍`xml.Decoder`的工作机制、使用技巧,并通过实例展示如何编写一个内存友好的XML解析器,特别适用于处理大文件和频繁解析的场景,从而有效降低服务器内存压力,提升程序性能。

使用xml.Decoder能更高效处理大XML文件的原因在于其流式解析机制。① xml.Decoder采用边读边处理的方式,避免将整个文档加载到内存;② 相比Unmarshal构建完整结构树,Decoder仅关注并解析所需节点;③ 通过DecodeElement结合结构体解析局部节点,及时跳过无关内容,减少内存占用;④ 适合处理大文件和频繁解析场景,显著降低内存开销。

Golang如何实现内存高效的XML解析 介绍xml.Decoder与SAX模式优势

Golang在处理XML数据时,如果面对的是大文件或者需要频繁解析的场景,使用常规的xml.Unmarshal方式可能会带来较大的内存开销。这是因为一次性将整个XML结构加载到内存中会占用较多资源。要实现更高效的内存使用,可以借助xml.Decoder,它采用了类似于SAX的流式解析模式,逐条读取XML内容,避免一次性加载全部数据。

Golang如何实现内存高效的XML解析 介绍xml.Decoder与SAX模式优势

为什么用xml.Decoder而不是Unmarshal?

在Go语言标准库的encoding/xml包中,有两种主要解析方式:一种是基于结构体的xml.Unmarshal,另一种是基于事件驱动的xml.Decoder
对于小文件来说,两者区别不大;但当XML文件体积较大(比如几百MB甚至更大)时,Unmarshal会导致整个文档被加载进内存,构建出完整的结构树,而xml.Decoder则是按需读取标签,边读边处理,大大节省了内存消耗。

Golang如何实现内存高效的XML解析 介绍xml.Decoder与SAX模式优势

举个例子,如果你有一个包含上万条记录的XML日志文件,使用Unmarshal需要先把它全读进来并生成一个巨大的结构体切片,而Decoder则可以在每次读到一个记录节点时处理一次,处理完即可释放这部分内存。

xml.Decoder的工作机制与使用技巧

xml.Decoder的核心思想是“边读边处理”,有点类似SAX解析器的行为。它的基本流程如下:

Golang如何实现内存高效的XML解析 介绍xml.Decoder与SAX模式优势
  • 创建一个xml.Decoder实例,通常包装一个io.Reader
  • 使用Decode方法逐步读取XML中的各个Token
  • 每次读取到开始标签、结束标签或文本内容时进行判断和处理

关键点在于只关注你关心的部分节点,跳过不需要的数据。例如,你可以监听某个特定的开始标签,一旦匹配就解析其内部的内容,忽略其他部分。

以下是一些使用建议:

  • 避免将整个文档结构保存在内存中
  • 在读取过程中及时调用decoder.Skip()跳过嵌套复杂结构
  • 处理文本内容时注意转义字符和空白符问题
  • 可以结合结构体解析局部节点,而不必完全手动拼装数据

如何编写一个内存友好的XML解析器?

假设我们要从一个大型XML文件中提取所有节点下的</code>字段,下面是一个典型的写法:</p><pre class="brush:language-go;toolbar:false;">dec := xml.NewDecoder(file) var title string for { tok, err := dec.Token() if err == io.EOF { break } if err != nil { log.Fatal(err) } switch se := tok.(type) { case xml.StartElement: if se.Name.Local == "item" { // 开始一个新的item节点 var item struct { Title string `xml:"title"` } dec.DecodeElement(&item, &se) title = item.Title fmt.Println(title) } } }</pre><p>上面这段代码虽然简单,但展示了几个关键思路:</p><ul><li>只对<code><item></code>节点做结构化解析</li><li>使用<code>DecodeElement</code>来填充结构体字段</li><li>不保留任何不相关的数据结构</li><li>整个过程没有把整个XML文件加载到内存里</li></ul><p>当然,实际使用中可能还需要处理嵌套结构、错误恢复等问题,但这种模式已经足够应对大多数场景。</p><h3>总结一下</h3><p>使用<code>xml.Decoder</code>的好处很明显:适合处理大文件,内存占用低,控制灵活。不过缺点也有,比如代码复杂度比直接<code>Unmarshal</code>高,调试也麻烦一些。所以选择哪种方式,还是要看具体的应用场景。</p><p>如果你只是处理几十KB的小配置文件,用结构体Unmarshal更省事。但如果遇到大文件,或者希望降低服务器内存压力,用<code>Decoder</code>才是更合适的选择。</p><p>文中关于的知识介绍,希望对你的学习有所帮助!若是受益匪浅,那就动动鼠标收藏这篇《Golang高效XML解析技巧分享》文章吧,也可关注golang学习网公众号了解相关技术文章。</p> </div> <div class="labsList"> </div> <div class="cateBox"> <div class="cateItem"> <a href="/article/308535.html" title="Excel调整行高列宽方法详解" class="img_box"> <img src="/uploads/20250907/175721114768bcea0b53ba0.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="Excel调整行高列宽方法详解">Excel调整行高列宽方法详解 </a> <dl> <dt class="lineOverflow"><a href="/article/308535.html" title="Excel调整行高列宽方法详解" class="aBlack">上一篇<i></i></a></dt> <dd class="lineTwoOverflow">Excel调整行高列宽方法详解</dd> </dl> </div> <div class="cateItem"> <a href="/article/308537.html" title="美图秀秀多图拼接教程与图片插入技巧" class="img_box"> <img src="/uploads/20250907/175721127768bcea8d56e79.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="美图秀秀多图拼接教程与图片插入技巧"> </a> <dl> <dt class="lineOverflow"><a href="/article/308537.html" class="aBlack" title="美图秀秀多图拼接教程与图片插入技巧">下一篇<i></i></a></dt> <dd class="lineTwoOverflow">美图秀秀多图拼接教程与图片插入技巧</dd> </dl> </div> </div> </div> </div> <div class="leftContBox pt0"> <div class="pdl20"> <div class="contTit"> <a href="/articlelist.html" class="more" title="查看更多">查看更多<i class="iconfont"></i></a> <div class="tit">最新文章</div> </div> </div> <ul class="newArticleList"> <li> <div class="contBox"> <a href="/article/620240.html" class="img_box" title="Go 1.22 循环变量升级:闭包、goroutine 和测试回归怎么处理"> <img src="/uploads/20260709/1783575699-loopvar-new-per-iteration.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="Go 1.22 循环变量升级:闭包、goroutine 和测试回归怎么处理"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/25_new_0_1.html" class="aLightGray" title="Golang">Golang</a> · <a href="/articlelist/44_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a>   |  1天前  |   <a href="/articletag/19_new_0_1.html" class="aLightGray" title="并发">并发</a> · <a href="/articletag/124_new_0_1.html" class="aLightGray" title="闭包">闭包</a> · <a href="/articletag/2054_new_0_1.html" class="aLightGray" title="for range">for range</a> · <a href="/articletag/3600_new_0_1.html" class="aLightGray" title="迁移">迁移</a> · <a href="/articletag/39686_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a> · <a href="/articletag/40206_new_0_1.html" class="aLightGray" title="Go 1.22">Go 1.22</a> · <a href="javascript:;" class="aLightGray" title="Goroutine">Goroutine</a> <a href="javascript:;" class="aLightGray" title="闭包">闭包</a> <a href="javascript:;" class="aLightGray" title="循环变量">循环变量</a> <a href="javascript:;" class="aLightGray" title="Go教程">Go教程</a> <a href="javascript:;" class="aLightGray" title="Go 1.22">Go 1.22</a> <a href="javascript:;" class="aLightGray" title="for range">for range</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/620240.html" class="aBlack" target="_blank" title="Go 1.22 循环变量升级:闭包、goroutine 和测试回归怎么处理">Go 1.22 循环变量升级:闭包、goroutine 和测试回归怎么处理</a> </dt> <dd class="cont2"> <span><i class="view"></i>113浏览</span> <span class="collectBtn user_collection" data-id="620240" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/620236.html" class="img_box" title="Go sync.Once 怎么用:懒加载配置、并发只初始化一次和错误边界"> <img src="/uploads/20260709/1783573276-go-once-error-boundary.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="Go sync.Once 怎么用:懒加载配置、并发只初始化一次和错误边界"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/25_new_0_1.html" class="aLightGray" title="Golang">Golang</a> · <a href="/articlelist/44_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a>   |  1天前  |   <a href="/articletag/172_new_0_1.html" class="aLightGray" title="标准库">标准库</a> · <a href="/articletag/389_new_0_1.html" class="aLightGray" title="sync.Once">sync.Once</a> · <a href="/articletag/1650_new_0_1.html" class="aLightGray" title="并发控制">并发控制</a> · <a href="/articletag/39686_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a> · <a href="/articletag/39909_new_0_1.html" class="aLightGray" title="懒加载">懒加载</a> · <a href="javascript:;" class="aLightGray" title="懒加载">懒加载</a> <a href="javascript:;" class="aLightGray" title="sync.Once">sync.Once</a> <a href="javascript:;" class="aLightGray" title="once.Do">once.Do</a> <a href="javascript:;" class="aLightGray" title="配置缓存">配置缓存</a> <a href="javascript:;" class="aLightGray" title="Go教程">Go教程</a> <a href="javascript:;" class="aLightGray" title="并发初始化">并发初始化</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/620236.html" class="aBlack" target="_blank" title="Go sync.Once 怎么用:懒加载配置、并发只初始化一次和错误边界">Go sync.Once 怎么用:懒加载配置、并发只初始化一次和错误边界</a> </dt> <dd class="cont2"> <span><i class="view"></i>331浏览</span> <span class="collectBtn user_collection" data-id="620236" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/620234.html" class="img_box" title="Go errors.Join 怎么用:多错误返回、errors.Is 判断和 nil 兼容"> <img src="/uploads/20260709/1783571457-go-errors-join-flow.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="Go errors.Join 怎么用:多错误返回、errors.Is 判断和 nil 兼容"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/25_new_0_1.html" class="aLightGray" title="Golang">Golang</a> · <a href="/articlelist/44_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a>   |  1天前  |   <a href="/articletag/254_new_0_1.html" class="aLightGray" title="单元测试">单元测试</a> · <a href="/articletag/503_new_0_1.html" class="aLightGray" title="错误处理">错误处理</a> · <a href="/articletag/39686_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a> · <a href="/articletag/40204_new_0_1.html" class="aLightGray" title="errors.Join">errors.Join</a> · <a href="/articletag/40205_new_0_1.html" class="aLightGray" title="errors.Is">errors.Is</a> · <a href="javascript:;" class="aLightGray" title="errors.Is">errors.Is</a> <a href="javascript:;" class="aLightGray" title="Go错误处理">Go错误处理</a> <a href="javascript:;" class="aLightGray" title="Go教程">Go教程</a> <a href="javascript:;" class="aLightGray" title="errors.Join">errors.Join</a> <a href="javascript:;" class="aLightGray" title="多错误返回">多错误返回</a> <a href="javascript:;" class="aLightGray" title="批量校验">批量校验</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/620234.html" class="aBlack" target="_blank" title="Go errors.Join 怎么用:多错误返回、errors.Is 判断和 nil 兼容">Go errors.Join 怎么用:多错误返回、errors.Is 判断和 nil 兼容</a> </dt> <dd class="cont2"> <span><i class="view"></i>352浏览</span> <span class="collectBtn user_collection" data-id="620234" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/620232.html" class="img_box" title="Go HTTP 客户端超时怎么设:Client.Timeout、context 和 Transport 分层预算"> <img src="/uploads/20260709/1783570142-go-http-budget-map.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="Go HTTP 客户端超时怎么设:Client.Timeout、context 和 Transport 分层预算"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/25_new_0_1.html" class="aLightGray" title="Golang">Golang</a> · <a href="/articlelist/44_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a>   |  1天前  |   <a href="/articletag/778_new_0_1.html" class="aLightGray" title="Context">Context</a> · <a href="/articletag/898_new_0_1.html" class="aLightGray" title="超时控制">超时控制</a> · <a href="/articletag/39686_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a> · <a href="/articletag/40201_new_0_1.html" class="aLightGray" title="http.Client">http.Client</a> · <a href="/articletag/40202_new_0_1.html" class="aLightGray" title="Transport">Transport</a> · <a href="javascript:;" class="aLightGray" title="Go">Go</a> <a href="javascript:;" class="aLightGray" title="context">context</a> <a href="javascript:;" class="aLightGray" title="请求超时">请求超时</a> <a href="javascript:;" class="aLightGray" title="Transport">Transport</a> <a href="javascript:;" class="aLightGray" title="http.Client">http.Client</a> <a href="javascript:;" class="aLightGray" title="Client.Timeout">Client.Timeout</a> <a href="javascript:;" class="aLightGray" title="ResponseHeaderTimeout">ResponseHeaderTimeout</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/620232.html" class="aBlack" target="_blank" title="Go HTTP 客户端超时怎么设:Client.Timeout、context 和 Transport 分层预算">Go HTTP 客户端超时怎么设:Client.Timeout、context 和 Transport 分层预算</a> </dt> <dd class="cont2"> <span><i class="view"></i>218浏览</span> <span class="collectBtn user_collection" data-id="620232" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/620226.html" class="img_box" title="Go 文件下载接口怎么防路径穿越:filepath.Clean、根路径约束和审计日志"> <img src="/uploads/20260709/1783565222-path-traversal-block.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="Go 文件下载接口怎么防路径穿越:filepath.Clean、根路径约束和审计日志"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/25_new_0_1.html" class="aLightGray" title="Golang">Golang</a> · <a href="/articlelist/44_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a>   |  1天前  |   <a href="/articletag/2264_new_0_1.html" class="aLightGray" title="文件下载">文件下载</a> · <a href="/articletag/39686_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a> · <a href="/articletag/40061_new_0_1.html" class="aLightGray" title="审计日志">审计日志</a> · <a href="/articletag/40065_new_0_1.html" class="aLightGray" title="接口安全">接口安全</a> · <a href="/articletag/40190_new_0_1.html" class="aLightGray" title="路径穿越">路径穿越</a> · <a href="javascript:;" class="aLightGray" title="Go">Go</a> <a href="javascript:;" class="aLightGray" title="文件下载">文件下载</a> <a href="javascript:;" class="aLightGray" title="审计日志">审计日志</a> <a href="javascript:;" class="aLightGray" title="HTTP接口">HTTP接口</a> <a href="javascript:;" class="aLightGray" title="filepath.Clean">filepath.Clean</a> <a href="javascript:;" class="aLightGray" title="安全下载">安全下载</a> <a href="javascript:;" class="aLightGray" title="路径穿越">路径穿越</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/620226.html" class="aBlack" target="_blank" title="Go 文件下载接口怎么防路径穿越:filepath.Clean、根路径约束和审计日志">Go 文件下载接口怎么防路径穿越:filepath.Clean、根路径约束和审计日志</a> </dt> <dd class="cont2"> <span><i class="view"></i>362浏览</span> <span class="collectBtn user_collection" data-id="620226" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/620224.html" class="img_box" title="Go 接口签名怎么防重放:timestamp、nonce 和 HMAC 校验实战"> <img src="/uploads/20260709/1783563744-hmac-defense-loop.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="Go 接口签名怎么防重放:timestamp、nonce 和 HMAC 校验实战"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/25_new_0_1.html" class="aLightGray" title="Golang">Golang</a> · <a href="/articlelist/44_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a>   |  1天前  |   <a href="/articletag/39686_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a> · <a href="/articletag/40082_new_0_1.html" class="aLightGray" title="HMAC">HMAC</a> · <a href="/articletag/40186_new_0_1.html" class="aLightGray" title="API安全">API安全</a> · <a href="/articletag/40187_new_0_1.html" class="aLightGray" title="接口签名">接口签名</a> · <a href="/articletag/40188_new_0_1.html" class="aLightGray" title="防重放">防重放</a> · <a href="javascript:;" class="aLightGray" title="timestamp">timestamp</a> <a href="javascript:;" class="aLightGray" title="Go">Go</a> <a href="javascript:;" class="aLightGray" title="中间件">中间件</a> <a href="javascript:;" class="aLightGray" title="API安全">API安全</a> <a href="javascript:;" class="aLightGray" title="HMAC">HMAC</a> <a href="javascript:;" class="aLightGray" title="接口签名">接口签名</a> <a href="javascript:;" class="aLightGray" title="nonce">nonce</a> <a href="javascript:;" class="aLightGray" title="防重放">防重放</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/620224.html" class="aBlack" target="_blank" title="Go 接口签名怎么防重放:timestamp、nonce 和 HMAC 校验实战">Go 接口签名怎么防重放:timestamp、nonce 和 HMAC 校验实战</a> </dt> <dd class="cont2"> <span><i class="view"></i>273浏览</span> <span class="collectBtn user_collection" data-id="620224" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/620223.html" class="img_box" title="Go 项目用 GitHub Actions 自托管 runner:版本强制执行前该怎么整理 CI"> <img src="/uploads/20260709/1783563014-actions-runner-blocked.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="Go 项目用 GitHub Actions 自托管 runner:版本强制执行前该怎么整理 CI"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/25_new_0_1.html" class="aLightGray" title="Golang">Golang</a> · <a href="/articlelist/44_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a>   |  1天前  |   <a href="/articletag/11130_new_0_1.html" class="aLightGray" title="CI/CD">CI/CD</a> · <a href="/articletag/13652_new_0_1.html" class="aLightGray" title="gitHub actions">gitHub actions</a> · <a href="/articletag/39686_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a> · <a href="/articletag/40184_new_0_1.html" class="aLightGray" title="自托管 Runner">自托管 Runner</a> · <a href="/articletag/40185_new_0_1.html" class="aLightGray" title="持续集成">持续集成</a> · <a href="javascript:;" class="aLightGray" title="Go">Go</a> <a href="javascript:;" class="aLightGray" title="持续集成">持续集成</a> <a href="javascript:;" class="aLightGray" title="CI">CI</a> <a href="javascript:;" class="aLightGray" title="Go test">Go test</a> <a href="javascript:;" class="aLightGray" title="GitHub Actions">GitHub Actions</a> <a href="javascript:;" class="aLightGray" title="self-hosted runner">self-hosted runner</a> <a href="javascript:;" class="aLightGray" title="自托管 runner">自托管 runner</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/620223.html" class="aBlack" target="_blank" title="Go 项目用 GitHub Actions 自托管 runner:版本强制执行前该怎么整理 CI">Go 项目用 GitHub Actions 自托管 runner:版本强制执行前该怎么整理 CI</a> </dt> <dd class="cont2"> <span><i class="view"></i>340浏览</span> <span class="collectBtn user_collection" data-id="620223" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/620218.html" class="img_box" title="Go 配置为什么要显式注入:从全局变量到可测试的 Config 结构"> <img src="/uploads/20260709/1783538241-config-boundary-flow.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="Go 配置为什么要显式注入:从全局变量到可测试的 Config 结构"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/25_new_0_1.html" class="aLightGray" title="Golang">Golang</a> · <a href="/articlelist/44_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a>   |  1天前  |   <a href="/articletag/183_new_0_1.html" class="aLightGray" title="依赖注入">依赖注入</a> · <a href="/articletag/377_new_0_1.html" class="aLightGray" title="配置管理">配置管理</a> · <a href="/articletag/39686_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a> · <a href="/articletag/39699_new_0_1.html" class="aLightGray" title="后端工程">后端工程</a> · <a href="javascript:;" class="aLightGray" title="config">config</a> <a href="javascript:;" class="aLightGray" title="Go">Go</a> <a href="javascript:;" class="aLightGray" title="单元测试">单元测试</a> <a href="javascript:;" class="aLightGray" title="配置管理">配置管理</a> <a href="javascript:;" class="aLightGray" title="依赖注入">依赖注入</a> <a href="javascript:;" class="aLightGray" title="工程实践">工程实践</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/620218.html" class="aBlack" target="_blank" title="Go 配置为什么要显式注入:从全局变量到可测试的 Config 结构">Go 配置为什么要显式注入:从全局变量到可测试的 Config 结构</a> </dt> <dd class="cont2"> <span><i class="view"></i>124浏览</span> <span class="collectBtn user_collection" data-id="620218" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/620216.html" class="img_box" title="Go 实现 HTTP Range 下载:用 ServeContent 支持断点续传和视频拖动"> <img src="/uploads/20260709/1783533747-go-range-request-path.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="Go 实现 HTTP Range 下载:用 ServeContent 支持断点续传和视频拖动"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/25_new_0_1.html" class="aLightGray" title="Golang">Golang</a> · <a href="/articlelist/44_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a>   |  1天前  |   <a href="/articletag/540_new_0_1.html" class="aLightGray" title="HTTP">HTTP</a> · <a href="/articletag/2264_new_0_1.html" class="aLightGray" title="文件下载">文件下载</a> · <a href="/articletag/39686_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a> · <a href="/articletag/40177_new_0_1.html" class="aLightGray" title="Range请求">Range请求</a> · <a href="/articletag/40178_new_0_1.html" class="aLightGray" title="ServeContent">ServeContent</a> · <a href="javascript:;" class="aLightGray" title="断点续传">断点续传</a> <a href="javascript:;" class="aLightGray" title="Content-Range">Content-Range</a> <a href="javascript:;" class="aLightGray" title="Go教程">Go教程</a> <a href="javascript:;" class="aLightGray" title="HTTP Range">HTTP Range</a> <a href="javascript:;" class="aLightGray" title="ServeContent">ServeContent</a> <a href="javascript:;" class="aLightGray" title="206 Partial Content">206 Partial Content</a> <a href="javascript:;" class="aLightGray" title="视频拖动">视频拖动</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/620216.html" class="aBlack" target="_blank" title="Go 实现 HTTP Range 下载:用 ServeContent 支持断点续传和视频拖动">Go 实现 HTTP Range 下载:用 ServeContent 支持断点续传和视频拖动</a> </dt> <dd class="cont2"> <span><i class="view"></i>250浏览</span> <span class="collectBtn user_collection" data-id="620216" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/620208.html" class="img_box" title="Go 大文件 CSV 导出怎么做稳:从全量查询到流式写出架构"> <img src="/uploads/20260708/1783498378-go-csv-export-bottleneck.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="Go 大文件 CSV 导出怎么做稳:从全量查询到流式写出架构"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/25_new_0_1.html" class="aLightGray" title="Golang">Golang</a> · <a href="/articlelist/44_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a>   |  1天前  |   <a href="/articletag/1392_new_0_1.html" class="aLightGray" title="csv">csv</a> · <a href="/articletag/39686_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a> · <a href="/articletag/39687_new_0_1.html" class="aLightGray" title="后端架构">后端架构</a> · <a href="/articletag/40106_new_0_1.html" class="aLightGray" title="流式响应">流式响应</a> · <a href="/articletag/40170_new_0_1.html" class="aLightGray" title="大文件导出">大文件导出</a> · <a href="javascript:;" class="aLightGray" title="大文件下载">大文件下载</a> <a href="javascript:;" class="aLightGray" title="FLUSH">FLUSH</a> <a href="javascript:;" class="aLightGray" title="CSV导出">CSV导出</a> <a href="javascript:;" class="aLightGray" title="Go教程">Go教程</a> <a href="javascript:;" class="aLightGray" title="流式写出">流式写出</a> <a href="javascript:;" class="aLightGray" title="csv.Writer">csv.Writer</a> <a href="javascript:;" class="aLightGray" title="rows.Next">rows.Next</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/620208.html" class="aBlack" target="_blank" title="Go 大文件 CSV 导出怎么做稳:从全量查询到流式写出架构">Go 大文件 CSV 导出怎么做稳:从全量查询到流式写出架构</a> </dt> <dd class="cont2"> <span><i class="view"></i>251浏览</span> <span class="collectBtn user_collection" data-id="620208" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/620205.html" class="img_box" title="Go HTTP 服务超时怎么配:ReadHeaderTimeout、WriteTimeout 和 IdleTimeout 实战"> <img src="/uploads/20260708/1783495694-go-http-timeout-checkboard.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="Go HTTP 服务超时怎么配:ReadHeaderTimeout、WriteTimeout 和 IdleTimeout 实战"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/25_new_0_1.html" class="aLightGray" title="Golang">Golang</a> · <a href="/articlelist/44_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a>   |  1天前  |   <a href="/articletag/1217_new_0_1.html" class="aLightGray" title="HTTP服务">HTTP服务</a> · <a href="/articletag/39686_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a> · <a href="/articletag/39745_new_0_1.html" class="aLightGray" title="后端开发">后端开发</a> · <a href="/articletag/40166_new_0_1.html" class="aLightGray" title="超时配置">超时配置</a> · <a href="/articletag/40167_new_0_1.html" class="aLightGray" title="服务稳定性">服务稳定性</a> · <a href="javascript:;" class="aLightGray" title="net/http">net/http</a> <a href="javascript:;" class="aLightGray" title="WriteTimeout">WriteTimeout</a> <a href="javascript:;" class="aLightGray" title="HTTP超时">HTTP超时</a> <a href="javascript:;" class="aLightGray" title="Go教程">Go教程</a> <a href="javascript:;" class="aLightGray" title="ReadHeaderTimeout">ReadHeaderTimeout</a> <a href="javascript:;" class="aLightGray" title="IdleTimeout">IdleTimeout</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/620205.html" class="aBlack" target="_blank" title="Go HTTP 服务超时怎么配:ReadHeaderTimeout、WriteTimeout 和 IdleTimeout 实战">Go HTTP 服务超时怎么配:ReadHeaderTimeout、WriteTimeout 和 IdleTimeout 实战</a> </dt> <dd class="cont2"> <span><i class="view"></i>140浏览</span> <span class="collectBtn user_collection" data-id="620205" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> <li> <div class="contBox"> <a href="/article/620189.html" class="img_box" title="Go context.WithCancelCause 怎么用:把取消原因带回请求链路"> <img src="/uploads/20260708/1783482786-go-cancel-cause-chain.webp" onerror="this.src='/assets/images/moren/morentu.png'" alt="Go context.WithCancelCause 怎么用:把取消原因带回请求链路"> </a> <dl> <dd class="cont1"> <span> <a href="/articlelist/25_new_0_1.html" class="aLightGray" title="Golang">Golang</a> · <a href="/articlelist/44_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a>   |  2天前  |   <a href="/articletag/503_new_0_1.html" class="aLightGray" title="错误处理">错误处理</a> · <a href="/articletag/778_new_0_1.html" class="aLightGray" title="Context">Context</a> · <a href="/articletag/1650_new_0_1.html" class="aLightGray" title="并发控制">并发控制</a> · <a href="/articletag/39686_new_0_1.html" class="aLightGray" title="Go教程">Go教程</a> · <a href="javascript:;" class="aLightGray" title="并发控制">并发控制</a> <a href="javascript:;" class="aLightGray" title="Go教程">Go教程</a> <a href="javascript:;" class="aLightGray" title="context取消">context取消</a> <a href="javascript:;" class="aLightGray" title="context.WithCancelCause">context.WithCancelCause</a> <a href="javascript:;" class="aLightGray" title="context.Cause">context.Cause</a> </span> </dd> <dt class="lineOverflow"> <a href="/article/620189.html" class="aBlack" target="_blank" title="Go context.WithCancelCause 怎么用:把取消原因带回请求链路">Go context.WithCancelCause 怎么用:把取消原因带回请求链路</a> </dt> <dd class="cont2"> <span><i class="view"></i>342浏览</span> <span class="collectBtn user_collection" data-id="620189" data-type="article" title="收藏"><i class="collect"></i>收藏</span> </dd> </dl> </div> </li> </ul> </div> </div> <div class="mainRight"> <!-- 右侧广告位banner --> <div class="rightContBox" style="margin-top: 0px;"> <div class="rightTit"> <a href="/courselist.html" class="more" title="查看更多">查看更多<i class="iconfont"></i></a> <div class="tit lineOverflow">课程推荐</div> </div> <ul class="lessonRecomRList"> <li> <a href="/course/9.html" class="img_box" target="_blank" title="前端进阶之JavaScript设计模式"> <img src="/uploads/20221222/52fd0f23a454c71029c2c72d206ed815.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="前端进阶之JavaScript设计模式"> </a> <dl> <dt class="lineTwoOverflow"><a href="/course/9.html" target="_blank" class="aBlack" title="前端进阶之JavaScript设计模式">前端进阶之JavaScript设计模式</a></dt> <dd class="cont1 lineTwoOverflow"> 设计模式是开发人员在软件开发过程中面临一般问题时的解决方案,代表了最佳的实践。本课程的主打内容包括JS常见设计模式以及具体应用场景,打造一站式知识长龙服务,适合有JS基础的同学学习。 </dd> <dd class="cont2">543次学习</dd> </dl> </li> <li> <a href="/course/2.html" class="img_box" target="_blank" title="GO语言核心编程课程"> <img src="/uploads/20221221/634ad7404159bfefc6a54a564d437b5f.png" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="GO语言核心编程课程"> </a> <dl> <dt class="lineTwoOverflow"><a href="/course/2.html" target="_blank" class="aBlack" title="GO语言核心编程课程">GO语言核心编程课程</a></dt> <dd class="cont1 lineTwoOverflow"> 本课程采用真实案例,全面具体可落地,从理论到实践,一步一步将GO核心编程技术、编程思想、底层实现融会贯通,使学习者贴近时代脉搏,做IT互联网时代的弄潮儿。 </dd> <dd class="cont2">516次学习</dd> </dl> </li> <li> <a href="/course/74.html" class="img_box" target="_blank" title="简单聊聊mysql8与网络通信"> <img src="/uploads/20240103/bad35fe14edbd214bee16f88343ac57c.png" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="简单聊聊mysql8与网络通信"> </a> <dl> <dt class="lineTwoOverflow"><a href="/course/74.html" target="_blank" class="aBlack" title="简单聊聊mysql8与网络通信">简单聊聊mysql8与网络通信</a></dt> <dd class="cont1 lineTwoOverflow"> 如有问题加微信:Le-studyg;在课程中,我们将首先介绍MySQL8的新特性,包括性能优化、安全增强、新数据类型等,帮助学生快速熟悉MySQL8的最新功能。接着,我们将深入解析MySQL的网络通信机制,包括协议、连接管理、数据传输等,让 </dd> <dd class="cont2">500次学习</dd> </dl> </li> <li> <a href="/course/57.html" class="img_box" target="_blank" title="JavaScript正则表达式基础与实战"> <img src="/uploads/20221226/bbe4083bb3cb0dd135fb02c31c3785fb.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="JavaScript正则表达式基础与实战"> </a> <dl> <dt class="lineTwoOverflow"><a href="/course/57.html" target="_blank" class="aBlack" title="JavaScript正则表达式基础与实战">JavaScript正则表达式基础与实战</a></dt> <dd class="cont1 lineTwoOverflow"> 在任何一门编程语言中,正则表达式,都是一项重要的知识,它提供了高效的字符串匹配与捕获机制,可以极大的简化程序设计。 </dd> <dd class="cont2">487次学习</dd> </dl> </li> <li> <a href="/course/28.html" class="img_box" target="_blank" title="从零制作响应式网站—Grid布局"> <img src="/uploads/20221223/ac110f88206daeab6c0cf38ebf5fe9ed.jpg" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="从零制作响应式网站—Grid布局"> </a> <dl> <dt class="lineTwoOverflow"><a href="/course/28.html" target="_blank" class="aBlack" title="从零制作响应式网站—Grid布局">从零制作响应式网站—Grid布局</a></dt> <dd class="cont1 lineTwoOverflow"> 本系列教程将展示从零制作一个假想的网络科技公司官网,分为导航,轮播,关于我们,成功案例,服务流程,团队介绍,数据部分,公司动态,底部信息等内容区块。网站整体采用CSSGrid布局,支持响应式,有流畅过渡和展现动画。 </dd> <dd class="cont2">485次学习</dd> </dl> </li> </ul> </div> <div class="rightContBox"> <div class="rightTit"> <a href="/ai.html" class="more" title="查看更多">查看更多<i class="iconfont"></i></a> <div class="tit lineOverflow">AI推荐</div> </div> <ul class="lessonRecomRList"> <li> <a href="/ai/13109.html" target="_blank" title="ljg-skills - "Prompt之神"李继刚开源的 AI 技能集" class="img_box"> <img src="/uploads/ai/20260616/ljg-skills-icon-8bbe1468e5.png" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="ljg-skills - "Prompt之神"李继刚开源的 AI 技能集" style="object-fit:cover;width:100%;height:100%;"> </a> <dl> <dt class="lineTwoOverflow"><a href="/ai/13109.html" class="aBlack" target="_blank" title="ljg-skills">ljg-skills</a></dt> <dd class="cont1 lineTwoOverflow"> ljg-skills 是李继刚开源的 AI 技能与提示词集合,面向大模型使用者整理了一批可复用的 prompt、角色设定和任务技能模板,适合用于学习提示词设计、搭建个人 AI 工作流和沉淀团队常用智能体能力。 </dd> <dd class="cont2">4401次使用</dd> </dl> </li> <li> <a href="/ai/13108.html" target="_blank" title="MELO音乐 - AI 音乐生成平台,支持多模态创作能力" class="img_box"> <img src="/uploads/ai/20260616/melo-icon-10bf590762.png" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="MELO音乐 - AI 音乐生成平台,支持多模态创作能力" style="object-fit:cover;width:100%;height:100%;"> </a> <dl> <dt class="lineTwoOverflow"><a href="/ai/13108.html" class="aBlack" target="_blank" title="MELO音乐">MELO音乐</a></dt> <dd class="cont1 lineTwoOverflow"> MELO音乐是一站式AI视频与音乐制作助手,对标suno, udio的高品质体验。提供伴奏生成、原创写词、无损导出、哼唱识曲、混音变声等全套音频与短视频编辑工具。无论是流行Kpop、电音说唱、民谣古风、摇滚儿歌还是商用轻音乐,MELO为你免费谱曲,轻松做同款! </dd> <dd class="cont2">4070次使用</dd> </dl> </li> <li> <a href="/ai/13107.html" target="_blank" title="UniScribe - AI 免费在线音视频转文字平台" class="img_box"> <img src="/uploads/ai/20260616/uniscribe-icon-3c88366a15.png" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="UniScribe - AI 免费在线音视频转文字平台" style="object-fit:cover;width:100%;height:100%;"> </a> <dl> <dt class="lineTwoOverflow"><a href="/ai/13107.html" class="aBlack" target="_blank" title="UniScribe">UniScribe</a></dt> <dd class="cont1 lineTwoOverflow"> UniScribe 是一款 AI 音视频转文字与内容整理工具,支持上传音频、视频文件或粘贴 YouTube 链接,自动生成转写文本、摘要、思维导图和关键问题,并支持多格式导出,适合会议记录、课程学习、访谈整理和内容创作复盘。 </dd> <dd class="cont2">4053次使用</dd> </dl> </li> <li> <a href="/ai/13106.html" target="_blank" title="剧云 - 免费 AI 智能中文剧本创作平台" class="img_box"> <img src="/uploads/ai/20260615/d36c7176-icon-2b0cd581ce.png" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="剧云 - 免费 AI 智能中文剧本创作平台" style="object-fit:cover;width:100%;height:100%;"> </a> <dl> <dt class="lineTwoOverflow"><a href="/ai/13106.html" class="aBlack" target="_blank" title="剧云">剧云</a></dt> <dd class="cont1 lineTwoOverflow"> 剧云是专业中文剧本创作平台,安全稳定运行十余年,集成AI编剧、剧本医生审核、人物小传、剧情关系图、大纲编写、多人协作、Word导入导出、版权管控功能,数据安全防护,轻松高效创作剧本。 </dd> <dd class="cont2">4238次使用</dd> </dl> </li> <li> <a href="/ai/13105.html" target="_blank" title="万象有声 - AI 一站式有声内容创作平台" class="img_box"> <img src="/uploads/ai/20260615/50267bac-icon-c146b001b5.png" onerror="this.onerror='',this.src='/assets/images/moren/morentu.png'" alt="万象有声 - AI 一站式有声内容创作平台" style="object-fit:cover;width:100%;height:100%;"> </a> <dl> <dt class="lineTwoOverflow"><a href="/ai/13105.html" class="aBlack" target="_blank" title="万象有声">万象有声</a></dt> <dd class="cont1 lineTwoOverflow"> 万象有声,一个专为有声创作者打造的新一代智能有声内容创作平台。平台提供专业的智能拆章、智能画本编辑、AI配音、AI生成音效、后期制作、智能对轨、智能审听等有声创作全流程工具,可以帮助创作者高效、低成本创作出引人入胜的有声作品。立即体验,让有声书制作更简单! </dd> <dd class="cont2">4209次使用</dd> </dl> </li> </ul> </div> <!-- 相关文章 --> <div class="rightContBox"> <div class="rightTit"> <a href="/articlelist.html" class="more" title="查看更多">查看更多<i class="iconfont"></i></a> <div class="tit lineOverflow">相关文章</div> </div> <ul class="aboutArticleRList"> <li> <dl> <dt class="lineTwoOverflow"><a href="/article/619847.html" class="aBlack" title="Java 性能优化上线清单:从定位、改造到灰度发布">Java 性能优化上线清单:从定位、改造到灰度发布</a></dt> <dd> <span class="left">2026-06-11</span> <span class="right">860浏览</span> </dd> </dl> </li> <li> <dl> <dt class="lineTwoOverflow"><a href="/article/619846.html" class="aBlack" title="Spring Boot 压测验证:Gatling、JMeter 与性能回归门禁">Spring Boot 压测验证:Gatling、JMeter 与性能回归门禁</a></dt> <dd> <span class="left">2026-06-11</span> <span class="right">843浏览</span> </dd> </dl> </li> <li> <dl> <dt class="lineTwoOverflow"><a href="/article/619845.html" class="aBlack" title="Java NMT 非堆内存排查:Direct Buffer、线程栈与 Metaspace 分析">Java NMT 非堆内存排查:Direct Buffer、线程栈与 Metaspace 分析</a></dt> <dd> <span class="left">2026-06-11</span> <span class="right">826浏览</span> </dd> </dl> </li> <li> <dl> <dt class="lineTwoOverflow"><a href="/article/619844.html" class="aBlack" title="Spring Boot 容器内存优化:JVM 堆、非堆与 MaxRAMPercentage">Spring Boot 容器内存优化:JVM 堆、非堆与 MaxRAMPercentage</a></dt> <dd> <span class="left">2026-06-11</span> <span class="right">809浏览</span> </dd> </dl> </li> <li> <dl> <dt class="lineTwoOverflow"><a href="/article/619843.html" class="aBlack" title="Tomcat 连接与线程参数调优:maxThreads、acceptCount 与 KeepAlive">Tomcat 连接与线程参数调优:maxThreads、acceptCount 与 KeepAlive</a></dt> <dd> <span class="left">2026-06-11</span> <span class="right">792浏览</span> </dd> </dl> </li> </ul> </div> </div> </div> <div class="footer"> <div class="footerIn"> <div class="footLeft"> <div class="linkBox"> <a href="/about/1.html" target="_blank" class="aBlack" title="关于我们">关于我们</a> <a href="/about/5.html" target="_blank" class="aBlack" title="免责声明">免责声明</a> <a href="#" class="aBlack" title="意见反馈">意见反馈</a> <a href="/about/2.html" class="aBlack" target="_blank" title="联系我们">联系我们</a> <a href="/send.html" class="aBlack" title="广告合作">内容提交</a> <a href="/manual/go/" target="_blank" class="aBlack" title="手册">手册</a> </div> <div class="footTip">Golang学习网:公益在线Go学习平台,帮助Go学习者快速成长!</div> <div class="shareBox"> <span><i class="qq"></i>技术交流群</span> </div> <div class="copyRight"> Copyright 2023 http://www.17golang.com/ All Rights Reserved | <a href="https://beian.miit.gov.cn/" target="_blank" title="备案">苏ICP备2023003363号-1</a> </div> </div> <div class="footRight"> <ul class="encodeList"> <li> <div class="encodeImg"> <img src="/assets/examples/qrcode_for_gh.jpg" alt="Golang学习网"> </div> <div class="tit">关注公众号</div> <div class="tip">Golang学习网</div> </li> <div class="clear"></div> </ul> </div> <div class="clear"></div> </div> </div> <!-- 微信登录弹窗 --> <style> .popupBg .n-error{ color: red; } </style> <div class="popupBg"> <div class="loginBoxBox"> <div class="imgbg"> <img src="/assets/images/leftlogo.jpg" alt=""> </div> <!-- 微信登录 --> <div class="loginInfo encodeLogin" style="display: none;"> <div class="closeIcon" onclick="$('.popupBg').hide();"></div> <div class="changeLoginType cursorPointer create_wxqrcode" onclick="$('.loginInfo').hide();$('.passwordLogin').show();"> <div class="tip">密码登录在这里</div> </div> <div class="encodeInfo"> <div class="tit"><i></i> 微信扫码登录或注册</div> <div class="encodeImg"> <span id="wx_login_qrcode"><img src="/assets/examples/code.png" alt="二维码"></span> <!-- <div class="refreshBox"> <p>二维码失效</p> <button type="button" class="create_wxqrcode">刷新1111</button> </div> --> </div> <div class="tip">打开微信扫一扫,快速登录/注册</div> </div> <div class="beforeLoginTip">登录即同意 <a href="#" class="aBlue" title="用户协议">用户协议</a> 和 <a href="#" class="aBlue" title="隐私政策">隐私政策</a></div> </div> <!-- 密码登录 --> <div class="loginInfo passwordLogin"> <div class="closeIcon" onclick="$('.popupBg').hide();"></div> <div class="changeLoginType cursorPointer create_wxqrcode" onclick="$('.loginInfo').hide();$('.encodeLogin').show();"> <div class="tip">微信登录更方便</div> </div> <div class="passwordInfo"> <ul class="logintabs selfTabMenu"> <li class="selfTabItem loginFormLi curr">密码登录</li> <li class="selfTabItem registerFormBox ">注册账号</li> </ul> <div class="selfTabContBox"> <div class="selfTabCont loginFormBox" style="display: block;"> <form name="form" id="login-form" class="form-vertical form" method="POST" action="/index/user/login"> <input type="hidden" name="url" value="//17golang.com/article/308536.html"/> <input type="hidden" name="__token__" value="981c7c1676f2d3dbdada96c0700fd256" /> <div class="form-group" style="height:70px;"> <input class="form-control" id="account" type="text" name="account" value="" data-rule="required" placeholder="邮箱/用户名" autocomplete="off"> </div> <div class="form-group" style="height:70px;"> <input class="form-control" id="password" type="password" name="password" data-rule="required;password" placeholder="密码" autocomplete="off"> </div> <div class="codeBox" style="height:70px;"> <div class="form-group" style="height:70px; width:205px; float: left;"> <input type="text" name="captcha" class="form-control" placeholder="验证码" data-rule="required;length(4)" /> </div> <span class="input-group-btn" style="padding:0;border:none;"> <img src="/captcha.html" width="100" height="45" onclick="this.src = '/captcha.html?r=' + Math.random();"/> </span> </div> <div class="other"> <a href="#" class="forgetPwd aGray" onclick="$('.loginInfo').hide();$('.passwordForget').show();" title="忘记密码">忘记密码</a> </div> <div class="loginBtn mt25"> <button type="submit">登录</button> </div> </form> </div> <div class="selfTabCont registerFormBox" style="display: none;"> <form name="form1" id="register-form" class="form-vertical form" method="POST" action="/index/user/register"> <input type="hidden" name="invite_user_id" value="0"/> <input type="hidden" name="url" value="//17golang.com/article/308536.html"/> <input type="hidden" name="__token__" value="981c7c1676f2d3dbdada96c0700fd256" /> <div class="form-group" style="height:70px;"> <input type="text" name="email" id="email2" data-rule="required;email" class="form-control" placeholder="邮箱"> </div> <div class="form-group" style="height:70px;"> <input type="text" id="username" name="username" data-rule="required;username" class="form-control" placeholder="用户名必须3-30个字符"> </div> <div class="form-group" style="height:70px;"> <input type="password" id="password2" name="password" data-rule="required;password" class="form-control" placeholder="密码必须6-30个字符"> </div> <div class="codeBox" style="height:70px;"> <div class="form-group" style="height:70px; width:205px; float: left;"> <input type="text" name="captcha" class="form-control" placeholder="验证码" data-rule="required;length(4)" /> </div> <span class="input-group-btn" style="padding:0;border:none;"> <img src="/captcha.html" width="100" height="45" onclick="this.src = '/captcha.html?r=' + Math.random();"/> </span> </div> <div class="loginBtn"> <button type="submit">注册</button> </div> </form> </div> </div> </div> <div class="beforeLoginTip">登录即同意 <a href="https://www.17golang.com/about/3.html" target="_blank" class="aBlue" title="用户协议">用户协议</a> 和 <a href="https://www.17golang.com/about/4.html" target="_blank" class="aBlue" title="隐私政策">隐私政策</a></div> </div> <!-- 重置密码 --> <div class="loginInfo passwordForget"> <div class="closeIcon" onclick="$('.popupBg').hide();"></div> <div class="returnLogin cursorPointer" onclick="$('.passwordForget').hide();$('.passwordLogin').show();">返回登录</div> <div class="passwordInfo"> <ul class="logintabs selfTabMenu"> <li class="selfTabItem">重置密码</li> </ul> <div class="selfTabContBox"> <div class="selfTabCont"> <form id="resetpwd-form" class="form-horizontal form-layer nice-validator n-default n-bootstrap form" method="POST" action="/api/user/resetpwd.html" novalidate="novalidate"> <div style="height:70px;"> <input type="text" class="form-control" id="email" name="email" value="" placeholder="输入邮箱" aria-invalid="true"> </div> <div class="codeBox" style="height:70px;"> <div class="form-group" style="height:70px; width:205px; float: left;"> <input type="text" name="captcha" class="form-control" placeholder="验证码" /> </div> <span class="input-group-btn" style="padding:0;border:none;"> <a href="javascript:;" class="btn btn-primary btn-captcha cursorPointer" style="background: #2080F8; border-radius: 4px; color: #fff; padding: 12px; position: absolute;" data-url="/api/ems/send.html" data-type="email" data-event="resetpwd">发送验证码</a> </span> </div> <input type="password" class="form-control" id="newpassword" name="newpassword" value="" placeholder="请输入6-18位密码"> <div class="loginBtn mt25"> <button type="submit">重置密码</button> </div> </form> </div> </div> </div> </div> </div> </div> <script src="/assets/js/juejin-theme.js?v=20260613b" defer></script> <script> var _hmt = _hmt || []; (function() { var hm = document.createElement("script"); hm.src = "https://hm.baidu.com/hm.js?e34c3e8ab31ba35d7e1c48ea8d77315f"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); })(); </script> <script src="/assets/js/frontend/common.js"></script> </body> </html>