1 Star 0 Fork 0

LJQ/blog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
a753c2b9.html 43.62 KB
一键复制 编辑 原始数据 按行查看 历史
LJQ 提交于 2025-01-13 21:04 . Site updated: 2025-01-13 21:04:28
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1"><meta><title>Go:pointer - Jack Liu Personal Site (ljq@GitHub).安全贯穿于软件开发各个环节.</title><link rel="manifest" href="/manifest.json"><meta name="application-name" content="Jack Liu Personal Site (ljq@GitHub).安全贯穿于软件开发各个环节."><meta name="msapplication-TileImage" content="/img/favicon.ico"><meta name="apple-mobile-web-app-capable" content="yes"><meta name="apple-mobile-web-app-title" content="Jack Liu Personal Site (ljq@GitHub).安全贯穿于软件开发各个环节."><meta name="apple-mobile-web-app-status-bar-style" content="default"><meta name="description" content="pointer 指针基于指针对象的方法当调用一个函数时,会对其每一个参数值进行拷贝,如果一个函数需要更新一个变量,或者函数的其中一个参数实在太大我们希望能够避免进行这种默认的拷贝,这种情况下我们就需要用到指针了。对应到我们这里用来更新接收器的对象的方法,当这个接受者变量本身比较大时,我们就可以用其指针而不是对象来声明方法,如下:"><meta property="og:type" content="blog"><meta property="og:title" content="Go:pointer"><meta property="og:url" content="https://www.defense.ink/a753c2b9.html"><meta property="og:site_name" content="Jack Liu Personal Site (ljq@GitHub).安全贯穿于软件开发各个环节."><meta property="og:description" content="pointer 指针基于指针对象的方法当调用一个函数时,会对其每一个参数值进行拷贝,如果一个函数需要更新一个变量,或者函数的其中一个参数实在太大我们希望能够避免进行这种默认的拷贝,这种情况下我们就需要用到指针了。对应到我们这里用来更新接收器的对象的方法,当这个接受者变量本身比较大时,我们就可以用其指针而不是对象来声明方法,如下:"><meta property="og:locale" content="en_US"><meta property="og:image" content="https://source.unsplash.com/random/800x600/?pointer,code"><meta property="article:published_time" content="2020-02-26T22:02:08.000Z"><meta property="article:modified_time" content="2024-02-17T03:35:16.587Z"><meta property="article:author" content="Jack Liu"><meta property="article:tag" content="Go"><meta property="article:tag" content="pointer"><meta property="twitter:card" content="summary"><meta property="twitter:image" content="https://source.unsplash.com/random/800x600/?pointer,code"><script type="application/ld+json">{"@context":"https://schema.org","@type":"BlogPosting","mainEntityOfPage":{"@type":"WebPage","@id":"https://www.defense.ink/a753c2b9.html"},"headline":"Go:pointer","image":[],"datePublished":"2020-02-26T22:02:08.000Z","dateModified":"2024-02-17T03:35:16.587Z","author":{"@type":"Person","name":"Jack Liu"},"publisher":{"@type":"Organization","name":"Jack Liu Personal Site (ljq@GitHub).安全贯穿于软件开发各个环节.","logo":{"@type":"ImageObject","url":"https://www.defense.ink/img/logo.svg"}},"description":"pointer 指针基于指针对象的方法当调用一个函数时,会对其每一个参数值进行拷贝,如果一个函数需要更新一个变量,或者函数的其中一个参数实在太大我们希望能够避免进行这种默认的拷贝,这种情况下我们就需要用到指针了。对应到我们这里用来更新接收器的对象的方法,当这个接受者变量本身比较大时,我们就可以用其指针而不是对象来声明方法,如下:"}</script><link rel="canonical" href="https://www.defense.ink/a753c2b9.html"><link rel="alternate" href="/atom.xml" title="Jack Liu Personal Site (ljq@GitHub).安全贯穿于软件开发各个环节." type="application/atom+xml"><link rel="icon" href="/img/favicon.ico"><link rel="stylesheet" href="https://cdnjs.loli.net/ajax/libs/font-awesome/5.15.2/css/all.min.css"><link rel="stylesheet" href="https://cdnjs.loli.net/ajax/libs/highlight.js/9.12.0/styles/atom-one-dark.min.css"><link rel="stylesheet" href="https://fonts.loli.net/css2?family=Ubuntu:wght@400;600&amp;family=Source+Code+Pro"><link rel="stylesheet" href="/css/default.css"><style>body>.footer,body>.navbar,body>.section{opacity:0}</style><script>!function(){var e=document.createElement("script"),t=(e.src="//hm.baidu.com/hm.js?9f72b89b2ff66be1d913039ecbd3bc14",document.getElementsByTagName("script")[0]);t.parentNode.insertBefore(e,t)}()</script><meta name="msvalidate.01" content="ad0df3c8d20f49daaeb5baa3c9dbfe75"><link rel="stylesheet" href="https://cdnjs.loli.net/ajax/libs/cookieconsent/3.1.1/cookieconsent.min.css"><link rel="stylesheet" href="https://cdnjs.loli.net/ajax/libs/lightgallery/1.10.0/css/lightgallery.min.css"><link rel="stylesheet" href="https://cdnjs.loli.net/ajax/libs/justifiedGallery/3.8.1/css/justifiedGallery.min.css"><style>.pace{-webkit-pointer-events:none;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.pace-inactive{display:none}.pace .pace-progress{background:#3273dc;position:fixed;z-index:2000;top:0;right:100%;width:100%;height:2px}</style><script src="https://cdnjs.loli.net/ajax/libs/pace/1.2.4/pace.min.js"></script><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8952360410310192" crossorigin="anonymous"></script><script>!function(){function e(){if(location.hash){Array.from(document.querySelectorAll(".tab-content")).forEach(e=>{e.classList.add("is-hidden")}),Array.from(document.querySelectorAll(".tabs li")).forEach(e=>{e.classList.remove("is-active")});const e=document.querySelector(location.hash),t=(e&&e.classList.remove("is-hidden"),document.querySelector(`a[href="${location.hash}"]`));t&&t.parentElement.classList.add("is-active")}}e(),window.addEventListener("hashchange",e,!1)}()</script><meta name="generator" content="Hexo 6.1.0"></head><body class="is-2-column"><img src="/img/avatar.jpeg" width="0" height="0"><nav class="navbar navbar-main"><div class="container navbar-container"><div class="navbar-brand justify-content-center"><a class="navbar-item navbar-logo" href="/"><img src="/img/logo.svg" alt="Jack Liu Personal Site (ljq@GitHub).安全贯穿于软件开发各个环节." height="28"></a></div><div class="navbar-menu"><div class="navbar-start"><a class="navbar-item" href="/">Home</a><a class="navbar-item" href="/archives">Archives</a><a class="navbar-item" href="/categories">Categories</a><a class="navbar-item" href="/tags">Tags</a><a class="navbar-item" href="/musics">Musics</a><a class="navbar-item" href="/videos">Videos</a><a class="navbar-item" href="/galleries">Galleries</a><a class="navbar-item" href="/about">About</a></div><div class="navbar-end"><a class="navbar-item dark-mode-btn" title="Light|Dark" rel="noopener" onclick="switchDarkMode()">    <i class="fas fa-lightbulb">  </i></a><a class="navbar-item" target="_blank" rel="noopener" title="Musics" href="/musics"><i class="fas fa-music"></i></a><a class="navbar-item" target="_blank" rel="noopener" title="Videos" href="/videos"><i class="fas fa-video"></i></a><a class="navbar-item" target="_blank" rel="noopener" title="WeChat Account (labsec)" href="/about/index/ljq-qrcode.jpeg"><i class="fab fa-weixin"></i></a><a class="navbar-item" target="_blank" rel="noopener" title="Jack Liu GitHub" href="https://github.com/ljq"><i class="fab fa-github"></i></a><a class="navbar-item is-hidden-tablet catalogue" title="Catalogue" href="javascript:;"><i class="fas fa-list-ul"></i></a><a class="navbar-item search" title="Search" href="javascript:;"><i class="fas fa-search"></i></a></div></div></div></nav><section class="section"><div class="container"><div class="columns"><div class="column order-2 column-main is-8-tablet is-8-desktop is-9-widescreen"><div class="card"><div class="card-image"><span class="image is-7by3"><img class="fill" src="https://source.unsplash.com/random/800x600/?pointer,code" alt="Go:pointer"></span></div><article class="card-content article" role="article"><div class="article-meta is-size-7 is-uppercase level is-mobile"><div class="level-left"><span class="level-item">Posted&nbsp;<time datetime="2020-02-26T22:02:08.000Z" title="2/27/2020, 6:02:08 AM">2020-02-27</time></span><span class="level-item">Updated&nbsp;<time datetime="2024-02-17T03:35:16.587Z" title="2/17/2024, 11:35:16 AM">2024-02-17</time></span><span class="level-item"> Jack Liu </span><span class="level-item"><a class="link-muted" href="/categories/Go/">Go</a></span><span class="level-item">10 minutes read (About 1468 words)</span></div></div><h1 class="title is-3 is-size-4-mobile">Go:pointer</h1><div class="content"><h3 id="pointer-指针"><a href="#pointer-指针" class="headerlink" title="pointer 指针"></a>pointer 指针</h3><h4 id="基于指针对象的方法"><a href="#基于指针对象的方法" class="headerlink" title="基于指针对象的方法"></a>基于指针对象的方法</h4><p>当调用一个函数时,会对其每一个参数值进行拷贝,如果一个函数需要更新一个变量,或者函数的其中一个参数实在太大我们希望能够避免进行这种默认的拷贝,这种情况下我们就需要用到指针了。对应到我们这里用来更新接收器的对象的方法,当这个接受者变量本身比较大时,我们就可以用其指针而不是对象来声明方法,如下:</p><span id="more"></span><p>func (p *Point) ScaleBy(factor float64) {<br>p.X *&#x3D; factor<br>p.Y *&#x3D; factor<br>}<br>这个方法的名字是(<em>Point).ScaleBy。这里的括号是必须的;没有括号的话这个表达式可能会被理解为</em>(Point.ScaleBy)。</p><p>在现实的程序里,一般会约定如果Point这个类有一个指针作为接收器的方法,那么所有Point的方法都必须有一个指针接收器,即使是那些并不需要这个指针接收器的函数。我们在这里打破了这个约定只是为了展示一下两种方法的异同而已。</p><p>只有类型(Point)和指向他们的指针(*Point),才是可能会出现在接收器声明里的两种接收器。此外,为了避免歧义,在声明方法时,如果一个类型名本身是一个指针的话,是不允许其出现在接收器中的,比如下面这个例子:</p><p>type P <em>int<br>func (P) f() { &#x2F;</em> … *&#x2F; } &#x2F;&#x2F; compile error: invalid receiver type<br>想要调用指针类型方法(*Point).ScaleBy,只要提供一个Point类型的指针即可,像下面这样。</p><p>r :&#x3D; &amp;Point{1, 2}<br>r.ScaleBy(2)<br>fmt.Println(*r) &#x2F;&#x2F; “{2, 4}”<br>或者这样:</p><p>p :&#x3D; Point{1, 2}<br>pptr :&#x3D; &amp;p<br>pptr.ScaleBy(2)<br>fmt.Println(p) &#x2F;&#x2F; “{2, 4}”<br>或者这样:</p><p>p :&#x3D; Point{1, 2}<br>(&amp;p).ScaleBy(2)<br>fmt.Println(p) &#x2F;&#x2F; “{2, 4}”<br>不过后面两种方法有些笨拙。幸运的是,go语言本身在这种地方会帮到我们。如果接收器p是一个Point类型的变量,并且其方法需要一个Point指针作为接收器,我们可以用下面这种简短的写法:</p><p>p.ScaleBy(2)<br>编译器会隐式地帮我们用&amp;p去调用ScaleBy这个方法。这种简写方法只适用于“变量”,包括struct里的字段比如p.X,以及array和slice内的元素比如perim[0]。我们不能通过一个无法取到地址的接收器来调用指针方法,比如临时变量的内存地址就无法获取得到:</p><p>Point{1, 2}.ScaleBy(2) &#x2F;&#x2F; compile error: can’t take address of Point literal<br>但是我们可以用一个<em>Point这样的接收器来调用Point的方法,因为我们可以通过地址来找到这个变量,只要用解引用符号</em>来取到该变量即可。编译器在这里也会给我们隐式地插入*这个操作符,所以下面这两种写法等价的:</p><p>pptr.Distance(q)<br>(*pptr).Distance(q)<br>这里的几个例子可能让你有些困惑,所以我们总结一下:在每一个合法的方法调用表达式中,也就是下面三种情况里的任意一种情况都是可以的:</p><p>不论是接收器的实际参数和其接收器的形式参数相同,比如两者都是类型T或者都是类型*T:</p><p>Point{1, 2}.Distance(q) &#x2F;&#x2F; Point<br>pptr.ScaleBy(2) &#x2F;&#x2F; <em>Point<br>或者接收器实参是类型T,但接收器形参是类型</em>T,这种情况下编译器会隐式地为我们取变量的地址:</p><p>p.ScaleBy(2) &#x2F;&#x2F; implicit (&amp;p)<br>或者接收器实参是类型*T,形参是类型T。编译器会隐式地为我们解引用,取到指针指向的实际变量:</p><p>pptr.Distance(q) &#x2F;&#x2F; implicit (<em>pptr)<br>如果命名类型T(译注:用type xxx定义的类型)的所有方法都是用T类型自己来做接收器(而不是</em>T),那么拷贝这种类型的实例就是安全的;调用他的任何一个方法也就会产生一个值的拷贝。比如time.Duration的这个类型,在调用其方法时就会被全部拷贝一份,包括在作为参数传入函数的时候。但是如果一个方法使用指针作为接收器,你需要避免对其进行拷贝,因为这样可能会破坏掉该类型内部的不变性。比如你对bytes.Buffer对象进行了拷贝,那么可能会引起原始对象和拷贝对象只是别名而已,但实际上其指向的对象是一致的。紧接着对拷贝后的变量进行修改可能会有让你意外的结果。</p><p>译注: 作者这里说的比较绕,其实有两点:</p><p>不管你的method的receiver是指针类型还是非指针类型,都是可以通过指针&#x2F;非指针类型进行调用的,编译器会帮你做类型转换。<br>在声明一个method的receiver该是指针还是非指针类型时,你需要考虑两方面的内部,第一方面是这个对象本身是不是特别大,如果声明为非指针变量时,调用会产生一次拷贝;第二方面是如果你用指针类型作为receiver,那么你一定要注意,这种指针类型指向的始终是一块内存地址,就算你对其进行了拷贝。熟悉C或者C艹的人这里应该很快能明白。</p></div><div class="article-licensing box"><div class="licensing-title"><p>Go:pointer</p><p><a href="https://www.defense.ink/a753c2b9.html">https://www.defense.ink/a753c2b9.html</a></p></div><div class="licensing-meta level is-mobile"><div class="level-left"><div class="level-item is-narrow"><div><h6>Author</h6><p>Jack Liu</p></div></div><div class="level-item is-narrow"><div><h6>Posted on</h6><p>2020-02-27</p></div></div><div class="level-item is-narrow"><div><h6>Updated on</h6><p>2024-02-17</p></div></div><div class="level-item is-narrow"><div><h6>Licensed under</h6><p><a class="icons" rel="noopener" target="_blank" title="Creative Commons" href="https://creativecommons.org/"><i class="icon fab fa-creative-commons"></i></a><a class="icons" rel="noopener" target="_blank" title="Attribution" href="https://creativecommons.org/licenses/by/4.0/"><i class="icon fab fa-creative-commons-by"></i></a><a class="icons" rel="noopener" target="_blank" title="Noncommercial" href="https://creativecommons.org/licenses/by-nc/4.0/"><i class="icon fab fa-creative-commons-nc"></i></a></p></div></div></div></div></div><div class="article-tags is-size-7 mb-4"><span class="mr-2">#</span><a class="link-muted mr-2" rel="tag" href="/tags/Go/">Go</a><a class="link-muted mr-2" rel="tag" href="/tags/pointer/">pointer</a></div><div class="sharethis-inline-share-buttons"></div><script src="https://platform-api.sharethis.com/js/sharethis.js#property=627845fc01dad800199bf3d4&amp;product=inline-share-buttons" defer></script></article></div><nav class="post-navigation mt-4 level is-mobile"><div class="level-start"><a class="article-nav-prev level level-item link-muted" href="/53f6e137.html"><i class="level-item fas fa-chevron-left"></i><span class="level-item">Go:reflect 反射</span></a></div><div class="level-end"><a class="article-nav-next level level-item link-muted" href="/31b42193.html"><span class="level-item">Go:null judge</span><i class="level-item fas fa-chevron-right"></i></a></div></nav><script src="https://cdn.bootcdn.net/ajax/libs/mermaid/8.13.8/mermaid.min.js"></script></div><div class="column column-right is-4-tablet is-4-desktop is-3-widescreen order-3"><div class="card widget" id="toc" data-type="toc"><div class="card-content"><div class="menu"><h3 class="menu-label">Catalogue</h3><ul class="menu-list"><li><a class="level is-mobile" href="#pointer-指针"><span class="level-left"><span class="level-item">1</span><span class="level-item">pointer 指针</span></span></a><ul class="menu-list"><li><a class="level is-mobile" href="#基于指针对象的方法"><span class="level-left"><span class="level-item">1.1</span><span class="level-item">基于指针对象的方法</span></span></a></li></ul></li></ul></div></div><style>#toc .menu-list>li>a.is-active+.menu-list{display:block}#toc .menu-list>li>a+.menu-list{display:none}</style><script src="/js/toc.js" defer></script></div><div class="card widget" data-type="recent-posts"><div class="card-content"><h3 class="menu-label">Recents</h3><article class="media"><figure class="media-left"><a class="image" href="/bafde551.html"><img src="https://source.unsplash.com/random/80x60/?keyboard" alt="macOS Ghostty Terminal Ddefault binding keyboard shortcut key list(Ghostty.org Ghostty 终端默认快捷键列表)"></a></figure><div class="media-content"><p class="date"><time datetime="2025-01-13T14:02:02.000Z">2025-01-13</time></p><p class="title"><a href="/bafde551.html">macOS Ghostty Terminal Ddefault binding keyboard shortcut key list(Ghostty.org Ghostty 终端默认快捷键列表)</a></p><p class="categories"><a href="/categories/macos/">macos</a></p></div></article><article class="media"><figure class="media-left"><a class="image" href="/187f82a.html"><img src="/./static/images/daily/2024-09-28-rszmfdd.jpeg" alt="人是怎样废掉的?"></a></figure><div class="media-content"><p class="date"><time datetime="2024-09-28T11:18:08.000Z">2024-09-28</time></p><p class="title"><a href="/187f82a.html">人是怎样废掉的?</a></p><p class="categories"><a href="/categories/daily/">daily</a> / <a href="/categories/daily/note/">note</a></p></div></article><article class="media"><figure class="media-left"><a class="image" href="/96f1067a.html"><img src="https://source.unsplash.com/random/80x60/?rocky-linux,linux" alt="Rocky Linux系统初始化常用基础命令和工具包的便捷安装脚本(ljq@GitHub)"></a></figure><div class="media-content"><p class="date"><time datetime="2024-07-04T13:47:01.000Z">2024-07-04</time></p><p class="title"><a href="/96f1067a.html">Rocky Linux系统初始化常用基础命令和工具包的便捷安装脚本(ljq@GitHub)</a></p><p class="categories"><a href="/categories/linux/">linux</a> / <a href="/categories/linux/centos/">centos</a></p></div></article><article class="media"><figure class="media-left"><a class="image" href="/93d6d12a.html"><img src="https://source.unsplash.com/random/80x60/?mysql" alt="MySQL 8.0为什么使用utf8mb4_0900_ai_ci默认校对规则,而不使用utf8mb4_general_ci?"></a></figure><div class="media-content"><p class="date"><time datetime="2024-06-19T14:02:02.000Z">2024-06-19</time></p><p class="title"><a href="/93d6d12a.html">MySQL 8.0为什么使用utf8mb4_0900_ai_ci默认校对规则,而不使用utf8mb4_general_ci?</a></p><p class="categories"><a href="/categories/Database/">Database</a></p></div></article><article class="media"><figure class="media-left"><a class="image" href="/de20129e.html"><img src="https://source.unsplash.com/random/80x60/?google" alt="《如何创建一家像谷歌一样的公司》(How to start Google)- paulgraham - 转载"></a></figure><div class="media-content"><p class="date"><time datetime="2024-03-27T16:51:01.000Z">2024-03-28</time></p><p class="title"><a href="/de20129e.html">《如何创建一家像谷歌一样的公司》(How to start Google)- paulgraham - 转载</a></p><p class="categories"><a href="/categories/reprinted-articles/">reprinted-articles</a></p></div></article></div></div><div class="card widget" data-type="categories"><div class="card-content"><div class="menu"><h3 class="menu-label">Categories</h3><ul class="menu-list"><li><a class="level is-mobile" href="/categories/AI/"><span class="level-start"><span class="level-item">AI</span></span><span class="level-end"><span class="level-item tag">1</span></span></a><ul><li><a class="level is-mobile" href="/categories/AI/painting/"><span class="level-start"><span class="level-item">painting</span></span><span class="level-end"><span class="level-item tag">1</span></span></a><ul><li><a class="level is-mobile" href="/categories/AI/painting/Controlnet/"><span class="level-start"><span class="level-item">Controlnet</span></span><span class="level-end"><span class="level-item tag">1</span></span></a><ul><li><a class="level is-mobile" href="/categories/AI/painting/Controlnet/Drawing/"><span class="level-start"><span class="level-item">Drawing</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li></ul></li></ul></li></ul></li><li><a class="level is-mobile" href="/categories/Algorithm/"><span class="level-start"><span class="level-item">Algorithm</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-mobile" href="/categories/Database/"><span class="level-start"><span class="level-item">Database</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-mobile" href="/categories/GIT/"><span class="level-start"><span class="level-item">GIT</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-mobile" href="/categories/Go/"><span class="level-start"><span class="level-item">Go</span></span><span class="level-end"><span class="level-item tag">24</span></span></a></li><li><a class="level is-mobile" href="/categories/JavaScript/"><span class="level-start"><span class="level-item">JavaScript</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-mobile" href="/categories/clang/"><span class="level-start"><span class="level-item">clang</span></span><span class="level-end"><span class="level-item tag">5</span></span></a></li><li><a class="level is-mobile" href="/categories/daily/"><span class="level-start"><span class="level-item">daily</span></span><span class="level-end"><span class="level-item tag">3</span></span></a><ul><li><a class="level is-mobile" href="/categories/daily/note/"><span class="level-start"><span class="level-item">note</span></span><span class="level-end"><span class="level-item tag">2</span></span></a></li></ul></li><li><a class="level is-mobile" href="/categories/distributed/"><span class="level-start"><span class="level-item">distributed</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-mobile" href="/categories/history-of-programing/"><span class="level-start"><span class="level-item">history-of-programing</span></span><span class="level-end"><span class="level-item tag">1</span></span></a><ul><li><a class="level is-mobile" href="/categories/history-of-programing/daily/"><span class="level-start"><span class="level-item">daily</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li></ul></li><li><a class="level is-mobile" href="/categories/linux/"><span class="level-start"><span class="level-item">linux</span></span><span class="level-end"><span class="level-item tag">6</span></span></a><ul><li><a class="level is-mobile" href="/categories/linux/centos/"><span class="level-start"><span class="level-item">centos</span></span><span class="level-end"><span class="level-item tag">3</span></span></a></li><li><a class="level is-mobile" href="/categories/linux/debian/"><span class="level-start"><span class="level-item">debian</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-mobile" href="/categories/linux/firewalld/"><span class="level-start"><span class="level-item">firewalld</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-mobile" href="/categories/linux/openssl/"><span class="level-start"><span class="level-item">openssl</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li></ul></li><li><a class="level is-mobile" href="/categories/lua/"><span class="level-start"><span class="level-item">lua</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-mobile" href="/categories/macos/"><span class="level-start"><span class="level-item">macos</span></span><span class="level-end"><span class="level-item tag">5</span></span></a></li><li><a class="level is-mobile" href="/categories/php/"><span class="level-start"><span class="level-item">php</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li><li><a class="level is-mobile" href="/categories/reprinted-articles/"><span class="level-start"><span class="level-item">reprinted-articles</span></span><span class="level-end"><span class="level-item tag">1</span></span></a></li></ul></div></div></div><div class="card widget" data-type="tags"><div class="card-content"><div class="menu"><h3 class="menu-label">Tags</h3><div class="field is-grouped is-grouped-multiline"><div class="control"><a class="tags has-addons" href="/tags/AI/"><span class="tag">AI</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/CDN/"><span class="tag">CDN</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Cloud-Distributed/"><span class="tag">Cloud-Distributed</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Distributed-Systems/"><span class="tag">Distributed-Systems</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/GIT/"><span class="tag">GIT</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/GO%E6%96%B9%E6%B3%95%E5%80%BC/"><span class="tag">GO方法值</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/GPG/"><span class="tag">GPG</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/GPG2/"><span class="tag">GPG2</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/GUI/"><span class="tag">GUI</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Ghostty/"><span class="tag">Ghostty</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Go/"><span class="tag">Go</span><span class="tag">24</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Go-Summary-notes/"><span class="tag">Go Summary notes</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Go-null-judge/"><span class="tag">Go null judge</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Go-Struct-Method-Receiver/"><span class="tag">Go(Struct|Method|Receiver)</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Go-map/"><span class="tag">Go(map)</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Go-new-make-struct/"><span class="tag">Go(new,make,struct{})</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Go-string/"><span class="tag">Go(string)</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Go-Polymorphism/"><span class="tag">Go-Polymorphism</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Go-Printf/"><span class="tag">Go-Printf</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Go-chain-operation/"><span class="tag">Go-chain-operation</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Go-init/"><span class="tag">Go-init()</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Google/"><span class="tag">Google</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/JS/"><span class="tag">JS</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/JSON/"><span class="tag">JSON</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/JavaScript/"><span class="tag">JavaScript</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Movie/"><span class="tag">Movie</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/Note-The-Legend-of-1900/"><span class="tag">Note The Legend of 1900</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/OpenSSH/"><span class="tag">OpenSSH</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/VIM/"><span class="tag">VIM</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/VIM-Author/"><span class="tag">VIM Author</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/ansi-lib/"><span class="tag">ansi-lib</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/banner/"><span class="tag">banner</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/centos7/"><span class="tag">centos7</span><span class="tag">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/chattr/"><span class="tag">chattr</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/clang/"><span class="tag">clang</span><span class="tag">6</span></a></div><div class="control"><a class="tags has-addons" href="/tags/cli/"><span class="tag">cli</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/daily/"><span class="tag">daily</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/debian/"><span class="tag">debian</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/firewalld/"><span class="tag">firewalld</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/format/"><span class="tag">format</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/func/"><span class="tag">func</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/go/"><span class="tag">go</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/go-pprof/"><span class="tag">go-pprof</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/goroutine/"><span class="tag">goroutine</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/hexo/"><span class="tag">hexo</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/homebrew/"><span class="tag">homebrew</span><span class="tag">3</span></a></div><div class="control"><a class="tags has-addons" href="/tags/interface/"><span class="tag">interface</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/io/"><span class="tag">io</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/laravel/"><span class="tag">laravel</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/laravel-artisan/"><span class="tag">laravel-artisan</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/linux/"><span class="tag">linux</span><span class="tag">5</span></a></div><div class="control"><a class="tags has-addons" href="/tags/lua/"><span class="tag">lua</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/macos/"><span class="tag">macos</span><span class="tag">3</span></a></div><div class="control"><a class="tags has-addons" href="/tags/macro/"><span class="tag">macro</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/motd/"><span class="tag">motd</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/mysql/"><span class="tag">mysql</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/mysql8-0/"><span class="tag">mysql8.0</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/mysql8-x/"><span class="tag">mysql8.x</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/neofetch/"><span class="tag">neofetch</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/nginx/"><span class="tag">nginx</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/package-time/"><span class="tag">package time</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/php/"><span class="tag">php</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/pointer/"><span class="tag">pointer</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/reflect%E5%8F%8D%E5%B0%84/"><span class="tag">reflect反射</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/rocky/"><span class="tag">rocky</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/rocky-linux/"><span class="tag">rocky-linux</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/rocky-linux-tools/"><span class="tag">rocky-linux-tools</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/rsync/"><span class="tag">rsync</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/services/"><span class="tag">services</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/slice%E5%88%87%E7%89%87%E6%9C%AC%E8%B4%A8/"><span class="tag">slice切片本质</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/stable-diffusion-webui/"><span class="tag">stable-diffusion-webui</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/struct/"><span class="tag">struct</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/switch/"><span class="tag">switch</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/systemd-service/"><span class="tag">systemd-service</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/terminal/"><span class="tag">terminal</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/travel/"><span class="tag">travel</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/type/"><span class="tag">type</span><span class="tag">2</span></a></div><div class="control"><a class="tags has-addons" href="/tags/type%E5%85%B3%E9%94%AE%E8%AF%8D%E6%80%BB%E7%BB%93/"><span class="tag">type关键词总结</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/utf8mb4/"><span class="tag">utf8mb4</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/utf8mb4-0900-ai-ci/"><span class="tag">utf8mb4_0900_ai_ci</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/utf8mb4-general-ci/"><span class="tag">utf8mb4_general_ci</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E4%BA%BA%E7%94%9F/"><span class="tag">人生</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E6%97%A5%E5%B8%B8/"><span class="tag">日常</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E7%94%9F%E6%B4%BB/"><span class="tag">生活</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E8%BD%AC%E8%BD%BD/"><span class="tag">转载</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6%E4%BD%93%E7%B3%BB/"><span class="tag">配置文件体系</span><span class="tag">1</span></a></div><div class="control"><a class="tags has-addons" href="/tags/%E9%98%B2%E7%81%AB%E5%A2%99/"><span class="tag">防火墙</span><span class="tag">1</span></a></div></div></div></div></div><div class="card widget" data-type="clustrmaps"><div class="card-content"><div class="menu"><h3 class="menu-label">CLUSTRMAPS</h3></div><nav class="level"><div class="level-item has-text-centered flex-shrink-1"><div style="margin-top:10px"><script type="text/javascript" id="clustrmaps" src="https://cdn.clustrmaps.com/map_v2.js?cl=ffffff&amp;w=250&amp;t=n&amp;d=xb7wV_PHYtl9KaSZpQgP9CLUNrXlqm480vcarJmX2A0&amp;co=2d78ad&amp;cmo=3acc3a&amp;cmn=ff5353&amp;ct=ffffff"></script><script type="text/javascript" id="clstr_globe" src="https://clustrmaps.com/globe.js?d=xb7wV_PHYtl9KaSZpQgP9CLUNrXlqm480vcarJmX2A0"></script></div></div></nav></div></div><div class="card widget" data-type="adsense"><div class="card-content"><div class="menu"><h3 class="menu-label">Advertisement</h3><script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script><ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-8952360410310192" data-ad-slot="1345698037" data-ad-format="auto" data-full-width-responsive="true"></ins><script>(adsbygoogle=window.adsbygoogle||[]).push({})</script></div></div></div></div></div></div></section><footer class="footer" style="padding:1rem 1.5rem 0"><div class="container"><div class="level"><div class="level-start"><p class="is-size-7"><a class="footer-logo" style="margin-right:10px" href="/"><img src="/img/logo.svg" alt="Jack Liu Personal Site (ljq@GitHub).安全贯穿于软件开发各个环节." height="16" style="max-height:1.25rem"></a><a href="http://beian.miit.gov.cn" target="_blank">鲁ICP备2023051700号</a>  <span>&copy; 2025 Jack Liu</span>  <span style="color:#e0e0e0">Powered by <a style="color:#e0e0e0" href="https://hexo.io/" target="_blank" rel="noopener">Hexo</a> &amp; <a style="color:#e0e0e0" href="https://github.com/ppoffice/hexo-theme-icarus" target="_blank" rel="noopener">Icarus</a></span><script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>  <span id="busuanzi_container_site_pv">Total Visits Counts: <span id="busuanzi_value_site_pv"></span>.</span></p></div><div class="level-end"><div class="field has-addons"><p class="control"><a class="button is-transparent is-large" target="_blank" rel="noopener" title="Creative Commons" href="https://creativecommons.org/"><i class="fab fa-creative-commons"></i></a></p><p class="control"><a class="button is-transparent is-large" target="_blank" rel="noopener" title="Attribution 4.0 International" href="https://creativecommons.org/licenses/by/4.0/"><i class="fab fa-creative-commons-by"></i></a></p><p class="control"><a class="button is-transparent is-large" target="_blank" rel="noopener" title="Jack Liu&#039;GitHub" href="https://github.com/ljq"><i class="fab fa-github"></i></a></p><p class="control"><a class="button is-transparent is-large" target="_blank" rel="noopener" title="ref.wdft.com" href="https://ref.wdft.com"><i class="fas fa-cloud"></i></a></p><p class="control"><a class="button is-transparent is-large" target="_blank" rel="noopener" title="cook.wdft.com" href="https://cook.wdft.com"><i class="fas fa-coffee"></i></a></p> <span><i class="fas fa-link">BlogRoll:</i></span><p class="control" style="color:#26c1fa"><a class="button is-transparent" target="_blank" rel="noopener" title="Quick Reference" href="https://ref.wdft.com">Quick Reference</a></p><p class="control" style="color:#26c1fa"><a class="button is-transparent" target="_blank" rel="noopener" title="Cook" href="https://cook.wdft.com">Cook</a></p></div></div></div></div></footer><script src="https://cdnjs.loli.net/ajax/libs/jquery/3.3.1/jquery.min.js"></script><script src="https://cdnjs.loli.net/ajax/libs/moment.js/2.22.2/moment-with-locales.min.js"></script><script src="https://cdnjs.loli.net/ajax/libs/clipboard.js/2.0.4/clipboard.min.js" defer></script><script>moment.locale("en")</script><script>var IcarusThemeSettings={article:{highlight:{clipboard:!0,fold:"unfolded"}}}</script><script src="/js/column.js"></script><script src="/js/animation.js"></script><a id="back-to-top" title="Back to top" href="javascript:;"><i class="fas fa-chevron-up"></i></a><script src="/js/back_to_top.js" defer></script><script src="/js/switchDarkMode.js" defer></script><script src="/js/toutiaoSEO.js" defer></script><script src="https://cdnjs.loli.net/ajax/libs/cookieconsent/3.1.1/cookieconsent.min.js" defer></script><script>window.addEventListener("load",()=>{window.cookieconsent.initialise({type:"info",theme:"edgeless",static:!1,position:"bottom-left",content:{message:"This website uses cookies to improve your experience.",dismiss:"Got it!",allow:"Allow cookies",deny:"Decline",link:"Learn more",policy:"Cookie Policy",href:"https://www.cookiesandyou.com/"},palette:{popup:{background:"#edeff5",text:"#838391"},button:{background:"#4b81e8"}}})})</script><script src="https://cdnjs.loli.net/ajax/libs/lightgallery/1.10.0/js/lightgallery.min.js" defer></script><script src="https://cdnjs.loli.net/ajax/libs/justifiedGallery/3.8.1/js/jquery.justifiedGallery.min.js" defer></script><script>window.addEventListener("load",()=>{"function"==typeof $.fn.lightGallery&&$(".article").lightGallery({selector:".gallery-item"}),"function"==typeof $.fn.justifiedGallery&&($(".justified-gallery > p > .gallery-item").length&&$(".justified-gallery > p > .gallery-item").unwrap(),$(".justified-gallery").justifiedGallery())})</script><script src="/js/main.js" defer></script><div class="searchbox"><div class="searchbox-container"><div class="searchbox-header"><div class="searchbox-input-container"><input class="searchbox-input" type="text" placeholder="Type something..."></div><a class="searchbox-close" href="javascript:;">×</a></div><div class="searchbox-body"></div></div></div><script src="/js/insight.js" defer></script><script>document.addEventListener("DOMContentLoaded",function(){loadInsight({contentUrl:"/content.json"},{hint:"Type something...",untitled:"(Untitled)",posts:"Posts",pages:"Pages",categories:"Categories",tags:"Tags"})})</script><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({pluginModelPath:"assets/",tagMode:!1,log:!1,model:{jsonPath:"/live2dw/assets/hijiki.model.json"},display:{position:"right",width:150,height:300},mobile:{show:!0},react:{opacity:.7},pluginJsPath:"lib/",pluginRootPath:"live2dw/"})</script></body></html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
HTML/CSS
1
https://gitee.com/jqe/blog.git
[email protected]:jqe/blog.git
jqe
blog
blog
master

搜索帮助