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:
2
ext/custom/.gitignore
vendored
Normal file
2
ext/custom/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
24
ext/init.go
Normal file
24
ext/init.go
Normal 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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user