Skip to main content
Version: 2.8.x(Latest)

One of the goals of resource management design is not to affect the development and management of static files during the development phase, only to execute packaging at release time. Once packaging is complete, temporary files are cleaned up, so it only affects the generated binary executable file, making it imperceptible and convenient for developers to use.

Prepare the Project

It is recommended to use the engineering directory structure officially provided by GoFrame and to use the CLI tool to create your project, as the entire framework engineering concept and some examples are based on a standardized engineering directory structure. This is more conducive to learning and using the entire development framework, improving development efficiency. In particular, there is a packed directory in the project directory to store the packaged content related to the resource management component. By default, it contains a blank go file that does nothing.

Development Phase

During the development phase, generally, developers do not need to care about resource management; they should code as usual, and static files should be placed in the resource directory as suggested. In the development phase, static file access will be directly through the file system.

Prepare for Release

After development is complete, if you wish to package static files, template files, and configuration files into the binary executable file for release alongside it, the resource component will now begin to showcase its capability. You need to configure cross-compilation settings, specifically refer to the command line section Cross-Compiling. We need to use the CLI tool to execute executable file compilation, managing your compile configuration through a configuration file (placed in the hack/config.yaml file). A reference compile configuration is as follows:

gfcli:
build:
name: "my-app"
arch: "amd64"
system: "linux"
mod: "none"
cgo: 0
packSrc: "manifest/config,manifest/i18n,resource/public,resource/template"
version: ""
output: "./bin"
extra: ""

Please note the pack configuration, indicating the directories to be automatically packaged into the binary executable file during compilation. Then, execute the compile command in the root directory of the project:

gf build

This command automatically packages the directories specified in the configuration file into temporary packaged go files during compilation, then cleans up the temporary packaged go files after compilation is complete.

tip

In most scenarios, configuration files may not need to be packaged into the binary executable file. Choose according to your business scenario.

Release and Run

Release and execute the binary as needed.