mirror of
https://github.com/fumiama/terasu.git
synced 2026-06-05 17:20:24 +08:00
26 lines
576 B
Go
26 lines
576 B
Go
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 ext", 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
|
|
}
|
|
logrus.Infoln("[terasu.plugin] loaded ext", TRSPluginFile)
|
|
}
|