File tree Expand file tree Collapse file tree 6 files changed +170
-0
lines changed
i18n/zh-CN/docusaurus-plugin-content-docs
current/user_docs/support
version-0.9/user_docs/support
versioned_docs/version-0.9/user_docs/support Expand file tree Collapse file tree 6 files changed +170
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ Please ensure that the following dependencies are in your PATH:
2828- ` gcc ` for Linux
2929- ` cl.exe ` for Windows, which can be obtained by installing ` MSVC ` including ` MSVCP140.dll ` and ` VCRUNTIME140.dll ` .
3030
31+ ## Error: invalid character 'c' looking for beginning of value
32+
33+ Please ensure that the following dependencies are in your PATH:
34+
35+ - ` clang ` for MacOS
36+ - ` gcc ` for Linux
37+ - ` cl.exe ` for Windows, which can be obtained by installing ` MSVC ` including ` MSVCP140.dll ` and ` VCRUNTIME140.dll ` .
38+
3139## Encountering exit status 0xc0000135 error on Windows platform
3240
3341Please ensure that ` .NET Framework ` and ` MSVC ` are installed on your Windows. If not installed, you can install them and try again.
Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ xattr -d com.apple.quarantine /path/to/kcl
2828- Linux: ` gcc `
2929- Windows: ` cl.exe ` (可以通过安装 ` MSVC ` 获得,主要包括 ` MSVCP140.dll ` 和 ` VCRUNTIME140.dll ` 等程序集)
3030
31+ ## 错误:invalid character 'c' looking for beginning of value
32+
33+ 请确保如下依赖在您的 PATH 中
34+
35+ - MacOS: ` clang `
36+ - Linux: ` gcc `
37+ - Windows: ` cl.exe ` (可以通过安装 ` MSVC ` 获得,主要包括 ` MSVCP140.dll ` 和 ` VCRUNTIME140.dll ` 等程序集)
38+
3139## 在 Windows 平台上遇到 exit status 0xc0000135 错误
3240
3341请确保您的 Windows 上安装了 ` .NET Framework ` 和 ` MSVC ` ,如没有安装,可以安装并重试。
Original file line number Diff line number Diff line change @@ -2556,3 +2556,72 @@ final_list:
25562556# # 61. KCL 代码片段 `version: "v1" = "v1"` 是什么意思?
25572557
25582558这里的第一个 `"v1"` 表示变量 `version` 的类型是字符串字面类型。第二个 `"v1"` 表示变量 `version` 的默认值是 "v1"。
2559+
2560+ # # 62. 如何定义一个 KCL Schema 校验给定 JSON/YAML 文件的内容?
2561+
2562+ 我们可以使用 kcl 的 vet 工具来校验给定 JSON 文件中的数据。例如,在下面的 data.json 文件中,我们使用以下的 KCL 文件(schema.k)来校验 age 参数。
2563+
2564+ data.json
2565+
2566+ ` ` ` json
2567+ [
2568+ {
2569+ "name": "Alice",
2570+ "age": 18
2571+ },
2572+ {
2573+ "name": "Bob",
2574+ "age": 10
2575+ }
2576+ ]
2577+ ` ` `
2578+
2579+ schema.k
2580+
2581+ ` ` ` kcl
2582+ schema Person:
2583+ name: str
2584+ age: int
2585+
2586+ check:
2587+ age >= 10
2588+ ` ` `
2589+
2590+ 校验 JSON 数据的命令
2591+
2592+ ` ` ` shell
2593+ kcl vet data.json schema.k
2594+ ` ` `
2595+
2596+ # # 63. 如何在给定 Schema 扩展数组属性的默认值?
2597+
2598+ 我们使用 += 运算符来扩展 Schema 数组属性的默认值。
2599+
2600+ ` ` ` python
2601+ schema MyApp:
2602+ args: [str] = ["default", "args"]
2603+
2604+ app = MyApp {
2605+ args += ["additional", "args"]
2606+ }
2607+ ` ` `
2608+
2609+ # # 64. 可以配置 kcl 在特定路径上生成 `.kclvm` 文件夹或者其他与 kcl 编译缓存相关的目录吗?
2610+
2611+ 可以通过变量 KCL_CACHE_PATH 来更改路径。
2612+
2613+ 在 macOS 和 Linux 上:
2614+
2615+ 可以通过向 ~/.bashrc、~/.zshrc 或类似的 shell rc 文件中添加 export 命令来设置 KCL_CACHE_PATH,或者如果您希望它只对当前会话生效,也可以直接在终端中运行它。
2616+
2617+ ` ` ` shell
2618+ export KCL_CACHE_PATH=/tmp # 或者更改为您想要的路径
2619+ ` ` `
2620+
2621+ 在 Windows 上
2622+
2623+ 可以通过命令提示符或 PowerShell 将 KCL_CACHE_PATH 设置为环境变量,以便影响所有 KCL 会话。 对于命令提示符,请使用 setx 命令来永久设置该值:
2624+
2625+ ` ` ` powershell
2626+ setx KCL_CACHE_PATH "C:\t emp" /M
2627+ ` ` `
Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ xattr -d com.apple.quarantine /path/to/kcl
2828- Linux: ` gcc `
2929- Windows: ` cl.exe ` (可以通过安装 ` MSVC ` 获得,主要包括 ` MSVCP140.dll ` 和 ` VCRUNTIME140.dll ` 等程序集)
3030
31+ ## 错误:invalid character 'c' looking for beginning of value
32+
33+ 请确保如下依赖在您的 PATH 中
34+
35+ - MacOS: ` clang `
36+ - Linux: ` gcc `
37+ - Windows: ` cl.exe ` (可以通过安装 ` MSVC ` 获得,主要包括 ` MSVCP140.dll ` 和 ` VCRUNTIME140.dll ` 等程序集)
38+
3139## 在 Windows 平台上遇到 exit status 0xc0000135 错误
3240
3341请确保您的 Windows 上安装了 ` .NET Framework ` 和 ` MSVC ` ,如没有安装,可以安装并重试。
Original file line number Diff line number Diff line change @@ -2556,3 +2556,72 @@ final_list:
25562556# # 61. KCL 代码片段 `version: "v1" = "v1"` 是什么意思?
25572557
25582558这里的第一个 `"v1"` 表示变量 `version` 的类型是字符串字面类型。第二个 `"v1"` 表示变量 `version` 的默认值是 "v1"。
2559+
2560+ # # 62. 如何定义一个 KCL Schema 校验给定 JSON/YAML 文件的内容?
2561+
2562+ 我们可以使用 kcl 的 vet 工具来校验给定 JSON 文件中的数据。例如,在下面的 data.json 文件中,我们使用以下的 KCL 文件(schema.k)来校验 age 参数。
2563+
2564+ data.json
2565+
2566+ ` ` ` json
2567+ [
2568+ {
2569+ "name": "Alice",
2570+ "age": 18
2571+ },
2572+ {
2573+ "name": "Bob",
2574+ "age": 10
2575+ }
2576+ ]
2577+ ` ` `
2578+
2579+ schema.k
2580+
2581+ ` ` ` kcl
2582+ schema Person:
2583+ name: str
2584+ age: int
2585+
2586+ check:
2587+ age >= 10
2588+ ` ` `
2589+
2590+ 校验 JSON 数据的命令
2591+
2592+ ` ` ` shell
2593+ kcl vet data.json schema.k
2594+ ` ` `
2595+
2596+ # # 63. 如何在给定 Schema 扩展数组属性的默认值?
2597+
2598+ 我们使用 += 运算符来扩展 Schema 数组属性的默认值。
2599+
2600+ ` ` ` python
2601+ schema MyApp:
2602+ args: [str] = ["default", "args"]
2603+
2604+ app = MyApp {
2605+ args += ["additional", "args"]
2606+ }
2607+ ` ` `
2608+
2609+ # # 64. 可以配置 kcl 在特定路径上生成 `.kclvm` 文件夹或者其他与 kcl 编译缓存相关的目录吗?
2610+
2611+ 可以通过变量 KCL_CACHE_PATH 来更改路径。
2612+
2613+ 在 macOS 和 Linux 上:
2614+
2615+ 可以通过向 ~/.bashrc、~/.zshrc 或类似的 shell rc 文件中添加 export 命令来设置 KCL_CACHE_PATH,或者如果您希望它只对当前会话生效,也可以直接在终端中运行它。
2616+
2617+ ` ` ` shell
2618+ export KCL_CACHE_PATH=/tmp # 或者更改为您想要的路径
2619+ ` ` `
2620+
2621+ 在 Windows 上
2622+
2623+ 可以通过命令提示符或 PowerShell 将 KCL_CACHE_PATH 设置为环境变量,以便影响所有 KCL 会话。 对于命令提示符,请使用 setx 命令来永久设置该值:
2624+
2625+ ` ` ` powershell
2626+ setx KCL_CACHE_PATH "C:\t emp" /M
2627+ ` ` `
Original file line number Diff line number Diff line change @@ -28,6 +28,14 @@ Please ensure that the following dependencies are in your PATH:
2828- ` gcc ` for Linux
2929- ` cl.exe ` for Windows, which can be obtained by installing ` MSVC ` including ` MSVCP140.dll ` and ` VCRUNTIME140.dll ` .
3030
31+ ## Error: invalid character 'c' looking for beginning of value
32+
33+ Please ensure that the following dependencies are in your PATH:
34+
35+ - ` clang ` for MacOS
36+ - ` gcc ` for Linux
37+ - ` cl.exe ` for Windows, which can be obtained by installing ` MSVC ` including ` MSVCP140.dll ` and ` VCRUNTIME140.dll ` .
38+
3139## Encountering exit status 0xc0000135 error on Windows platform
3240
3341Please ensure that ` .NET Framework ` and ` MSVC ` are installed on your Windows. If not installed, you can install them and try again.
You can’t perform that action at this time.
0 commit comments