12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- package main
- import (
- "fmt"
- "os"
- "plugin"
- )
- func main() {
- soPath := os.Args[1]
- //soPath := "/home/cicv/GolandProjects/rosbag-handle/plugin/brakefault.so"
- open, err := plugin.Open(soPath)
- if err != nil {
- fmt.Print("1")
- return
- }
- // 校验 Topic 函数
- topic, err := open.Lookup("Topic")
- if err != nil {
- fmt.Print("2")
- return
- }
- _, ok := topic.(func() string)
- if ok != true {
- fmt.Print("3")
- return
- }
- // 校验 Label 函数
- label, err := open.Lookup("Label")
- if err != nil {
- fmt.Print("4")
- return
- }
- _, ok = label.(func() string)
- if ok != true {
- fmt.Print("5")
- return
- }
- // 校验 Rule 函数
- _, err = open.Lookup("Label")
- if err != nil {
- fmt.Print("6")
- return
- }
- fmt.Print("0")
- }
|