Golang language recognition method
When there are
go.mod files in the source code root directory, and
Dockerfile files do not exist, Rainbond will recognize the source code as
- After the pre-compilation process is completed,
Golangwill be selected according to the language type to compile the project. During the compilation process, the defined
Golangversions will be installed;
- After the compilation is completed, it will check whether the
Procfileparameter is set on the platform. If it is configured, the startup command configuration file Procfile will be rewritten.
Golang project source code specification
In this step, you need to provide an available Go source code program for deployment on the Rainbond platform. This application must meet at least the following conditions:
go runwhich works fine locally.
Source code programs must be hosted on git or svn services such as gitlab.### Compile the specified module
If there are multiple services in the current project, it can be compiled into multiple binaries, or the main file is not in the main code directory.In golang, one package and one service are usually used under the cmd path.At this time, the above method cannot be compiled and run correctly.
BUILD_GO_INSTALL_PACKAGE_SPEC variable to the environment variable to define the entry path of the component compilation package, for example：
goodrain.com/app-store is the main name of the project, which is consistent with
module in go.mod.
/cmd/manage-server is the package path where the main entry code of the current component is located relative to the code main directory.
The startup command must be defined by uploading the
Procfile file in the code root directory, or by declaring the environment variable
BUILD_PROCFILE The format is as follows：
web: there is a space betweenand
- End of file cannot contain special characters
hellois the compiled binary
For a project that is compiled with a specified module, the following definitions should be made:：
manage-server is the default service subdirectory path in the cmd directory.Binary files are uniformly stored in the bin directory.
Compile and run environment settings
Configure Golang version
Mainstream supports version
go1.11, and the default version of Cloud Help is
go1.16 go1.15 go1.14 go1.13 go1.12 go1.10 go1.9 go1.8
Go Tools version
- Dep supports version v0.4.1 by default
- Glide supports version v0.12.3 by default
- Govendor supports version v1.0.8 by default
- GB supports version 0.4.4 by default
- PkgErrors supports version 0.8.0 by default
- HG supports version 3.9 by default
- TQ supports version v0.5 by default
- MattesMigrate supports version v3.0.0 by default