VM1 и VM2 имеют версию 1.11.1.
Мой сценарий:
VM1:
main.go
package main
func startGin() *gin.Engine {
gin.SetMode(gin.ReleaseMode)
router := gin.New()
v1:= router.Group("/v1")
all_plugins, err := filepath.Glob("plugins/*.so")
if err != nil {
panic(err)
}
for _, filename := range all_plugins {
p, err := plugin.Open(filename)
if err != nil {
panic(err)
}
handler, err := p.Lookup("Handler")
if err != nil {
panic(err)
}
v1.GET("/sample", handler.(func() gin.HandlerFunc)())
}
return router
}
func main() {
router := startGin()
server := &http.Server{Handler: router}
ln, err := net.Listen("tcp4", ":8080")
if err != nil {
log.Error.Printf("error during startup", err)
}
server.Serve(tcpKeepAliveListener{ln.(*net.TCPListener)})
}
gobuild main.go
VM2:
plugin.go
package main
import (
"fmt"
"github.com/gin-gonic/gin"
)
func Handler() gin.HandlerFunc {
return func(c *gin.Context) {
c.JSON(200, "Success")
}
}
go build -buildmode = plugin plugin plugin.go
Getting Error "былпостроен с другой версией пакета