Important: this is a work-in-progress. Bugs and feature requests welcome via issues or pull requests.
All packages require libvarnishapi (varnish-dev or varnish-devel) (open-source or Enterprise) and CGo.
vtest — spawn Varnish instances for testing
Go-native alternative to the varnishtest tool.
Spin up a real Varnish process, make HTTP requests against it, and inspect VSL logs — all from regular Go tests.
go get github.com/varnish/varnish-go/vtestlog — stream VSL transactions
Read and filter Varnish Shared Log transactions from a live instance or a binary file, equivalent to varnishlog.
log/tags.go exposes named variables for every known VSL tag across Varnish OSS and Enterprise (e.g. log.TagReqURL). Values are resolved at startup; tags absent from the installed Varnish version are left as zero.
go get github.com/varnish/varnish-go/logstat — read statistics counters
Poll VSC counters from Varnish Shared Memory, equivalent to varnishstat.
go get github.com/varnish/varnish-go/statadm — admin socket client
Send CLI commands to a running Varnish instance, equivalent to varnishadm.
go get github.com/varnish/varnish-go/admversion — installed Varnish version
Reports the installed Varnish edition (open-source or Enterprise), version string, and commit hash, resolved at compile time from vmod_abi.h.
go get github.com/varnish/varnish-go/versionvcl — parse and render VCL
Parses Varnish Configuration Language (VCL) source into an AST, and renders it back. Pure Go, no CGo and no libvarnishapi required — unlike the other packages above.
v, err := vcl.NewParser(input).Parse()
if err != nil {
// handle error
}
fmt.Print(v.String()) // re-rendered VCL
prog := v.AST() // the parsed *ast.Programgo get github.com/varnish/varnish-go/vcl