-
Notifications
You must be signed in to change notification settings - Fork 8
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
17 changed files
with
165 additions
and
151 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 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 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 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 |
---|---|---|
@@ -1,15 +1,15 @@ | ||
--- | ||
home: true | ||
icon: home | ||
title: Go Guide | ||
title: Go 面试宝典 | ||
heroImage: /logo.svg | ||
heroText: Go Guide | ||
tagline: Golang interview guide | ||
heroText: Go 面试宝典 | ||
tagline: Golang 面试基础,常见面试题。 | ||
actions: | ||
- text: Guide | ||
- text: 指南 | ||
link: ./guide/ | ||
type: primary | ||
|
||
|
||
copyright: false | ||
footer: Apache2.0 license, Copyright © 2024-present Go Guide | ||
footer: Apache2.0 协议, 版权所有 © 2024-present Go Guide |
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,15 @@ | ||
--- | ||
home: true | ||
icon: home | ||
title: Go Guide | ||
heroImage: /logo.svg | ||
heroText: Go Guide | ||
tagline: Golang interview guide | ||
actions: | ||
- text: Guide | ||
link: ./guide/ | ||
type: primary | ||
|
||
|
||
copyright: false | ||
footer: Apache2.0 license, Copyright © 2024-present Go Guide |
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,8 @@ | ||
--- | ||
title: Guide | ||
icon: mingcute:book-line | ||
--- | ||
|
||
## introduce | ||
|
||
This website mainly provides Golang interview frequently asked questions and basic knowledge. |
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> |
File renamed without changes.
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
--- | ||
title: Guide | ||
title: 指南 | ||
icon: mingcute:book-line | ||
--- | ||
|
||
## introduce | ||
## 介绍 | ||
|
||
This website mainly provides Golang interview frequently asked questions and basic knowledge. | ||
本栏目主要提供 Golang 面试常见问题。 |
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 |
---|---|---|
@@ -1,41 +1,84 @@ | ||
--- | ||
order: 1 | ||
title: 'Keywords' | ||
title: '保留关键字' | ||
--- | ||
|
||
## Keywords | ||
## 1. 保留关键字 | ||
|
||
Golang has 25 reserved keywords that cannot be used as program identifiers. | ||
golang 有 25 个保留的关键字,这些关键字不能用作程序标识符。 | ||
|
||
| 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. | | ||
| 类型 | 关键字 | 介绍 | | ||
| -------- | ------------------------------------------------------------------------------------------------------------- | ------------------------------------ | | ||
| 声明 | `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 | | ||
|
||
## Declaration Type Keywords | ||
|
||
### **const** | ||
## 2. 声明类型关键字 | ||
|
||
`const` is used to declare constants, which once declared cannot be changed, and must specify an initial value when declaring a constant. | ||
### 2.1. **const** | ||
|
||
`const` 用于声明常量,常量一经声明就不能被更改,声明常量必须指定初始值。 | ||
|
||
<details> | ||
<summary>Example</summary> | ||
<summary>例子</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 identifier T = value // T 为数据类型,可以省略,编译器会自己推断。 | ||
const identifier1, identifier2 = value1, value2 // 声明多个,如 const a, b, c = "hello", 100, true | ||
|
||
const ( | ||
FeMale = 0 | ||
Male = 1 | ||
) // Enumeration | ||
) // 枚举 | ||
|
||
const ( | ||
a = iota | ||
b | ||
c | ||
) // iota | ||
``` | ||
</details> | ||
</details> | ||
|
||
#### 2.1.1. **func** | ||
|
||
`func` 用于声明函数,支持多个返回值,不支持默认参数。 | ||
|
||
|
||
<details> | ||
<summary>例子</summary> | ||
|
||
```go | ||
// p 为参数, T 为类型 | ||
func Test(p T) {} | ||
func Test(p T) (T1, T2) {} | ||
func Test (p T, p1, T1, list ...T3) (T4, T5) {} // 不定参数 | ||
``` | ||
|
||
</details> | ||
|
||
#### 2.1.2. **import** | ||
|
||
`import` 用于导入包,使用其公开的标识符。 | ||
|
||
`import` 支持单行和多行导入。 | ||
|
||
```go | ||
import "flag" // 单个导入 | ||
|
||
import ( | ||
"flag" | ||
"fmt" | ||
) // 多个导入 | ||
``` | ||
|
||
我们还可以使用 `.`, `_` 和别名修饰导入的包。 | ||
|
||
| 导入命令 | 使用方法 | 解析 | | ||
| ---------------------- | -------- | --------------------------------------------- | | ||
| `import "lib/math"` | math.Sin | 普通导入需要使用包名 | | ||
| `import m "lib/math"` | m.Sin | 可以在导入时设置别名 | | ||
| `import . "lib/math" ` | Sin | 使用 `.` 导入本地可以直接使用函数,不需要包名 | | ||
|
||
我们还可以使用 `_` 来修饰导入的包,这样只会执行导入包的初始化函数 `init()` |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.