forked from hillu/go-yara
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
38 lines (33 loc) · 1.01 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright © 2015-2020 Hilko Bengen <[email protected]>
// All rights reserved.
//
// Use of this source code is governed by the license that can be
// found in the LICENSE file.
// Package yara provides bindings to the YARA library.
package yara
/*
#include <yara.h>
*/
import "C"
func init() {
if err := initialize(); err != nil {
panic(err)
}
}
// Prepares the library to be used.
func initialize() error {
return newError(C.yr_initialize())
}
// Finalize releases all the resources allocated by the YARA library.
// It should be called by the program when it no longer needs YARA,
// e.g. just before the program exits. It is not strictly necessary to
// call Finalize because the allocated memory will be freed on program
// exit; however, explicitly-freed resources will not show up as a
// leak in memory profiling tools.
//
// A good practice is calling Finalize as a deferred function in the
// program's main function:
// defer yara.Finalize()
func Finalize() error {
return newError(C.yr_finalize())
}