You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
360 lines
8.5 KiB
HTML
360 lines
8.5 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-cn" dir="ltr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<meta name="description" content=" 函数 # 一等公民 函数调用栈 值传递 闭包 方法 ">
|
|
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#ffffff">
|
|
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#343a40">
|
|
<meta name="color-scheme" content="light dark"><meta property="og:title" content="函数" />
|
|
<meta property="og:description" content="" />
|
|
<meta property="og:type" content="website" />
|
|
<meta property="og:url" content="https://go.cyub.vip/function/" />
|
|
<title>函数 | 深入Go语言之旅</title>
|
|
<link rel="manifest" href="/manifest.json">
|
|
<link rel="icon" href="/favicon.png" >
|
|
<link rel="stylesheet" href="/book.min.f06572240ce28e67eb332ac5cf5d59a696c47ad4c6f700d5842c5ed93dd8ec77.css" integrity="sha256-8GVyJAzijmfrMyrFz11ZppbEetTG9wDVhCxe2T3Y7Hc=" crossorigin="anonymous">
|
|
<script defer src="/flexsearch.min.js"></script>
|
|
<script defer src="/en.search.min.7e9d53d4a20eea8c87bf76a4502bd21aa041c1ef2adc7e37ffc5339c57accccd.js" integrity="sha256-fp1T1KIO6oyHv3akUCvSGqBBwe8q3H43/8UznFeszM0=" crossorigin="anonymous"></script>
|
|
|
|
<script async src="https://www.googletagmanager.com/gtag/js?id=G-BQ229RRTTX"></script>
|
|
<script>
|
|
var doNotTrack = false;
|
|
if (!doNotTrack) {
|
|
window.dataLayer = window.dataLayer || [];
|
|
function gtag(){dataLayer.push(arguments);}
|
|
gtag('js', new Date());
|
|
gtag('config', 'G-BQ229RRTTX', { 'anonymize_ip': false });
|
|
}
|
|
</script>
|
|
<link rel="alternate" type="application/rss+xml" href="https://go.cyub.vip/function/index.xml" title="深入Go语言之旅" />
|
|
<!--
|
|
Made with Book Theme
|
|
https://github.com/alex-shpak/hugo-book
|
|
-->
|
|
|
|
</head>
|
|
<body dir="ltr">
|
|
<input type="checkbox" class="hidden toggle" id="menu-control" />
|
|
<input type="checkbox" class="hidden toggle" id="toc-control" />
|
|
<main class="container flex">
|
|
<aside class="book-menu">
|
|
<div class="book-menu-content">
|
|
|
|
<nav>
|
|
<h2 class="book-brand">
|
|
<a class="flex align-center" href="/"><img src="https://static.cyub.vip/images/202310/golang-480.png" alt="Logo" /><span>深入Go语言之旅</span>
|
|
</a>
|
|
</h2>
|
|
|
|
|
|
<div class="book-search">
|
|
<input type="text" id="book-search-input" placeholder="Search" aria-label="Search" maxlength="64" data-hotkeys="s/" />
|
|
<div class="book-search-spinner hidden"></div>
|
|
<ul id="book-search-results"></ul>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ul>
|
|
|
|
<li>
|
|
<a href="https://www.cyub.vip/" target="_blank" rel="noopener">
|
|
个人博客
|
|
</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="https://github.com/cyub" target="_blank" rel="noopener">
|
|
Github主页
|
|
</a>
|
|
</li>
|
|
|
|
<li>
|
|
<a href="https://www.topgoer.cn/?ref=go.cyub.vip" target="_blank" rel="noopener">
|
|
地鼠文档
|
|
</a>
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ul>
|
|
<li>
|
|
<p><strong>准备篇</strong></p>
|
|
<ul>
|
|
<li>
|
|
<a href="/compiler/">编译流程</a></li>
|
|
<li>
|
|
<a href="/analysis-tools/">分析工具</a>
|
|
<ul>
|
|
<li>
|
|
<a href="/analysis-tools/gdb/">GDB</a></li>
|
|
<li>
|
|
<a href="/analysis-tools/dlv/">Delve</a></li>
|
|
<li>
|
|
<a href="/analysis-tools/go-buildin-tools/">Go 内置工具</a></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<a href="/go-assembly/">Go汇编</a></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<p><strong>基础篇</strong></p>
|
|
<ul>
|
|
<li>
|
|
<a href="/type/">数据类型与数据结构</a>
|
|
<ul>
|
|
<li>
|
|
<a href="/type/string/">字符串</a></li>
|
|
<li>
|
|
<a href="/type/array/">数组</a></li>
|
|
<li>
|
|
<a href="/type/slice/">切片</a></li>
|
|
<li>
|
|
<a href="/type/nil/">nil</a></li>
|
|
<li>
|
|
<a href="/type/empty_struct/">空结构体</a></li>
|
|
<li>
|
|
<a href="/type/pointer/">指针</a></li>
|
|
<li>
|
|
<a href="/type/map/">映射</a></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<a href="/function/"class=active>函数</a>
|
|
<ul>
|
|
<li>
|
|
<a href="/function/first-class/">一等公民</a></li>
|
|
<li>
|
|
<a href="/function/call-stack/">函数调用栈</a></li>
|
|
<li>
|
|
<a href="/function/pass-by-value/">值传递</a></li>
|
|
<li>
|
|
<a href="/function/closure/">闭包</a></li>
|
|
<li>
|
|
<a href="/function/method/">方法</a></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<a href="/feature/">语言特性</a>
|
|
<ul>
|
|
<li>
|
|
<a href="/feature/comma-ok/">逗号ok模式</a></li>
|
|
<li>
|
|
<a href="/feature/for-range/">遍历 - for-range语法</a></li>
|
|
<li>
|
|
<a href="/feature/defer/">延迟执行 - defer语法</a></li>
|
|
<li>
|
|
<a href="/feature/select/">通道选择器 - select语法</a></li>
|
|
<li>
|
|
<a href="/feature/panic-recover/">恐慌与恢复 - panic/recover</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<p><strong>运行时篇</strong></p>
|
|
<ul>
|
|
<li>
|
|
<a href="/concurrency/">并发编程</a>
|
|
<ul>
|
|
<li>
|
|
<a href="/concurrency/memory-model/">内存模型</a></li>
|
|
<li>
|
|
<a href="/concurrency/context/">上下文 - context</a></li>
|
|
<li>
|
|
<a href="/concurrency/channel/">通道 - channel</a></li>
|
|
<li>
|
|
<a href="/concurrency/atomic/">原子操作 - atomic</a></li>
|
|
<li>
|
|
<a href="/concurrency/sync-map/">并发Map - sync.Map</a></li>
|
|
<li>
|
|
<a href="/concurrency/sync-waitgroup/">等待组 - sync.WaitGroup</a></li>
|
|
<li>
|
|
<a href="/concurrency/sync-once/">一次性操作 - sync.Once</a></li>
|
|
<li>
|
|
<a href="/concurrency/sync-pool/">缓冲池 - sync.Pool</a></li>
|
|
<li>
|
|
<a href="/concurrency/sync-cond/">条件变量 - sync.Cond</a></li>
|
|
<li>
|
|
<a href="/concurrency/sync-mutex/">互斥锁 - sync.Mutex</a></li>
|
|
<li>
|
|
<a href="/concurrency/sync-rwmutex/">读写锁 - sync.RWMutex</a></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<a href="/gmp/">G-M-P调度机制</a>
|
|
<ul>
|
|
<li>
|
|
<a href="/gmp/gmp-model/">调度机制概述</a></li>
|
|
<li>
|
|
<a href="/gmp/scheduler/">调度器</a></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<a href="/memory/">内存管理</a>
|
|
<ul>
|
|
<li>
|
|
<a href="/memory/allocator/">内存分配器</a></li>
|
|
<li>
|
|
<a href="/memory/gc/">GC</a></li>
|
|
</ul>
|
|
</li>
|
|
<li>
|
|
<a href="/type-system/">类型系统</a>
|
|
<ul>
|
|
<li>
|
|
<a href="/type-system/type/">类型系统</a></li>
|
|
<li>
|
|
<a href="/type-system/interface/">接口</a></li>
|
|
<li>
|
|
<a href="/type-system/reflect/">反射</a></li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</nav>
|
|
|
|
|
|
|
|
|
|
<script>(function(){var e=document.querySelector("aside .book-menu-content");addEventListener("beforeunload",function(){localStorage.setItem("menu.scrollTop",e.scrollTop)}),e.scrollTop=localStorage.getItem("menu.scrollTop")})()</script>
|
|
|
|
|
|
|
|
</div>
|
|
</aside>
|
|
|
|
<div class="book-page">
|
|
<header class="book-header">
|
|
|
|
<div class="flex align-center justify-between">
|
|
<label for="menu-control">
|
|
<img src="/svg/menu.svg" class="book-icon" alt="Menu" />
|
|
</label>
|
|
|
|
<strong>函数</strong>
|
|
|
|
<label for="toc-control">
|
|
|
|
</label>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</header>
|
|
|
|
|
|
|
|
<article class="markdown"><h1 id="函数">
|
|
函数
|
|
<a class="anchor" href="#%e5%87%bd%e6%95%b0">#</a>
|
|
</h1>
|
|
<ul>
|
|
<li>
|
|
<a href="/function/first-class/">一等公民</a></li>
|
|
<li>
|
|
<a href="/function/call-stack/">函数调用栈</a></li>
|
|
<li>
|
|
<a href="/function/pass-by-value/">值传递</a></li>
|
|
<li>
|
|
<a href="/function/closure/">闭包</a></li>
|
|
<li>
|
|
<a href="/function/method/">方法</a></li>
|
|
</ul>
|
|
</article>
|
|
|
|
|
|
|
|
<footer class="book-footer">
|
|
|
|
<div class="flex flex-wrap justify-between">
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>(function(){function e(e){const t=window.getSelection(),n=document.createRange();n.selectNodeContents(e),t.removeAllRanges(),t.addRange(n)}document.querySelectorAll("pre code").forEach(t=>{t.addEventListener("click",function(){if(window.getSelection().toString())return;e(t.parentElement),navigator.clipboard&&navigator.clipboard.writeText(t.parentElement.textContent)})})})()</script>
|
|
|
|
|
|
|
|
|
|
</footer>
|
|
|
|
|
|
|
|
<div class="book-comments">
|
|
<div id="disqus_thread"></div>
|
|
<script type="application/javascript">
|
|
window.disqus_config = function () {
|
|
|
|
|
|
|
|
};
|
|
(function() {
|
|
if (["localhost", "127.0.0.1"].indexOf(window.location.hostname) != -1) {
|
|
document.getElementById('disqus_thread').innerHTML = 'Disqus comments not available by default when the website is previewed locally.';
|
|
return;
|
|
}
|
|
var d = document, s = d.createElement('script'); s.async = true;
|
|
s.src = '//' + "go-cyub-vip" + '.disqus.com/embed.js';
|
|
s.setAttribute('data-timestamp', +new Date());
|
|
(d.head || d.body).appendChild(s);
|
|
})();
|
|
</script>
|
|
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
|
|
<a href="https://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>
|
|
</div>
|
|
|
|
|
|
|
|
<label for="menu-control" class="hidden book-menu-overlay"></label>
|
|
</div>
|
|
|
|
|
|
</main>
|
|
|
|
|
|
</body>
|
|
</html>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|