/clamav

Go bindings for the ClamAV antivirus library (http://clamav.net)

Primary LanguageGoGNU General Public License v2.0GPL-2.0

clamav

Go bindings for the ClamAV antivirus library (http://clamav.net)

This is a thin wrapper around the ClamAV antivirus library. The code includes a small scanner as an example in the avclient directory.

To learn more about ClamAV and to install antivirus databases see http://www.clamav.net/lang/en/.

To build make sure the C compiler can see the libclamav shared library, if not you may have to specify it as LDFLAGS: -L/path/to/dylib in the CGo header of each file importing "C". Alternatively, if you have compiled ClamAV in a non-standard directory you can use the following arguments to the go tool:

CGO_CFLAGS=-I/path/to/include CGO_LDFLAGS=-L/path/to/lib go install

For example, on Mountain Lion, after compiling ClamAV by hand, the library gets installed in /usr/local/lib/x86_64. The following command then works to compile the wrappers:

CGO_CFLAGS=-I/usr/local/include CGO_LDFLAGS=-L/usr/local/lib/x86_64 go install

Run go build and, if you have copied the virus files from ClamAV's test/ subdirectory, you can run go test. Run go test -test.bench=Bench to run the benchmarks.

The examples/avclient directory contains a simple filesystem scanner. To compile it run go build in that directory.

Update:

The library is updated to be used with newer versions of libclamav (currently tested with go 1.12 and libclamav version 0.101.4 on Debian 10).

To test the library you will require the testdata that is generated during the clamav build process. The command to test the library is go test ./test

Requirements to build:

  • clamav - version 0.101.4
  • libclamav-dev - version 0.101.4