Preliminary Remarks
The GoFrame
framework has released version v2
, marking a milestone with numerous new features and significant improvements, as well as some pioneering features.
For new users, please start directly with v2
. For existing users, it’s highly recommended to upgrade from v1
to v2
, for greater stability and reliability.
Key points to note for the v2
upgrade:
- To ensure compatibility and in accordance with the official
Golang
module management norms, we have changed theimport
paths, hence a global replacement ofimport
paths is required. - Given this is a major upgrade, some methods have been removed or updated, rest assured that better alternatives are provided.
- Generally, after upgrading, simply recompile and modify the code according to the compilation error messages to complete the upgrade.
- The
gredis
component supports clustering, thus changes in configuration need attention.
We have not provided an upgrade tool as we believe that a guide is sufficient.
Compatibility Between v1 and v2
To ensure project compatibility, it is possible to simultaneously depend on both v1
and v2
versions. Therefore, we have released the last version v1.16.7
of v1
, which you can upgrade to if needed. This release addresses the common issue of client_tracing.go:73:3: undefined: attribute.Any
. However, depending on both versions of GoFrame
might reduce project maintainability, and it’s suggested to upgrade to v2
as soon as possible.
Replace Dependencies with v2
Globally replace the source code as follows:
"github.com/gogf/gf/ => "github.com/gogf/gf/v2/
Like this:
Download the Latest v2 Version
go get -u github.com/gogf/gf/v2@latest
Project Directory Adjustments
If you are using the officially recommended project directory structure of GoFrame
, you can manually adjust to the latest directory structure: Project Structure🔥
Note that the latest cli
tool no longer supports the creation of projects with the old directory structure.
Compilation and Running Modifications
Run your project, and if you encounter compilation problems, manually modify them according to the error messages, iterating as necessary.
If you’re unsure how to modify, leave a comment on this document, and our community team will assist you with the upgrade.
Important Changes to the CLI
- The
swagger
command has been removed. In thev1
version, thegf swagger
command automatically installed a third-partyswag
tool to parse annotations in source code to generateswagger
documents. This method of document management and maintenance has issues: it only supports theSwagger2.0
protocol, has a poor usage experience, and maintaining annotations in sync with code is difficult, leading to inconsistencies between interface documentation and code. With standard routes in the new version, this command is discarded. If you need to continue using this function, manually install the third-partyswag
tool: https://github.com/swaggo/swag - The
update
command has been removed. Starting from versionv2
, the installation and download of theCLI
tool are unified viagithub
, reducing maintenance workload. The command may be reintroduced in the future.
Some Important Notes
- The
gf-cli
repository has been moved to the maingf
repository for maintenance, ensuring tools and framework versions are in sync. The original repository is no longer maintained. For details, see: https://github.com/gogf/gf/tree/master/cmd/gf - Core framework components adopt an interface design to ensure wide applicability of interfaces, with some minor reductions in exposed methods.
- Extensive use of the
gvar
generic in core framework components enhances usability, masking specific type implementations at the lower level. For stability and usability, the framework will not consider using the officialGolang
generics within the next2-3
years. The official generics have value for modification in certain features of some framework components.