From 07d49fbdd33519f670922ef432dbbf72c1e8d82d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E6=B6=9B?= Date: Fri, 8 Sep 2023 13:57:21 +0800 Subject: [PATCH] =?UTF-8?q?post:=E5=8C=85=E4=B8=80=E8=8A=82=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0import=E7=9A=84=E8=AF=AD=E8=A8=80=E8=A7=84=E8=8C=83?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/project-structure/package.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/project-structure/package.md b/src/project-structure/package.md index 8d8e8f2..61957eb 100644 --- a/src/project-structure/package.md +++ b/src/project-structure/package.md @@ -48,6 +48,14 @@ import ( 在Go语言中,这种使用括号来精简批量语句是一种使用非常普遍的语法范式,在后面会介绍到还有哪些关键字可以使用这种语法范式。 ``` +在 Go 语言规范定义中`import`关键字的定义是下面这样的。 + +``` +ImportDecl = "import" ( ImportSpec | "(" { ImportSpec } ")") . +ImportSpec = [ "." | PackageName ] ImportPath . +ImportPath = string_lit . +``` + ## 引入的包在代码中的使用 一个包在使用`import`关键字引入之后就可以在当前代码文件中使用了,但是使用的时候需要记住的是,引入的内容需要通过包名来访问。