-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
99 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
order: 1 | ||
title: 'Keywords' | ||
--- | ||
|
||
## Keywords | ||
|
||
Golang has 25 reserved keywords that cannot be used as program identifiers. | ||
|
||
| Type | Keywords | Introduction | | ||
| ------------------ | ------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------- | | ||
| Declaration | `const` `func` `import` `package` `type` `var` | These keywords are used to declare various elements in the code. | | ||
| Compound Types | `chan` `interface` `map` `struct` | These keywords are used to declare some special compound types. | | ||
| Flow Control | `break` `case` `continue` `default` `else` `fallthrough` `for` `goto` `if` `range` `return` `select` `switch` | These keywords are used to control the flow of program execution. | | ||
| Function Modifiers | `defer` `go` | Used to modify special functions. | | ||
|
||
## Declaration Type Keywords | ||
|
||
### **const** | ||
|
||
`const` is used to declare constants, which once declared cannot be changed, and must specify an initial value when declaring a constant. | ||
|
||
<details> | ||
<summary>Example</summary> | ||
|
||
```go | ||
const identifier T = value // T is the data type, which can be omitted, and the compiler will infer it. | ||
const identifier1, identifier2 = value1, value2 // Declare multiple, such as const a, b, c = "hello", 100, true | ||
|
||
const ( | ||
FeMale = 0 | ||
Male = 1 | ||
) // Enumeration | ||
|
||
const ( | ||
a = iota | ||
b | ||
c | ||
) // iota | ||
``` | ||
</details> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
order: 1 | ||
title: '保留关键字' | ||
--- | ||
|
||
## 保留关键字 | ||
|
||
golang 有 25 个保留的关键字,这些关键字不能用作程序标识符。 | ||
|
||
| 类型 | 关键字 | 介绍 | | ||
| -------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------ | | ||
| 声明 | `const` `func` `import` `package` `type` `var` | 这些关键字用于声明代码中的各种元素 | | ||
| 复合类型 | `chan` `interface` `map` `struct` | 这些关键字用于声明一些特殊的复合类型 | | ||
| 流程控制 | `break` `case` `continue` `default` `else` `fallthrough` `for` `goto` `if` `range` `return` `select` `switch` | 这些关键字用于控制程序运行流程 | | ||
| 功能修饰 | `defer` `go` | 用于修饰特殊的 function | | ||
|
||
|
||
## 声明类型关键字 | ||
|
||
### **const** | ||
|
||
const 用于声明常量,常量一经声明就不能被更改,声明常量必须指定初始值。 | ||
|
||
<details> | ||
<summary>例子</summary> | ||
|
||
```go | ||
const identifier T = value // T 为数据类型,可以省略,编译器会自己推断。 | ||
const identifier1, identifier2 = value1, value2 // 声明多个,如 const a, b, c = "hello", 100, true | ||
|
||
const ( | ||
FeMale = 0 | ||
Male = 1 | ||
) // 枚举 | ||
|
||
const ( | ||
a = iota | ||
b | ||
c | ||
) // iota | ||
``` | ||
</details> |