This Go program serves as a dynamic plugin loader, loading a shared object file (plug.so
) at runtime. The program assumes that the plugin defines specific symbols (V
and F
) and demonstrates how to interact with them.
- Dynamic Loading: The program dynamically loads a shared object file (
plug.so
) using the Goplugin
package. - Symbol Lookup: It looks up symbols (
V
andF
) in the loaded plugin. - Command-Line Interaction: The program takes a command-line argument and sets the value of a variable (
V
) in the plugin. - Function Invocation: It calls a function (
F
) from the plugin with the hostname as an argument.
Ensure that you have Go installed on your machine. You can download it from the official website.
-
Build the Program:
make build
-
Build the Plugin (
plug.so
):The plugin should export the symbols
V
(pointer to a string) andF
(function taking a string argument). Make sure the plugin is built before running the main program.go build -buildmode=plugin -o build/plug.so plugin/*
-
Run the Program:
./app <your_argument>
Replace
<your_argument>
with the desired command-line argument.
No specific configuration is required for this program. Ensure that the shared object file (plug.so
) is present in the same directory as the executable.
If you'd like to contribute to the project, feel free to fork the repository, make your changes, and submit a pull request.
This project is licensed under the MIT License - see the LICENSE file for details.