This repository contains usage examples of the ip-intelligence-go module.
To run these examples you will need a data file and example evidence. To fetch these assets follow the instructions in the ip-intelligence-data repo and put in the root of this repository.
The dependency library ip-intelligence-go uses CGO, so make sure CGO_ENABLED=1 - this is the default, unless you override it.
If you are on Windows, make sure that:
- The path to the
MinGW-x64binfolder is included in thePATH. By default, the path should beC:\msys64\ucrt64\bin - Go environment variable
CGO_ENABLEDis set to1
go env -w CGO_ENABLED=1
NOTE: ip-intelligence-examples-go references ip-intelligence-go as a dependency in go.mod. No additional
actions should be required - the module will be downloaded and built when you do go run, go test, or go build
explicitly for any example.
- All examples under
ipi_onpremisedirectory are console program examples and are run usinggo run.
Below is a table that describes the examples:
| Example | Description |
|---|---|
| ipi_onpremise/getting_started/getting_sarted.go | An example showing how to initialize the IPI engine, minimum required parameters, calling the engine and printing the result |
| ipi_onpremise/offline_processing/offline_processing.go | Example showing how to get values from the engine in weighted value format; writing the obtained values to a yaml file |
| ipi_onpremise/performance/performance.go | A benchmarking example to measure the speed of data processing in single and multi-threaded modes |
| ipi_onpremise/reload_from_file/reload_from_file.go | An example that demonstrates how a data file can be reloaded while serving IP Intelligence requests |
| ipi_onpremise/update_polling_interval/update_polling_interval.go | An example doing periodic polling for the updated data file |
- Navigate to
ipi_onpremisefolder. All examples here are testable and can be run as:
go run [example_dir/example_name].go
- ipi_onpremise examples are assumed to be run from the root directory:
go run onpremise/update_polling_interval/update_polling_interval.go
For further details of how to run each example, please read more in the comment section located at the top of each example file.
To provide a different path to a data file or evidence file use environment variables, e.g.
DATA_FILE=../51Degrees-EnterpriseIpiV41.ipi go run getting_started/getting_started.go
DATA_FILE=../51Degrees-EnterpriseIpiV41.ipi EVIDENCE_YAML=../20000_ipi_evidence_records.yml go run offline_processing/offline_processing.go
DATA_FILE=../51Degrees-EnterpriseIpiV41.ipi EVIDENCE_YAML=../20000_ipi_evidence_records.yml go run update_polling_interval/update_polling_interval.go