增加 -trimpath 参数.
Signed-off-by: lion.chan <cy187lion@sina.com>
This commit is contained in:
parent
a9f0ace2eb
commit
c2784076bc
|
@ -24,13 +24,15 @@ func PrintTest(strInput string) {
|
|||
编译 Go 动态库命令:
|
||||
|
||||
```bash
|
||||
go build -buildmode=plugin
|
||||
go build -trimpath -buildmode=plugin -ldflags="-w -s"
|
||||
```
|
||||
|
||||
指定文件编译 Go 动态库命令
|
||||
其中 -trimpath 用于从二进制文件中删除文件系统路径信息。
|
||||
|
||||
指定文件编译 Go 动态库命令:
|
||||
|
||||
```bash
|
||||
go build -buildmode=plugin -o print.so print.go
|
||||
go build -trimpath -buildmode=plugin -ldflags="-w -s" -o print.so print.go
|
||||
```
|
||||
|
||||
go 动态库方法的使用(main.go):
|
||||
|
@ -61,6 +63,12 @@ func main() {
|
|||
}
|
||||
```
|
||||
|
||||
编译:
|
||||
|
||||
```bash
|
||||
go build -trimpath -ldflags="-w -s"
|
||||
```
|
||||
|
||||
Go 1.8 中 plugin 包只提供 Open 和 Lookup 方法,对应打开动态库和获取动态库中的方法。注意获取到的动态动态库方法其实是一个 interface{} 类型,需要将其进行转换后才可以使用。
|
||||
|
||||
## 3.注意
|
||||
|
|
Loading…
Reference in New Issue