main.go 729 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "plugin"
  6. )
  7. func main() {
  8. soPath := os.Args[1]
  9. //soPath := "/home/cicv/GolandProjects/rosbag-handle/plugin/brakefault.so"
  10. open, err := plugin.Open(soPath)
  11. if err != nil {
  12. fmt.Print("1")
  13. return
  14. }
  15. // 校验 Topic 函数
  16. topic, err := open.Lookup("Topic")
  17. if err != nil {
  18. fmt.Print("2")
  19. return
  20. }
  21. _, ok := topic.(func() string)
  22. if ok != true {
  23. fmt.Print("3")
  24. return
  25. }
  26. // 校验 Label 函数
  27. label, err := open.Lookup("Label")
  28. if err != nil {
  29. fmt.Print("4")
  30. return
  31. }
  32. _, ok = label.(func() string)
  33. if ok != true {
  34. fmt.Print("5")
  35. return
  36. }
  37. // 校验 Rule 函数
  38. _, err = open.Lookup("Label")
  39. if err != nil {
  40. fmt.Print("6")
  41. return
  42. }
  43. fmt.Print("0")
  44. }