PageSourceSearch

https://golangguide.top/assets/%E5%A4%9A%E5%8D%8F%E7%A8%8B%E6%9F%A…E7%89%87%E9%97%AE%E9%A2%98.html-DFd78wyB.js

js golangguide.top collected 2026-10-05 18:45:16 UTC 5,298 bytes, 1 lines download raw bytes

1import{_ as a,r,o as l,c as i,a as e,b as t,d as n,e as c}from"./app-DMFMbUxP.js";const p={},g=c('<h1 id="多协程查询切片问题" tabindex="-1"><a class="header-anchor" href="#多协程查询切片问题"><span>多协程查询切片问题</span></a></h1><h2 id="题目" tabindex="-1"><a class="header-anchor" href="#题目"><span>题目</span></a></h2><p>假设有一个超长的切片,切片的元素类型为int,切片中的元素为乱序排序。限时5秒,使用多个goroutine查找切片中是否存在给定的值,在查找到目标值或者超时后立刻结束所有goroutine的执行。</p><p>比如,切片 <code>[23,32,78,43,76,65,345,762,......915,86]</code>,查找目标值为 345 ,如果切片中存在,则目标值输出<code>&quot;Found it!&quot;</code>并立即取消仍在执行查询任务的<code>goroutine</code>。</p><p>如果在超时时间未查到目标值程序,则输出<code>&quot;Timeout!Not Found&quot;</code>,同时立即取消仍在执行的查找任务的<code>goroutine</code>。</p>',5),s={href:"https://mp.weixin.qq.com/s/GhC2WDw3VHP91DrrFVCnag",target:"_blank",rel:"noopener noreferrer"},d=e("h2",{id:"相关文章",tabindex:"-1"},[e("a",{class:"header-anchor",href:"#相关文章"},[e("span",null,"相关文章")])],-1),E={href:"https://golangguide.top/golang/%E9%9D%A2%E8%AF%95%E9%A2%98/2.Go%E8%BF%9B%E9%98%B6.html",target:"_blank",rel:"noopener noreferrer"},h={href:"https://golangguide.top/golang/%E9%9D%A2%E8%AF%95%E9%A2%98/1.Go%E5%85%A5%E9%97%A8.html",target:"_blank",rel:"noopener noreferrer"},u={href:"https://golangguide.top/golang/%E5%B8%B8%E7%94%A8%E5%8C%85%E5%A4%A7%E5%85%A8.html",target:"_blank",rel:"noopener noreferrer"},A={href:"https://golangguide.top/golang/%E5%AD%A6%E4%B9%A0%E8%B7%AF%E7%BA%BF.html",target:"_blank",rel:"noopener noreferrer"};function m(_,F){const o=r("ExternalLinkIcon");return l(),i("div",null,[g,e("blockquote",null,[e("p",null,[t("答案: "),e("a",s,[t("https://mp.weixin.qq.com/s/GhC2WDw3VHP91DrrFVCnag"),n(o)])])]),d,e("ul",null,[e("li",null,[e("p",null,[e("a",E,[t("golang进阶面试题八股文合集"),n(o)])])]),e("li",null,[e("p",null,[e("a",h,[t("golang基础面试题八股文合集"),n(o)])])]),e("li",null,[e("p",null,[e("a",u,[t("golang常用标准库第三方库大全"),n(o)])])]),e("li",null,[e("p",null,[e("a",A,[t("golang学习路线"),n(o)])])])])])}const B=a(p,[["render",m],["__file","多协程查询切片问题.html.vue"]]),b=JSON.parse('{"path":"/golang/%E6%A0%B8%E5%BF%83%E7%9F%A5%E8%AF%86%E7%82%B9/%E5%A4%9A%E5%8D%8F%E7%A8%8B%E6%9F%A5%E8%AF%A2%E5%88%87%E7%89%87%E9%97%AE%E9%A2%98.html","title":"多协程查询切片问题","lang":"zh-CN","frontmatter":{"description":"多协程查询切片问题 题目 假设有一个超长的切片,切片的元素类型为int,切片中的元素为乱序排序。限时5秒,使用多个goroutine查找切片中是否存在给定的值,在查找到目标值或者超时后立刻结束所有goroutine的执行。 比如,切片 [23,32,78,43,76,65,345,762,......915,86],查找目标值为 345 ,如果切片中存...","head":[["link",{"rel":"canonical","href":"https://golangguide.top/golang/%E6%A0%B8%E5%BF%83%E7%9F%A5%E8%AF%86%E7%82%B9/%E5%A4%9A%E5%8D%8F%E7%A8%8B%E6%9F%A5%E8%AF%A2%E5%88%87%E7%89%87%E9%97%AE%E9%A2%98.html"}],["meta",{"property":"og:url","content":"https://golangguide.top/golang/%E6%A0%B8%E5%BF%83%E7%9F%A5%E8%AF%86%E7%82%B9/%E5%A4%9A%E5%8D%8F%E7%A8%8B%E6%9F%A5%E8%AF%A2%E5%88%87%E7%89%87%E9%97%AE%E9%A2%98.html"}],["meta",{"property":"og:site_name","content":"golang全栈指南"}],["meta",{"property":"og:title","content":"多协程查询切片问题"}],["meta",{"property":"og:description","content":"多协程查询切片问题 题目 假设有一个超长的切片,切片的元素类型为int,切片中的元素为乱序排序。限时5秒,使用多个goroutine查找切片中是否存在给定的值,在查找到目标值或者超时后立刻结束所有goroutine的执行。 比如,切片 [23,32,78,43,76,65,345,762,......915,86],查找目标值为 345 ,如果切片中存..."}],["meta",{"property":"og:type","content":"article"}],["meta",{"property":"og:locale","content":"zh-CN"}
1],["meta",{"property":"og:updated_time","content":"2025-02-12T02:37:21.000Z"}],["meta",{"property":"article:author","content":"小白debug"}],["meta",{"property":"article:modified_time","content":"2025-02-12T02:37:21.000Z"}],["script",{"type":"application/ld+json"},"{\\"@context\\":\\"https://schema.org\\",\\"@type\\":\\"Article\\",\\"headline\\":\\"多协程查询切片问题\\",\\"image\\":[\\"\\"],\\"dateModified\\":\\"2025-02-12T02:37:21.000Z\\",\\"author\\":[{\\"@type\\":\\"Person\\",\\"name\\":\\"小白debug\\",\\"url\\":\\"https://xiaobaidebug.top/\\"}]}"]]},"headers":[{"level":2,"title":"题目","slug":"题目","link":"#题目","children":[]},{"level":2,"title":"相关文章","slug":"相关文章","link":"#相关文章","children":[]}],"git":{"createdTime":1739327841000,"updatedTime":1739327841000,"contributors":[{"name":"xiaobai-tech","email":"[email protected]","commits":1}]},"readingTime":{"minutes":0.95,"words":286},"filePathRelative":"golang/核心知识点/多协程查询切片问题.md","localizedDate":"2025å¹´2月12日","autoDesc":true}');export{B as comp,b as data};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.