Installation¶
This guide will help you install HNSW in your Go project.
Requirements¶
- Go 1.18 or later (for generics support)
- A Go project initialized with Go modules
Installing the Library¶
You can install HNSW using the go get
command:
This will download the latest version of the library and add it to your go.mod
file.
Verifying the Installation¶
To verify that the library is installed correctly, you can create a simple Go program that imports the library:
package main
import (
"fmt"
"github.com/TFMV/hnsw"
)
func main() {
// Create a new HNSW graph
graph := hnsw.NewGraph[int]()
fmt.Println("HNSW graph created successfully!")
}
Save this file as verify.go
and run it:
If the installation was successful, you should see the message "HNSW graph created successfully!".
Installing Extensions¶
HNSW comes with several extensions that provide additional functionality. These extensions are included in the main package and don't require separate installation.
To use the extensions, you can import them as follows:
import (
"github.com/TFMV/hnsw"
"github.com/TFMV/hnsw/hnsw-extensions/meta" // For metadata extension
"github.com/TFMV/hnsw/hnsw-extensions/facets" // For faceted search
)
Building from Source¶
If you want to build HNSW from source, you can clone the repository and build it using the standard Go tools:
Next Steps¶
Now that you have installed HNSW, you can proceed to the Quick Start guide to learn how to use the library.