Skip to content

Commit

Permalink
refactor: optimize locale
Browse files Browse the repository at this point in the history
  • Loading branch information
suyuan32 committed Jan 16, 2024
1 parent 8455ca3 commit 029e3c5
Show file tree
Hide file tree
Showing 17 changed files with 165 additions and 151 deletions.
4 changes: 2 additions & 2 deletions src/.vuepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ export default defineUserConfig({
base: "/",

locales: {
"/": {
"/en/": {
lang: "en-US",
title: "Go Guide",
description: "Golang guide for interview",
},
"/zh/": {
"/": {
lang: "zh-CN",
title: "Go 面试宝典",
description: "Golang 面试宝典,面试题和基础",
Expand Down
2 changes: 1 addition & 1 deletion src/.vuepress/navbar/en.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { navbar } from "vuepress-theme-hope";

export const enNavbar = navbar([
"/",
"/en/",
{
text: "Guide",
icon: "icon-park-outline:mountain",
Expand Down
2 changes: 1 addition & 1 deletion src/.vuepress/navbar/zh.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { navbar } from "vuepress-theme-hope";

export const zhNavbar = navbar([
"/zh/",
"/",
{
text: "指南",
icon: "icon-park-outline:mountain",
Expand Down
21 changes: 14 additions & 7 deletions src/.vuepress/sidebar/en.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { sidebar } from "vuepress-theme-hope";

export const enSidebar = sidebar({
"/": [
"/en/": [
{
text: "Guide",
icon: "mingcute:book-line",
Expand All @@ -19,13 +19,20 @@ export const enSidebar = sidebar({
children: "structure",
}
]
},
},
{
text: "Golang",
icon: "grommet-icons:golang",
prefix: "basic/",
children: "structure"
},
text: "Interview Question",
icon: "solar:book-outline",
prefix: "interview/",
children: [
{
text: "Golang",
icon: "grommet-icons:golang",
prefix: "golang/basic/",
children: "structure"
}
]
},
],
},
],
Expand Down
19 changes: 13 additions & 6 deletions src/.vuepress/sidebar/zh.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { sidebar } from "vuepress-theme-hope";

export const zhSidebar = sidebar({
"/zh/": [
"/": [
{
text: "面试宝典",
icon: "mingcute:book-line",
Expand All @@ -21,11 +21,18 @@ export const zhSidebar = sidebar({
]
},
{
text: "Golang",
icon: "grommet-icons:golang",
prefix: "basic/",
children: "structure"
}
text: "面试题",
icon: "solar:book-outline",
prefix: "interview/",
children: [
{
text: "Golang",
icon: "grommet-icons:golang",
prefix: "golang/basic/",
children: "structure"
}
]
},
],
},
],
Expand Down
4 changes: 2 additions & 2 deletions src/.vuepress/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default hopeTheme({
breadcrumb: false,

locales: {
"/": {
"/en/": {
// navbar
navbar: enNavbar,

Expand All @@ -40,7 +40,7 @@ export default hopeTheme({
/**
* Chinese locale config
*/
"/zh/": {
"/": {
// navbar
navbar: zhNavbar,

Expand Down
10 changes: 5 additions & 5 deletions src/README.md
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
15 changes: 15 additions & 0 deletions src/en/README.md
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
8 changes: 8 additions & 0 deletions src/en/guide/README.md
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.
41 changes: 41 additions & 0 deletions src/en/guide/concepts/golang/1-basic.md
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.
6 changes: 3 additions & 3 deletions src/guide/README.md
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 面试常见问题。
77 changes: 60 additions & 17 deletions src/guide/concepts/golang/1-basic.md
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.
15 changes: 0 additions & 15 deletions src/zh/README.md

This file was deleted.

8 changes: 0 additions & 8 deletions src/zh/guide/README.md

This file was deleted.

Loading

0 comments on commit 029e3c5

Please sign in to comment.