1
0
mirror of https://github.com/fumiama/terasu.git synced 2026-06-09 04:30:27 +08:00

feat: add plugin

This commit is contained in:
源文雨
2026-02-16 15:20:45 +08:00
parent f6d5336492
commit 1d573cf2be
14 changed files with 234 additions and 295 deletions

2
ext/custom/.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
*
!.gitignore

24
ext/init.go Normal file
View File

@@ -0,0 +1,24 @@
package ext
import (
"os"
"plugin"
"github.com/sirupsen/logrus"
)
const (
TRSPluginFile = "./terasu.plugin.so"
)
func init() {
if _, err := os.Stat(TRSPluginFile); err != nil {
return
}
_, err := plugin.Open(TRSPluginFile)
if err != nil {
logrus.Warnln("[terasu.plugin] load", TRSPluginFile, "err:", err)
logrus.Warnln("[terasu.plugin] hint: ensure the main binary and plugin are built with identical flags (e.g. both use -trimpath -ldflags=\"-s -w\"), and avoid using 'go run'")
return
}
}