簡介 · Clash文件

快速開始

說明準備 Clash 核心的兩種方式:下載預先編譯的二進位檔,或使用 Go 從原始碼編譯,並列出 GOPATH、版本檢查及 GOOS、GOARCH 交叉編譯重點。

  • Golang
  • 預編譯
  • GOPATH
  • 交叉編譯
  • GOARCH
簡介

為了開始使用 Clash,您可以從原始碼編譯或者下載預編譯的二進位檔案。

使用預編譯的二進位檔案

如需下載 Clash 核心的二進位檔,請參閱:Clash Premium 說明

從原始碼編譯

您可以使用 Golang 1.19+ 在您的裝置上編譯 Clash:

shell
$ go install github.com/Dreamacro/clash@latest
go: downloading github.com/Dreamacro/clash v1.15.1

二進位檔會編譯至 $GOPATH/bin 目錄:

shell
$ $GOPATH/bin/clash -v
Clash unknown version darwin arm64 with go1.20.3 unknown time

跨平台/作業系統編譯

Golang 支援交叉編譯,因此您可以為不同架構或作業系統的裝置編譯 Clash。使用 make 即可輕鬆完成編譯,例如:

shell
$ git clone --depth 1 https://github.com/Dreamacro/clash
Cloning into 'clash'...
remote: Enumerating objects: 359, done.
remote: Counting objects: 100% (359/359), done.
remote: Compressing objects: 100% (325/325), done.
remote: Total 359 (delta 25), reused 232 (delta 17), pack-reused 0
Receiving objects: 100% (359/359), 248.99 KiB | 1.63 MiB/s, done.
Resolving deltas: 100% (25/25), done.
$ cd clash && make darwin-arm64
fatal: No names found, cannot describe anything.
GOARCH=arm64 GOOS=darwin CGO_ENABLED=0 go build -trimpath -ldflags '-X "github.com/Dreamacro/clash/constant.Version=unknown version" -X "github.com/Dreamacro/clash/constant.BuildTime=Mon May  8 16:47:10 UTC 2023" -w -s -buildid=' -o bin/clash-darwin-arm64
$ file bin/clash-darwin-arm64
bin/clash-darwin-arm64: Mach-O 64-bit executable arm64

如需瞭解其他建置目標,請參閱本站跨平台編譯說明