To start developing plugins, you will need the following installed on your computer
If you have just cloned Zoraxy from the Github repo, use the following to build and run it once.
cd src/
go mod tidy
go build
sudo ./zoraxy
This would allow Zoraxy to generate all the required folder structure on startup.
After the startup process completes, you would see a folder named “plugins” in the working directory of Zoraxy.
Next, you will need to think of a name for your plugin. Lets name our new plugin “Lapwing”.
Notes: Plugin name described in Introspect (will discuss this in later sessions) can contains space, but the folder and compiled binary filename must not contains space and special characters for platform compatibilities reasons.
Follow the steps below to create the folder structure
Create a folder with your plugin name in the
plugins
folder. After creating the folder, you would have something like
plugins/Lapwing/
.
Locate the Zoraxy plugin library from the Zoraxy source code. You can find the
zoraxy_plugin
Go module under
src/mod/plugins/zoraxy_plugin
.
Copy the
zoraxy_plugin
folder from the Zoraxy source code mod folder into the your plugin’s mod folder. Let assume you use the same mod folder name as Zoraxy as
mod
, then your copied library path should be
plugins/Lapwing/mod/zoraxy_plugin
.
Create the
main.go
file for your plugin. In the example above, it would be located at
plugins/Lapwing/main.go
.
Use
go mod init yourdomain.com/foo/plugin_name
to initiate your plugin. By default the
go.mod
file will be automatically generated by the go compiler. Assuming you are developing Lapwing with its source located on Github, this command would be
go mod init github.com/your_user_name/Lapwing
.
Now open your preferred IDE or text editor and use your plugin folder as the project folder
Now, you are ready to start developing Zoraxy plugin!