# myPlugin **Repository Path**: cy422396350/myPlugin ## Basic Information - **Project Name**: myPlugin - **Description**: golang 插件样例,可移植到web项目 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-06-27 - **Last Updated**: 2022-06-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # golangPlugin #### 介绍 golang 插件样例,可移植到web项目 本例子是测试github里面的:https://github.com/scgywx/myplugin 发现依赖GOPAYTH是以前的版本,将其改到gomod下,有例子可以方便的移植到各位的项目中 #### 使用说明 测试步骤 1、编译main. 2、编译第1个版本so(plugins里面的插件) ```shell go build -buildmode=plugin -o phone.so ./plugins/phone/phone.go ``` 3、编译第2个版本so(plugins里面的插件)调整里面的modelVersion和modelName 例:l var ( modelVersion = 1002 modelName = "game2" ) 4、编译第2个版本so(注册后面的参数) ```shell go build -buildmode=plugin -o phone.so ./plugins/car/car.go ``` 5、运行main ```shell ./golangPlugin ``` 6、浏览器输入127.0.0.1:12345/hello,会看到如下显示(这是使用的第一个版本so) ### hello test, this is golang plugin test!, version=1001, name=phone, oldversion=0, oldName= 7、浏览器输入127.0.0.1:12345/load?name=plugin2.so(这里输出done,就说明加载so成功了) 8、再次输入127.0.0.1:12345/hello,会看到如下显示。 ### hello test, this is golang plugin test!, version=1002, name=car, oldversion=1001, oldName=phone