Updated on 2024-04-08 GMT+08:00

Guidelines for Compiling Go Plug-ins

Constraint

The Go language has many restrictions on plug-ins, such as the Go version, third-party dependency version, and compilation parameters. The plug-ins must be strictly consistent with the main program of the CodeArts PerfTest executor. Otherwise, exceptions including but not limited to those described in Table 1 may occur. Compile the so file strictly according to the conventions.

Table 1 Guidelines for compiling Go plug-ins

Item

Constraint Value

Description

arch

linux amd64

-

Go version

1.19.6

Run the go version command to check the version.

  • The following exception occurs when medium versions are inconsistent:

    fatal error: runtime: no plugin module data

  • The following exception occurs when minor versions are inconsistent:

    plugin was built with a different version of package runtime

go.mod

github.com/go-resty/resty/v2 v2.7.0

github.com/shopspring/decimal v1.3.1

github.com/xuri/excelize/v2 v2.6.0

github.com/tidwall/gjson v1.14.4

github.com/valyala/fasthttp v1.43.0

go.uber.org/atomic v1.10.0

golang.org/x/net v0.8.0

golang.org/x/time v0.2.0

If a third-party library is directly or indirectly used, use the version according to the constraint value in the go.mod file.

If the third-party versions are inconsistent, the following exception occurs:

plugin was built with a different version of package github.com/json-iterator/go

TrimPath

Using TrimPath

If this parameter is not used, the following exception occurs:

plugin was built with a different version of package internal/unsafeheader

Run the Linux command strip to remove symbols and debugging information.

Compilation Example

go build -buildmode=plugin -trimpath -o random.so random.go
strip random.so