[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-2064":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":22,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":28,"readmeContent":29,"aiSummary":30,"trendingCount":16,"starSnapshotCount":16,"syncStatus":14,"lastSyncTime":31,"discoverSource":32},2064,"go-libghostty","mitchellh\u002Fgo-libghostty","mitchellh","[Mirror] Go bindings for libghostty-vt. Source of truth: https:\u002F\u002Ftangled.org\u002Fmitchellh.com\u002Fgo-libghostty","https:\u002F\u002Fpkg.go.dev\u002Fgo.mitchellh.com\u002Flibghostty",null,"Go",138,7,2,1,0,3,5,9,2.71,"MIT License",false,"main",true,[26,27],"ghostty","libghostty","2026-06-12 02:00:36","# Go Libghostty Bindings\n\nGo bindings for `libghostty-vt`.\n\nThis project uses [cgo](https:\u002F\u002Fpkg.go.dev\u002Fcmd\u002Fcgo) but `libghostty-vt`\nonly depends on libc, so it is very easy to static link and very\neasy to cross-compile. The bindings default to static linking for this\nreason.\n\n> [!WARNING]\n>\n> **I'm not promising any API stability yet.** This is a new project and the\n> API may change as necessary. The underlying functionality is very stable,\n> but the Go API is still being designed.\n\n## Example\n\n```go\npackage main\n\nimport (\n \"fmt\"\n \"log\"\n\n \"go.mitchellh.com\u002Flibghostty\"\n)\n\nfunc main() {\n term, err := libghostty.NewTerminal(libghostty.WithSize(80, 24))\n if err != nil {\n  log.Fatal(err)\n }\n defer term.Close()\n\n \u002F\u002F Feed VT data — bold green \"world\", then plain text.\n fmt.Fprintf(term, \"Hello, \\033[1;32mworld\\033[0m!\\r\\n\")\n\n \u002F\u002F Format the terminal contents as plain text.\n f, err := libghostty.NewFormatter(term,\n  libghostty.WithFormatterFormat(libghostty.FormatterFormatPlain),\n  libghostty.WithFormatterTrim(true),\n )\n if err != nil {\n  log.Fatal(err)\n }\n defer f.Close()\n\n output, _ := f.FormatString()\n fmt.Println(output) \u002F\u002F Hello, world!\n}\n```\n\nMore examples are in the [`examples\u002F`](examples\u002F) directory.\n\n## Usage\n\nAdd the module to your Go project:\n\n```shell\ngo get go.mitchellh.com\u002Flibghostty\n```\n\nThis is a cgo package that links `libghostty-vt` via `pkg-config`. By\ndefault it links statically. Before building your project, you need the\nlibrary installed. Either install it system-wide or set `PKG_CONFIG_PATH`\nto point to a local checkout:\n\n```shell\nexport PKG_CONFIG_PATH=\u002Fpath\u002Fto\u002Flibghostty-vt\u002Fshare\u002Fpkgconfig\n```\n\nTo link dynamically instead (requires the shared library at runtime,\nso you'll also need to set the library path):\n\n```shell\ngo build -tags dynamic\n```\n\nSee the [Ghostty docs](https:\u002F\u002Fghostty.org\u002Fdocs\u002Finstall\u002Fbuild) for\nbuilding `libghostty-vt` from source.\n\n### Cross-Compilation\n\nBecause `libghostty-vt` only depends on libc, cross-compilation is\nstraightforward using [Zig](https:\u002F\u002Fziglang.org\u002F) as the C compiler.\nZig is already required to build `libghostty-vt`, so no extra tooling\nis needed. You don't need to write any Zig code, we're just using\nZig as a C\u002FC++ compiler.\n\nFirst, build `libghostty-vt` for your target (from the ghostty source tree):\n\n```shell\nzig build -Demit-lib-vt -Dtarget=x86_64-linux-gnu --prefix \u002Ftmp\u002Fghostty-linux-amd64\n```\n\nThen cross-compile your Go project with `zig cc`:\n\n```shell\nCGO_ENABLED=1 \\\nGOOS=linux GOARCH=amd64 \\\nCC=\"zig cc -target x86_64-linux-gnu\" \\\nCXX=\"zig c++ -target x86_64-linux-gnu\" \\\nCGO_CFLAGS=\"-I\u002Ftmp\u002Fghostty-linux-amd64\u002Finclude -DGHOSTTY_STATIC\" \\\nCGO_LDFLAGS=\"-L\u002Ftmp\u002Fghostty-linux-amd64\u002Flib -lghostty-vt\" \\\ngo build .\u002F...\n```\n\nSupported targets include `x86_64-linux-gnu`, `aarch64-linux-gnu`,\n`x86_64-macos`, `aarch64-macos`, `x86_64-windows-gnu`, and\n`aarch64-windows-gnu`.\n\nIf you are using ghostty's CMake integration via `FetchContent`, the\n`ghostty_vt_add_target()` function handles the zig build for you:\n\n```cmake\nFetchContent_MakeAvailable(ghostty)\nghostty_vt_add_target(NAME linux-amd64 ZIG_TARGET x86_64-linux-gnu)\n```\n\nSee the [ghostty CMakeLists.txt](https:\u002F\u002Fgithub.com\u002Fghostty-org\u002Fghostty\u002Fblob\u002Fmain\u002FCMakeLists.txt)\nfor full documentation of `ghostty_vt_add_target()`.\n\n## Development\n\nCMake fetches and builds `libghostty-vt` automatically. CMake is only\nrequired and used for development of this module. For actual downstream\nusage, you can get `libghostty-vt` available however you like (e.g. system\npackage, local checkout, etc.).\n\nYou need [Zig](https:\u002F\u002Fghostty.org\u002Fdocs\u002Finstall\u002Fbuild) and CMake on your PATH.\n\n```shell\nmake build\nmake test\n\n# If in a Nix dev shell:\ngo build\ngo test\n```\n\nIf you use the Nix dev shell (`nix develop`), `go build` and `go test`\nwork directly — the shell configures all paths automatically.\n","该项目提供了Go语言绑定库，用于与`libghostty-vt`进行交互。其核心功能包括通过cgo技术将`libghostty-vt`静态链接到Go项目中，使得终端模拟和VT数据处理变得简单且易于跨平台编译。该库支持创建虚拟终端、处理VT序列以及将终端内容格式化为纯文本等功能。由于其依赖于libc，因此非常适合需要在不同操作系统上运行的命令行工具或后端服务开发场景。需要注意的是，尽管底层功能非常稳定，但当前版本的Go API尚处于设计阶段，未来可能会有所变化。","2026-06-11 02:47:54","CREATED_QUERY"]