Golang Language Recognition Method

When the go.mod file exists in the root directory of the source code and the Dockerfile file does not exist, Kato will recognize the source code as a Golang project.

Compilation Principle

  1. After the pre-compilation process is completed, the buildpack of Golang will be selected according to the language type to compile the project. The defined Golang version will be installed during the compilation process;
  2. After the compilation is completed, it will be checked whether the Procfile parameter is set on the platform. If it is configured, it will rewrite the startup command configuration file Procfile.

Golang Project Source Code Specification

In this step, you need to provide a usable Go source code program for deployment on the Kato platform. This application must at least meet the following conditions:

  1. go build, go run that can run normally locally.

  2. The source code program must be hosted on related git or svn services such as gitlab.

Compile the Specified Module

If there are multiple services in the current project, they can be compiled into multiple binaries, or the main file is not in the main code directory. In golang, a service is usually packaged under the cmd path. At this time, it cannot compile and run correctly according to the above method.

Add the BUILD_GO_INSTALL_PACKAGE_SPEC variable to the environment variable to define the entry path of the component compilation package, for example:


Among them, gridworkz.com/app-store is the main name of the project, which is consistent with the module in go.mod.

/cmd/manage-server is the package path where the main entry code of the current component relative to the code main directory is located.

Procfile Specification

The startup command must be defined by uploading the Procfile file under the code root directory or declaring the environment variable BUILD_PROCFILE, the format is as follows:

web: hello
  1. There is a space between web: and hello
  2. The end of the file cannot contain special characters
  3. hello is the compiled binary

For the project compiled by the specified module, the following definitions should be made:

web: bin/manage-server

Among them, manage-server is the path of the service subdirectory under the default cmd directory. The binary files are stored in the bin directory.

Compile and Run Environment Settings

Configure Golang Version

The mainstream supported versions are go1.10.5, go1.11.2, and the default version of Cloud Help is go1.11.2.

#Support version
Go1.9.7 go1.8.7 go1.11.2 go1.11 go1.11.1 go1.10.5 go1.10.4

Go Tools Version

  • Dep Version v0.4.1 is supported by default
  • Glide Default support version v0.12.3
  • Govendor Version v1.0.8 is supported by default
  • GB Version 0.4.4 is supported by default
  • PkgErrors Version 0.8.0 is supported by default
  • HG Version 3.9 is supported by default
  • TQ Default support version v0.5
  • MattesMigrate Version v3.0.0 is supported by default

Sample Demo Program

Example https://github.com/gridworkz/go-demo