The library requires Go 1.27.0 or later. It has no CGO or libyara dependency. Prebuilt CLI binaries run without a Go installation.
Add the library
Section titled “Add the library”In an existing Go module, pin the documented release:
go get github.com/cawalch/go-yara/compiler@v0.11.1Then follow the complete Go example. The public entry point is the compiler package.
Download the CLI
Section titled “Download the CLI”Published CLI archives use the default Go build; experimental SIMD requires a separate source build. Choose an archive for your operating system and CPU. Extract it and place the go-yara executable on your PATH. On Windows, the executable is go-yara.exe.
| System | CPU | Archive |
|---|---|---|
| Linux | x86-64 | linux_amd64.tar.gz |
| Linux | ARM64 | linux_arm64.tar.gz |
| macOS | Intel | darwin_amd64.tar.gz |
| macOS | Apple silicon | darwin_arm64.tar.gz |
| Windows | x86-64 | windows_amd64.zip |
Compare the archive’s SHA-256 digest with the checksums attached to the release. The release also includes a Cosign verification bundle for the checksums.
Run go-yara --help to confirm the executable is available, then scan a file.
Build from source
Section titled “Build from source”With Git and a supported Go toolchain installed:
git clone https://github.com/cawalch/go-yara.gitcd go-yaragit checkout v0.11.1go build -o go-yara ./cmd./go-yara --helpBuilding with -o go-yara gives the executable the name used throughout these docs. On Windows, use -o go-yara.exe.
Optional SIMD build
Section titled “Optional SIMD build”With Go 1.27 or later, the experimental SIMD build can accelerate parts of literal matching and case folding:
GOEXPERIMENT=simd go build -o go-yara ./cmdScalar paths remain available on unsupported platforms and when SIMD is disabled with GODEBUG=simd=0. Measure your rule set and inputs before choosing a build; performance guidance explains what to compare.
Browser and embedded runtimes
Section titled “Browser and embedded runtimes”The browser playground runs the documented release locally in a Web Worker. It downloads its runtime when you start a scan. Rules and input bytes stay in the browser. The build checks the playground in Chromium, Firefox, and WebKit before publication.
- PageRule editor and input bytes
- Web WorkerGo runtime + Wasm compiler and scanner
- ResultsRule names, occurrence offsets, redacted evidence
The browser build contains the Go runtime and go-yara’s compiler and scanner. A rule still compiles to go-yara bytecode inside that engine; it is not compiled into a separate Wasm module. Input bytes are copied into Go memory. The playground accepts 16 KiB of rule source and 1 MiB of input, with a three-second operation deadline and a hard 128 MiB Wasm linear-memory ceiling. Browser overhead is additional.
Go’s browser Wasm support needs a matching wasm_exec.js. A WASI reactor instead needs a host that supplies WASI imports and initializes the module before calling its exports. A Go application can embed the library directly without either runtime layer.
The playground displays at most 100 rule names, 200 occurrences, 20 evidence findings, and 80 evidence field rows within a shared 64 KiB response. Evidence capture copies are limited to 256 bytes per capture inside the worker; captured values are omitted from the response. These are display limits: conditions and correlation use the complete scan. A timeout or runtime failure produces no complete result, and the worker is discarded. Native file paths and memory mapping are not part of this byte-buffer interface.