Instgo is a Go application compilation tool provided by Application Real-Time Monitoring Service (ARMS). After you compile your Go project with Instgo, ARMS monitors your Go application and provides monitoring data such as application topology, traces, and SQL analysis.
This topic applies to Instgo 1.3.0 and later. Run instgo version to check your version. If your version is earlier than 1.3.0, upgrade to 1.3.0 or later. For more information, see Monitor Go applications.
Prerequisites
-
The compilation environment is connected to the public network or an Alibaba Cloud internal network, and the security group of the compilation environment allows outbound TCP traffic on port 80.
-
The LicenseKey and RegionId parameters are configured, which is required to deploy a compilation artifact in a production environment. For more information, see Monitor Go applications.
Download Instgo
-
Run the
wgetcommand to download the compilation tool based on the region where the environment and tool reside. Then, store the tool in a directory where you have the write permission, because it will be automatically updated during compilation.NoteIf you are able to access Object Storage Service (OSS) over the Internet, you can directly use the public endpoint of the operating system and architecture in the China (Hangzhou) region to obtain the compilation tool.
-
Grant the compilation tool the permissions required to perform the related operations.
Linux/Darwin
# Grant the permissions. chmod +x instgoWindows
In Windows, you do not need to grant permissions.
-
Check whether Instgo is available.
Run the instgo version command to check the Instgo version. For example, the output
Instgo version 1.3.0_dea8285indicates that the Instgo version is 1.3.0.Linux/Darwin
./instgo versionWindows
.\instgo.exe version -
Optional. Add Instgo to the path of the compilation environment.
Use Instgo to compile the Go application
Before compiling a Go application, run go version to verify the Go compiler is in your PATH.
Original compilation command of the Go application:
go build -ldflags "-X main.Env=prod -X main.Version=1.0.0" -o app main.go
Compilation command with the instgo prefix:
instgo go build -ldflags "-X main.Env=prod -X main.Version=1.0.0" -o app main.go
If Instgo is not stored in the path of the compilation environment, replace the prefix with the relative or absolute path of Instgo. Example:
/path/to/instgo go build -ldflags "-X main.Env=prod -X main.Version=1.0.0" -o app main.go
Configure Instgo compilation parameters
Instgo provides compilation parameters to control the compilation process. Run the instgo list command to view all parameters and their current preset values.
You can compile and deploy your Go application with the default parameters. To deploy artifacts to a production environment, we recommend that you specify LicenseKey and RegionId before compilation.
|
Flag key |
Environment key |
Parameter data type |
Default value |
Description |
|
--agentVersion |
INSTGO_AGENT_VERSION |
String |
None |
Specifies the version of the ARMS agent for Go. |
|
--agentPath |
INSTGO_AGENT_PATH |
String |
None |
Specifies the local path of the agent. |
|
--cacheDir |
INSTGO_CACHE_DIR |
String |
None |
Specifies the cache directory of the agent. |
|
--dev |
INSTGO_DEV |
Bool |
true |
Enables Development Mode for compilation. In this mode, basic features are available but some may be degraded. For production use, specify the LicenseKey parameter. |
|
--disableDefaultRule |
INSTGO_DISABLE_DEFAULT_RULE |
Bool |
false |
Specifies whether to disable the code enhancement provided by ARMS. If enabled, automatic code enhancement is blocked. Use with caution. |
|
--licenseKey |
INSTGO_LICENSE_KEY |
String |
None |
Specifies the LicenseKey of ARMS. Setting this parameter disables Development Mode. To obtain the LicenseKey, you can call the DescribeTraceLicenseKey operation in OpenAPI Explorer. For more information, see DescribeTraceLicenseKey. |
|
--mse |
INSTGO_MSE |
Bool |
false |
Specifies whether to enable MSE Microservices Governance for the application. For more information, see Connect ACK Go applications to MSE Microservices Governance. |
|
--regionId |
INSTGO_REGION_ID |
String |
cn-hangzhou |
Specifies the region for pulling the agent package and reporting compilation logs. If the compilation environment is in a virtual private cloud (VPC), specify the region of the compilation environment. |
|
--rule |
INSTGO_RULE |
String |
None |
Specifies a code enhancement template for the agent. For more information, see Use custom extensions for the Go agent. |
|
--timeout |
INSTGO_TIMEOUT |
Int |
180 |
Specifies the timeout period for pulling the agent package. Unit: seconds. |
|
--verbose |
INSTGO_VERBOSE |
Bool |
false |
Specifies whether to print detailed compilation logs. |
|
--vpc |
INSTGO_VPC |
Bool |
false |
Specifies whether to pull the agent package through an internal network. |
|
--vendored |
INSTGO_VENDORED |
Bool |
false |
Specifies whether to build projects in vendor mode. |
Use the set command to configure compilation parameters
Use the set command to modify compilation parameters. This command saves the parameters to a $HOME/.instgo.yaml file. Subsequent compilations automatically use the preset values from this file.
For example, if you select the Production Mode and specify the LicenseKey and RegionId parameters, the command is as follows:
instgo set --licenseKey=${YourLicenseKey} --regionId=${YourRegionId} --dev=false
Subsequent compilations use the preset parameters by default.
instgo go build -a
Reset the compilation parameters
To reset all compilation parameters to their default values, run the reset command.
instgo reset
Use environment variables to configure compilation parameters
To apply temporary compilation parameters for a single build without affecting other compilations, set them via environment variables. These variables apply only to the current session.
Example (enabling production mode with LicenseKey and RegionId):
Call the DescribeTraceLicenseKey operation to obtain the LicenseKey.
Linux/Darwin
export INSTGO_LICENSE_KEY=${ARMS_LICENSEKEY}
export INSTGO_REGION_ID=${ARMS_REGIONID}
export INSTGO_DEV="false"
Windows
$env:INSTGO_LICENSE_KEY=${ARMS_LICENSEKEY}
$env:INSTGO_REGION_ID=${ARMS_REGIONID}
$env:INSTGO_DEV="false"
During compilation, Instgo checks for environment variables first. If no environment variables are set, Instgo uses the parameters configured by the set command.
instgo go build -a
You can also write the environment variables and the compilation command on the same line. Example:
Linux/Darwin
INSTGO_LICENSE_KEY=${ARMS_LICENSEKEY} INSTGO_REGION_ID=${ARMS_REGIONID} INSTGO_DEV="false" instgo go build -a
Windows
$env:INSTGO_LICENSE_KEY=${ARMS_LICENSEKEY}; $env:INSTGO_REGION_ID=${ARMS_REGIONID}; $env:INSTGO_DEV="false"; instgo.exe go build -a
Clear temporary files of the agent
Run the clean command to clear compilation and runtime artifacts in the current directory. For example:
instgo clean
If you need to delete the locally cached agent, you can add the --localAgents flag.
instgo clean --localAgents
Manually upgrade Instgo
If your Instgo version is outdated, run the update command to upgrade Instgo and the agent to the latest version available in production environments. Example:
instgo update
-
By default, Instgo automatically updates during compilation according to the ARMS release schedule. In rare cases, compilation failures may occur, which can typically be resolved by retrying.
-
If your Instgo version is earlier than 1.3.0, the
updatecommand may not be available; in this case, please delete the current Instgo and download the latest version of Instgo directly.
Release notes
|
Version |
Release date |
Description |
|
1.3.9 |
August 5, 2025 |
|
|
1.3.8 |
May 29, 2025 |
|
|
1.3.7 |
May 19, 2025 |
|
|
1.3.6 |
April 28, 2025 |
|
|
1.3.5 |
April 17, 2025 |
Projects can be built in vendor mode. |
|
1.3.4 |
March 31, 2025 |
Native Go command proxying is supported in prefix mode. |
|
1.3.3 |
February 28, 2025 |
The ARMS agent for Go V1.6.0 is used as the default version. |
|
1.3.2 |
January 17, 2025 |
The issue of repeated instgo update attempts due to failed automatic updates is fixed. This was caused by a lack of write permissions for instgo. Note
If this issue occurs to your instgo, delete the tool and download a new one. |
|
1.3.1 |
January 10, 2025 |
In Linux and Darwin operating systems, the default agent cache directory has been changed to |
|
1.3.0 |
December 5, 2024 |
|