Skip to content

Install go-yara

Docs for v0.11.1 · Go 1.27.0+ · Go API

The library requires Go 1.27.0 or later. It has no CGO or libyara dependency. Prebuilt CLI binaries run without a Go installation.

In an existing Go module, pin the documented release:

Terminal window
go get github.com/cawalch/go-yara/compiler@v0.11.1

Then follow the complete Go example. The public entry point is the compiler package.

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.

SystemCPUArchive
Linuxx86-64linux_amd64.tar.gz
LinuxARM64linux_arm64.tar.gz
macOSInteldarwin_amd64.tar.gz
macOSApple silicondarwin_arm64.tar.gz
Windowsx86-64windows_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.

With Git and a supported Go toolchain installed:

Terminal window
git clone https://github.com/cawalch/go-yara.git
cd go-yara
git checkout v0.11.1
go build -o go-yara ./cmd
./go-yara --help

Building with -o go-yara gives the executable the name used throughout these docs. On Windows, use -o go-yara.exe.

With Go 1.27 or later, the experimental SIMD build can accelerate parts of literal matching and case folding:

Terminal window
GOEXPERIMENT=simd go build -o go-yara ./cmd

Scalar 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.

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.

Browser playground · runtime loaded on demand
  1. PageRule editor and input bytes
  2. Web WorkerGo runtime + Wasm compiler and scanner
  3. ResultsRule names, occurrence offsets, redacted evidence
Messages cross the worker boundary. Input bytes are copied into Go memory. Terminating the worker stops work and discards its compiled rules.

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.