Day-00012

原文

Tutorial: Get started with Go

Table of Contents
Prerequisites

Install Go

Write some code

Call code in an external package

Write more code

In this tutorial, you'll get a brief introduction to Go programming. Along the way, you will:

  • Install Go (if you haven't already).
  • Write some simple "Hello, world" code.
  • Use the go command to run your code.
  • Use the Go package discovery tool to find packages you can use in your own code.
  • Call functions of an external module.

Note: For other tutorials, see Tutorials.

Prerequisites

  • Some programming experience. The code here is pretty simple, but it helps to know something about functions.
  • A tool to edit your code. Any text editor you have will work fine. Most text editors have good support for Go. The most popular are VSCode (free), GoLand (paid), and Vim (free).
  • A command terminal. Go works well using any terminal on Linux and Mac, and on PowerShell or cmd in Windows.

Install Go

Just use the Download and install steps.

Write some code

Get started with Hello, World.

  1. Open a command prompt and cd to your home directory.

    On Linux or Mac:

    cd
    

    On Windows:

    cd %HOMEPATH%
    
  2. Create a hello directory for your first Go source code.

    For example, use the following commands:

    mkdir hello
    cd hello
    
  3. Enable dependency tracking for your code.

    When your code imports packages contained in other modules, you manage those dependencies through your code's own module. That module is defined by a go.mod file that tracks the modules that provide those packages. That go.mod file stays with your code, including in your source code repository.

    To enable dependency tracking for your code by creating a go.mod file, run the go mod init command, giving it the name of the module your code will be in. The name is the module's module path.

    In actual development, the module path will typically be the repository location where your source code will be kept. For example, the module path might be github.com/mymodule. If you plan to publish your module for others to use, the module path must be a location from which Go tools can download your module. For more about naming a module with a module path, see Managing dependencies.

    For the purposes of this tutorial, just use example/hello.

    $ go mod init example/hello
    go: creating new go.mod: module example/hello
    
  4. In your text editor, create a file hello.go in which to write your code.

  5. Paste the following code into your hello.go file and save the file.

    package main
    
    import "fmt"
    
    func main() {
        fmt.Println("Hello, World!")
    }
    

    This is your Go code. In this code, you:

    • Declare a main package (a package is a way to group functions, and it's made up of all the files in the same directory).
    • Import the popular fmt package, which contains functions for formatting text, including printing to the console. This package is one of the standard library packages you got when you installed Go.
    • Implement a main function to print a message to the console. A main function executes by default when you run the main package.
  6. Run your code to see the greeting.

    $ go run .
    Hello, World!
    

    The go run command is one of many go commands you'll use to get things done with Go. Use the following command to get a list of the others:

    $ go help
    

Call code in an external package

When you need your code to do something that might have been implemented by someone else, you can look for a package that has functions you can use in your code.

  1. Make your printed message a little more interesting with a function from an external module.

    1. Visit pkg.go.dev and search for a "quote" package.
    2. In the search results, locate and click on the v1 of the rsc.io/quote package (it should be listed with the "Other major versions" of rsc.io/quote/v4).
    3. In the Documentation section, under Index, note the list of functions you can call from your code. You'll use the Go function.
    4. At the top of this page, note that package quote is included in the rsc.io/quote module.

    You can use the pkg.go.dev site to find published modules whose packages have functions you can use in your own code. Packages are published in modules -- like rsc.io/quote -- where others can use them. Modules are improved with new versions over time, and you can upgrade your code to use the improved versions.

  2. In your Go code, import the rsc.io/quote package and add a call to its Go function.

    After adding the highlighted lines, your code should include the following:

    package main
    
    import "fmt"
    
    import "rsc.io/quote"
    
    func main() {
        fmt.Println(quote.Go())
    }
    
  3. Add new module requirements and sums.

    Go will add the quote module as a requirement, as well as a go.sum file for use in authenticating the module. For more, see Authenticating modules in the Go Modules Reference.

    $ go mod tidy
    go: finding module for package rsc.io/quote
    go: found rsc.io/quote in rsc.io/quote v1.5.2
    
  4. Run your code to see the message generated by the function you're calling.

    $ go run .
    Don't communicate by sharing memory, share memory by communicating.
    

    Notice that your code calls the Go function, printing a clever message about communication.

    When you ran go mod tidy, it located and downloaded the rsc.io/quote module that contains the package you imported. By default, it downloaded the latest version -- v1.5.2.

Write more code

With this quick introduction, you got Go installed and learned some of the basics. To write some more code with another tutorial, take a look at Create a Go module.

1. 全文专业翻译(英译汉)

教程:Go 语言入门

目录

  • 前置要求
  • 安装 Go
  • 编写一些代码
  • 调用外部包中的代码
  • 编写更多代码

在本教程中,您将获得 Go 编程的简要介绍。在此过程中,您将完成以下任务:

  • 安装 Go(如果尚未安装);
  • 编写简单的 “Hello, World” 代码;
  • 使用 go 命令运行您的代码;
  • 使用 Go 包发现工具查找可在您自己代码中使用的包;
  • 调用外部模块中的函数。

注意:其他教程请参见 Tutorials


前置要求
具备一定的编程经验。此处的代码非常简单,但了解函数的基本概念会有所帮助。
一个用于编辑代码的工具。任何文本编辑器均可胜任。大多数编辑器对 Go 有良好支持,最流行的包括 VSCode(免费)、GoLand(付费)和 Vim(免费)。
一个命令行终端。Go 在 Linux 和 macOS 的任意终端下运行良好,在 Windows 上则可使用 PowerShell 或 cmd。


安装 Go
直接按照“下载与安装”步骤操作即可。


编写一些代码
从 “Hello, World” 开始。

  1. 打开命令提示符,并切换到您的主目录。

    • 在 Linux 或 Mac 上:

      cd
      
    • 在 Windows 上:

      cd %HOMEPATH%
      
  2. 为您的首个 Go 源代码创建一个 hello 目录。例如,使用以下命令:

    mkdir hello
    cd hello
    
  3. 为您的代码启用依赖项追踪。
    当您的代码导入其他模块中的包时,您需通过自身代码所属的模块来管理这些依赖。该模块由一个 go.mod 文件定义,用于记录提供这些包的模块信息。此 go.mod 文件将随您的代码一同保存(包括纳入源代码仓库)。

    要通过创建 go.mod 文件启用依赖追踪,请运行 go mod init 命令,并传入您的代码所属模块的名称(即模块路径)。

    在实际开发中,模块路径通常对应您源代码的托管位置(如 github.com/mymodule)。若您计划公开发布模块供他人使用,则模块路径必须是 Go 工具可从中下载该模块的位置。有关模块路径命名的更多说明,请参阅《依赖管理》文档。

    本教程中,仅需使用 example/hello 即可:

    $ go mod init example/hello
    go: creating new go.mod: module example/hello
    
  4. 在文本编辑器中创建文件 hello.go,用于编写代码。

  5. 将以下代码粘贴到 hello.go 并保存:

    package main
    
    import "fmt"
    
    func main() {
        fmt.Println("Hello, World!")
    }
    

    这段 Go 代码包含以下内容:

    • 声明一个 main 包(包用于组织函数,由同一目录下的所有文件构成);
    • 导入广为人知的 fmt 包(该包提供文本格式化功能,包括向控制台输出,属于安装 Go 时自带的标准库);
    • 实现 main 函数,用于向控制台打印消息(运行 main 包时,main 函数会默认执行)。
  6. 运行代码以查看问候语:

    $ go run .
    Hello, World!
    

    go run 是众多 go 命令之一,用于完成各类 Go 开发任务。运行以下命令可查看其他可用命令:

    $ go help
    

调用外部包中的代码
当您的代码需要实现某项功能,而该功能可能已被他人实现时,您可以查找一个包含可用函数的包。

  1. 使用外部模块中的函数,让输出消息更有趣。

    • 访问 pkg.go.dev,搜索 “quote” 包;
    • 在搜索结果中,找到并点击 rsc.io/quote 包的 v1 版本(应列在 “Other major versions” 下,与 rsc.io/quote/v4 并列);
    • 在页面“Documentation”部分的“Index”下,查看可调用的函数列表,您将使用 Go 函数;
    • 注意页面顶部显示:quote 包属于 rsc.io/quote 模块。

    您可通过 pkg.go.dev 查找已发布的模块,其包中的函数可被您的代码复用。包以模块形式发布(如 rsc.io/quote),供他人使用。模块会随时间推出新版本,您也可升级代码以使用改进后的版本。

  2. 在 Go 代码中导入 rsc.io/quote 包,并添加对其 Go 函数的调用。
    添加高亮行后,您的代码应如下所示:

    package main
    
    import "fmt"
    import "rsc.io/quote"
    
    func main() {
        fmt.Println(quote.Go())
    }
    
  3. 添加新的模块依赖和校验和。
    Go 会自动将 quote 模块添加为依赖项,并生成 go.sum 文件用于模块认证。详情请参阅《Go 模块参考》中的“模块认证”章节。

    $ go mod tidy
    go: finding module for package rsc.io/quote
    go: found rsc.io/quote in rsc.io/quote v1.5.2
    
  4. 运行代码,查看所调用函数生成的消息:

    $ go run .
    Don't communicate by sharing memory, share memory by communicating.
    

    注意:您的代码调用了 Go 函数,输出了一句关于通信的巧妙格言。
    执行 go mod tidy 时,Go 自动定位并下载了包含所导入包的 rsc.io/quote 模块(默认下载最新版本 v1.5.2)。


编写更多代码
通过这一快速入门,您已成功安装 Go 并掌握了基础知识。若想继续编写更多代码,请参阅另一篇教程:《创建 Go 模块》。


2. 词汇表梳理(共 18个)

  1. Prerequisites
    词性:名词(复数)
    音标:/ˌpriːˈrekwɪzɪts/(“普-瑞-瑞-克-维-兹-茨”)
    音节划分:Pre·req·ui·sites
    释义:前置要求。指开始某项任务前必须满足的条件或具备的知识/工具。
    扩展信息:单数 prerequisite;形容词 prerequisite(必备的)。
    注意事项:技术文档标准章节标题;常缩写为 “Prereqs”。
    例句:The prerequisites for this course include basic programming knowledge.
    中文翻译:本课程的前置要求包括基础编程知识。
  2. Pretty
    词性:副词
    音标:/ˈprɪti/(“普-瑞-提”)
    音节划分:Pret·ty
    释义:相当,颇为。用于口语化强调程度(此处修饰 simple,意为“相当简单”)。
    扩展信息:形容词 pretty(漂亮的);此处为副词用法。近义词:quite, fairly。
    注意事项:非字面“漂亮”义;技术文档中常见于降低语气强度。
    例句:The setup process is pretty straightforward.
    中文翻译:设置过程相当简单。
  3. Locate
    词性:动词
    音标:/loʊˈkeɪt/(“楼-凯-特”)
    音节划分:Lo·cate
    释义:定位,找到。指在大量信息或文件系统中确定目标项的具体位置。
    扩展信息:名词 location;形容词 located。近义词:find, identify。
    注意事项:比 “find” 更正式,强调“精准定位”;常用于工具输出(如 “go: found...”)。
    例句:The tool will locate the required dependency in the module cache.
    中文翻译:该工具将在模块缓存中定位所需依赖。
  4. Clever
    词性:形容词
    音标:/ˈklevər/(“克-雷-沃”)
    音节划分:Clev·er
    释义:巧妙的。指设计精巧、富有智慧或令人会心一笑的表达(如 quote 中的格言)。
    扩展信息:副词 cleverly;名词 cleverness。近义词:ingenious, witty。
    注意事项:此处形容引语的机智,非“聪明的人”。
    例句:The error message includes a clever reference to concurrency.
    中文翻译:错误信息包含一处对并发的巧妙引用。
  5. Experience
    词性:名词
    音标:/ɪkˈspɪriəns/(“伊-克-斯-皮-瑞-恩-斯”)
    音节划分:Ex·pe·ri·ence
    释义:经验。指通过实践、观察或参与而获得的知识、技能或理解,尤指在编程或软件开发领域的实际操作积累。
    扩展信息:动词 experience(经历);形容词 experienced(有经验的)、inexperienced(缺乏经验的)。词根 ex-(出)+ periri(尝试),本义“通过尝试获得”。近义词:knowledge, expertise, background。
    注意事项:此处为不可数名词,强调“整体性经验”而非单次事件;技术文档中常用于描述用户前置条件(如 “some programming experience”)。
    例句:You don’t need years of experience to start learning Go.
    中文翻译:您无需多年经验即可开始学习 Go。
  6. Directory
    词性:名词
    音标:/dəˈrektəri/(“德-瑞-克-特-瑞”)
    音节划分:Di·rec·to·ry
    释义:目录。指文件系统中用于组织和存储文件及其他子目录的容器结构,在命令行操作和项目布局中具有核心作用。
    扩展信息:复数 directories;形容词 directory(罕见,多作名词);近义词 folder(通用术语),但在 Unix/Linux/macOS 技术语境中优先使用 “directory”。词源来自拉丁语 directus(直的、引导的),原指“指引信息的清单”,后引申为文件系统结构。
    注意事项:在 Go 项目中,一个目录通常对应一个包(package);go mod initgo run 等命令均以当前工作目录为上下文;不可与 “file” 混淆。
    例句:Each Go package resides in its own directory.
    中文翻译:每个 Go 包都位于其独立的目录中。
  7. Track
    词性:动词
    音标:/træk/(“特-拉-克”)
    音节划分:Track
    释义:追踪,记录。在软件开发中特指对依赖项、版本、变更或状态进行持续监控和管理,确保系统可复现且一致。
    扩展信息:过去式 tracked;名词 tracker(跟踪器)、tracking(追踪);形容词 trackable。词源古法语 trac(路径),与 “trail” 同源。近义词:monitor, record, manage。
    注意事项:在 Go 模块系统中,“track dependencies” 指通过 go.mod 文件记录所依赖模块的路径和版本;强调自动化、声明式管理,而非手动干预。
    例句:The go.mod file tracks all external modules your code depends on.
    中文翻译:go.mod 文件会追踪您代码所依赖的所有外部模块。
  8. Actual
    词性:形容词
    音标:/ˈæktʃuəl/(“艾-克-丘-欧”)
    音节划分:Ac·tu·al
    释义:实际的。指在真实开发场景中发生或采用的做法,而非示例、假设或教学简化情形。
    扩展信息:副词 actually;名词 actuality(现实性)。词源拉丁语 actualis(行动的),来自 actus(行动)。近义词:real, genuine, practical;反义词:theoretical, hypothetical。
    注意事项:常用于区分教程中的临时用法与生产环境规范(如 “In actual development…”);强调上下文的真实性,避免读者将示例路径误用于正式项目。
    例句:In actual development, you would use your repository URL as the module path.
    中文翻译:在实际开发中,您会使用自己的仓库 URL 作为模块路径。
  9. Purpose
    词性:名词
    音标:/ˈpɜːrpəs/(“珀-珀-斯”)
    音节划分:Pur·pose
    释义:目的,用途。指某项操作、设计或约定所要达成的具体目标或意图,常用于限定上下文范围(如教程中的简化假设)。
    扩展信息:形容词 purposeful(有目的的)、purposeless(无目的的);动词 purport(声称,注意拼写不同)。词源拉丁语 propositum(被提出的计划)。近义词:goal, intention, aim。
    注意事项:在技术文档中常以复数形式 “purposes” 出现,构成固定短语 “for the purposes of...”(就……而言),用于声明当前场景的特殊性或临时性。
    例句:For the purposes of this tutorial, we use a placeholder module path.
    中文翻译:就本教程而言,我们使用一个占位符模块路径。
  10. Section
    词性:名词
    音标:/ˈsekʃn/(“赛-克-申”)
    音节划分:Sec·tion
    释义:章节,部分。指文档、网页或技术资料中具有明确主题和标题的结构化内容单元。
    扩展信息:动词 section(分割,较少用);形容词 sectional(分段的)。词源拉丁语 sectio(切割),来自 secare(切)。近义词:part, chapter, segment。
    注意事项:在技术文档(如 Go 官方教程)中,“section” 用于组织逻辑流程(如 “Prerequisites”、“Install Go” 等);常与 “in this section” 搭配引导读者聚焦当前内容。
    例句:The Documentation section on pkg.go.dev lists all exported functions.
    中文翻译:pkg.go.dev 上的“文档”章节列出了所有导出的函数。
  11. Improve
    词性:动词
    音标:/ɪmˈpruːv/(“伊-姆-普-鲁-夫”)
    音节划分:Im·prove
    释义:改进,优化。指通过修正缺陷、增强功能或提升性能,使软件模块、代码或系统变得更好。
    扩展信息:过去式 improved;名词 improvement;形容词 improvable。词根 in-(加强)+ probus(好的),原义“使更好”。近义词:enhance, refine, upgrade。
    注意事项:在 Go 模块生态中,“modules are improved with new versions over time” 强调版本迭代带来的质量提升;常与 “over time”、“continuously” 搭配,体现渐进式演进理念。
    例句:The library was improved in v2.0 with better error handling.
    中文翻译:该库在 2.0 版本中通过更完善的错误处理得到了改进。
  12. Quote
    词性:名词
    音标:/kwoʊt/(“克-沃-特”)
    音节划分:Quote
    释义:引语,格言。在 Go 教程上下文中,特指由 rsc.io/quote 包提供的、用于演示外部模块调用的预定义字符串常量(如 “Don’t communicate by sharing memory...”)。
    扩展信息:动词 quote(引用);过去分词 quoted;复数 quotes。词源拉丁语 quotare(按章节划分),后演变为“摘录文字”。近义词:saying, excerpt, citation。
    注意事项:此处为专有名词化用法——quote 既是包名(package quote),也指其输出的智慧短句;在 Go 生态中已成为经典教学示例,不可直译为“报价”或“引号”。
    例句:The quote package returns famous programming aphorisms when you call its functions.
    中文翻译:调用 quote 包的函数时,它会返回著名的编程格言。
  13. Highlighted
    词性:形容词(过去分词作形容词)
    音标:/ˈhaɪˌlaɪtɪd/(“海-莱-特-伊-德”)
    音节划分:High·light·ed
    释义:高亮显示的。指在代码示例或文档中通过颜色、背景或字体加粗等方式特别标出的内容,用于引导读者关注新增、修改或关键部分。
    扩展信息:动词 highlight(突出,强调);名词 highlight(亮点)。词根 high(高)+ light(光),字面意为“打上强光”。近义词:emphasized, marked, underscored。
    注意事项:在技术教程中,“highlighted lines” 是标准表述,表示需用户注意的变更点;常与 “add the highlighted lines” 搭配,指示具体编辑操作。
    例句:After adding the highlighted lines, your code will import the quote package.
    中文翻译:添加高亮显示的代码行后,您的代码将导入 quote 包。
  14. Requirement
    词性:名词
    音标:/rɪˈkwaɪərmənt/(“瑞-克-怀-尔-门-特”)
    音节划分:Re·quire·ment
    释义:依赖项,需求。在 Go 模块系统中,特指项目所依赖的外部模块及其版本信息,由 go.mod 文件声明并由 go mod tidy 自动管理。
    扩展信息:复数 requirements;动词 require(需要);形容词 required(必需的)。词根 re-(加强)+ quaerere(寻求),本义“被要求之物”。近义词:dependency, prerequisite, necessity。
    注意事项:在 Go 语境中,“module requirement” 是标准术语,强调“声明式依赖”;与泛用词 “need” 不同,具有精确的技术含义,通常可被工具自动解析和满足。
    例句:Running go mod tidy adds the quote module as a requirement in go.mod.
    中文翻译:运行 go mod tidy 会将 quote 模块作为依赖项添加到 go.mod 中。
  15. Sum
    词性:名词
    音标:/sʌm/(“萨-姆”)
    音节划分:Sum
    释义:校验和。在 Go 模块系统中,特指 go.sum 文件中记录的加密哈希值,用于验证所下载模块内容的完整性和真实性,防止篡改或意外损坏。
    扩展信息:动词 sum(求和,较少用于此语境);复数 sums。此处为 “checksum” 的简写用法,在 Go 工具链中固定称为 “sum”。近义词:hash, digest, checksum。
    注意事项:不可理解为“总和”或“金额”;在 Go 中,“sum” 专指模块认证所需的密码学摘要;go.sumgo.mod 配合使用,是 Go 模块安全机制的核心组成部分。
    例句:The go.sum file contains cryptographic sums that authenticate each dependency.
    中文翻译:go.sum 文件包含用于认证每个依赖项的加密校验和。
  16. Authenticating
    词性:动词(现在分词/动名词)
    音标:/ɔːˈθentɪkeɪtɪŋ/(“奥-森-提-凯-廷”)
    音节划分:Au·then·ti·ca·ting
    释义:认证。在 Go 模块系统中,指通过比对 go.sum 文件中存储的加密校验和,验证所下载模块内容的真实性与完整性,确保其未被篡改或损坏。
    扩展信息:动词原形 authenticate;名词 authentication;形容词 authentic(真实的)。词源希腊语 authentikos(“亲自完成的”),由 authentes(行动者)演变而来。近义词:verifying, validating, securing。
    注意事项:此处为技术术语,强调密码学意义上的身份与内容验证,而非一般意义上的“登录认证”;Go 工具链在下载模块时自动执行此过程,开发者通常无需干预,但需理解其安全意义。
    例句:Go uses the go.sum file for authenticating modules during builds.
    中文翻译:Go 在构建过程中使用 go.sum 文件对模块进行认证。
  17. Typically
    词性:副词
    音标:/ˈtɪpɪkli/(“提-皮-克-利”)
    音节划分:Typ·i·cal·ly
    释义:通常,一般而言。用于描述在常规开发实践或标准场景下普遍采用的做法或默认行为,强调惯例而非绝对规则。
    扩展信息:形容词 typical;名词 typicality。词源希腊语 typos(模型、印记),经拉丁语 typicus 演变而来。近义词:usually, generally, commonly。
    注意事项:在技术文档中常用于区分“推荐实践”与“强制要求”;暗示存在例外情况(如本地开发可使用非典型路径)。
    例句:The module path will typically be the repository URL where your code is hosted.
    中文翻译:模块路径通常就是托管您代码的仓库 URL。
  18. Support
    词性:名词
    音标:/səˈpɔːrt/(“瑟-珀-特”)
    音节划分:Sup·port
    释义:支持。在开发工具语境中,指编辑器、IDE 或系统对特定语言(如 Go)提供的功能适配,包括语法高亮、自动补全、调试、格式化和错误检查等。
    扩展信息:动词 support;形容词 supportive;过去分词 supported 常作定语(如 “Go-supported editor”)。词源拉丁语 supportare(从下托起),由 sub-(在下)+ portare(携带)组成。近义词:compatibility, integration, assistance。
    注意事项:此处为不可数名词,强调“功能层面的适配能力”,而非“人力帮助”;技术文档中 “has good support for Go” 是标准表达,用于评估工具链成熟度。
    例句:Most modern text editors have excellent support for Go development.
    中文翻译:大多数现代文本编辑器对 Go 开发都有出色的支持。

短语表(共 10 个)

  1. Get started with Go
    释义:开始使用 Go。用于引导用户进入学习或开发流程的行动号召式短语。
    注意事项:动词短语,“get started” 表示“着手进行”,常用于教程、文档首页。
    例句:New developers can get started with Go in minutes.
    中文翻译:新开发者几分钟内即可开始使用 Go。
  2. Along the way
    释义:在此过程中。指在完成主要任务的同时自然发生的附加学习或操作。
    注意事项:副词性短语,用于平滑衔接多个子目标,强调非孤立步骤。
    例句:You’ll learn about modules along the way.
    中文翻译:在此过程中,您将了解模块相关知识。
  3. For example
    释义:例如。引出具体、典型的实例以说明前文所述内容。
    注意事项:后接逗号;所举例应具代表性;技术文档高频短语。
    例句:For example, use the following commands: mkdir hello; cd hello.
    中文翻译:例如,使用以下命令:mkdir hello;cd hello。
  4. In actual development
    释义:在实际开发中。用于区分教学简化场景与真实工程实践。
    注意事项:强调上下文真实性;常与 “for the purposes of this tutorial” 对比使用。
    例句:In actual development, module paths reflect repository URLs.
    中文翻译:在实际开发中,模块路径反映仓库 URL。
  5. For the purposes of this tutorial
    释义:就本教程而言。限定当前上下文中的临时约定或简化假设。
    注意事项:正式书面语;表明后续做法仅适用于教学,非生产规范。
    例句:For the purposes of this tutorial, just use example/hello.
    中文翻译:就本教程而言,仅需使用 example/hello。
  6. Call functions of an external module
    释义:调用外部模块中的函数。描述复用第三方代码的核心操作。
    注意事项:“call...of...” 结构体现归属关系;“external module” 是 Go 模块系统标准术语。
    例句:Your code can call functions of an external module via import.
    中文翻译:您的代码可通过导入调用外部模块中的函数。
  7. as well as
    释义:以及,还有。连接两个并列但主次分明的名词成分,强调前者为主、后者为补充。
    注意事项:不是简单等同于 “and”;语法上不改变主语核心;技术文档中用于列举工具自动完成的多项操作。
    例句:Go adds the module as a requirement, as well as a go.sum file.
    中文翻译:Go 将该模块添加为依赖项,以及一个 go.sum 文件。
  8. For more
    释义:欲了解更多。技术文档中引导读者查阅扩展资料的标准省略短语。
    注意事项:固定后接逗号 + “see + 引用”;高度程式化,属于元语用标记。
    例句:For more, see Authenticating modules in the Go Modules Reference.
    中文翻译:欲了解更多,请参阅《Go 模块参考》中的“模块认证”章节。
  9. Don't communicate by sharing memory, share memory by communicating.
    释义:“不要通过共享内存来通信,而应通过通信来共享内存。”
    注意事项:Go 并发哲学核心格言;出自 Rob Pike;体现 CSP(通信顺序进程)思想;常被引用作文化符号。
    例句:This quote encapsulates Go’s approach to safe concurrency.
    中文翻译:这句格言概括了 Go 实现安全并发的方式。
  10. Take a look at
    释义:查看,浏览。用于友好地引导读者参考其他资源或后续教程。
    注意事项:比 “see” 更口语化且具邀请性;常见于教程结尾的延伸建议。
    例句:To write more code, take a look at Create a Go module.
    中文翻译:若要编写更多代码,请查看《创建 Go 模块》教程。
posted @ 2026-01-14 21:49  红尘过客2022  阅读(16)  评论(0)    收藏  举报