zoraxy/docs/plugins/docs/1. Introduction/2. Getting Started.md
Toby Chui 29daa4402d Added more doc
- Added auto reload for doc engine
- Added helloworld example
2025-05-27 22:00:16 +08:00

62 lines
2.3 KiB
Markdown

# Getting Started
Last Update: 25/05/2025
---
To start developing plugins, you will need the following installed on your computer
1. The source code of Zoraxy
2. Go compiler
3. VSCode (recommended, or any editor of your choice)
---
## Step 1: Start Zoraxy at least once
If you have just cloned Zoraxy from the Github repo, use the following to build and run it once.
```bash
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.
---
## Steps 2: Prepare the development environment for Zoraxy Plugin
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
### 2.1 Create Plugin Folder
Create a folder with your plugin name in the `plugins` folder. After creating the folder, you would have something like `plugins/Lapwing/`.
### 2.2 Locate and copy Zoraxy Plugin library
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`.
### 2.3 Prepare Go Project structure
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`.
---
## Steps 3: Open plugin folder in IDE
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!