跳至内容

c3n1g's Docs

基础

11
  • 构建系统
  • 单元测试
  • 流程控制
  • 枚举
  • 类型转换
  • Allocator和Alignment
  • Reader和Writer
  • Io.Threaded
  • 编译期
  • 原子操作
  • 元编程

开发

2
  • HttpClient开发
  • 协程实现

zio

3
  • 1.1 zio概述
  • 1.2 快速开始
  • 2.1 架构
View Categories
  • 首页
  • 文档
  • Zig
  • zio
  • 1.2 快速开始

1.2 快速开始

c3n1g
更新 2026年4月5日

1 min read

1.2.1 安装 #

添加依赖 #

在项目中添加 ZIO 依赖:

zig fetch --save "git+https://github.com/lalinsky/zio#v0.9.0"
Bash

配置 build.zig #

const std = @import("std");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});
    
    const zio = b.dependency("zio", .{
        .target = target,
        .optimize = optimize,
    });

    const exe = b.addExecutable(.{
        .name = "myapp",
        .root_source_file = b.path("src/main.zig"),
        .target = target,
        .optimize = optimize,
    });

    // 添加 ZIO 模块
    
    exe.root_module.addImport("zio", zio.module("zio"));

    b.installArtifact(exe);

    const run_cmd = b.addRunArtifact(exe);
    const run_step = b.step("run", "Run the app");
    run_step.dependOn(&run_cmd.step);
}
Zig
1.1 zio概述2.1 架构
内容目录
  • 1.2.1 安装
    • 添加依赖
    • 配置 build.zig
© 2026 c3n1g's Docs • Built with GeneratePress