mirror of
https://gitee.com/johng/gf
synced 2026-07-06 13:42:46 +08:00
This pull request updates the GoFrame framework and its related drivers and configuration modules from version v2.10.0 to v2.10.1 across multiple `go.mod` files and documentation. The main goal is to ensure all dependencies consistently use the latest patch version, improving compatibility and stability. Dependency version updates: * Updated `github.com/gogf/gf/v2` and related driver dependencies from v2.10.0 to v2.10.1 in the following `go.mod` files: - `cmd/gf/go.mod` - `contrib/config/apollo/go.mod` - `contrib/config/consul/go.mod` - `contrib/config/kubecm/go.mod` - `contrib/config/nacos/go.mod` - `contrib/config/polaris/go.mod` - `contrib/drivers/clickhouse/go.mod` - `contrib/drivers/dm/go.mod` - `contrib/drivers/gaussdb/go.mod` - `contrib/drivers/mariadb/go.mod` - `contrib/drivers/mssql/go.mod` - `contrib/drivers/mysql/go.mod` - `contrib/drivers/oceanbase/go.mod` - `contrib/drivers/oracle/go.mod` - `contrib/drivers/pgsql/go.mod` - `contrib/drivers/sqlite/go.mod` - `contrib/drivers/sqlitecgo/go.mod` - `contrib/drivers/tidb/go.mod` Documentation updates: * Updated the contributors badge in `README.MD` and `README.zh_CN.MD` to reflect version v2.10.1. [[1]](diffhunk://#diff-01e6d9ffed056a02cae8d8a0ec5d476a64d017bf85c0d5a94bb23ca21f33f5aaL49-R49) [[2]](diffhunk://#diff-c93759cb9a9500f20e551c741eb167fc72825fd638d36121357feb8253ce6ac1L49-R49)
apollo
Package apollo implements GoFrame gcfg.Adapter using apollo service.
Installation
go get -u github.com/gogf/gf/contrib/config/apollo/v2
Usage
Create a custom boot package
If you wish using configuration from apollo globally, it is strongly recommended creating a custom boot package in very top import, which sets the Adapter of default configuration instance before any other package boots.
package boot
import (
"github.com/gogf/gf/contrib/config/apollo/v2"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
)
func init() {
var (
ctx = gctx.GetInitCtx()
appId = "SampleApp"
cluster = "default"
ip = "http://localhost:8080"
)
// Create apollo Client that implements gcfg.Adapter.
adapter, err := apollo.New(ctx, apollo.Config{
AppID: appId,
IP: ip,
Cluster: cluster,
})
if err != nil {
g.Log().Fatalf(ctx, `%+v`, err)
}
// Change the adapter of default configuration instance.
g.Cfg().SetAdapter(adapter)
}
Import boot package in top of main
It is strongly recommended import your boot package in top of your main.go.
Note the top import: _ "github.com/gogf/gf/example/config/apollo/boot" .
package main
import (
_ "github.com/gogf/gf/example/config/apollo/boot"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
)
func main() {
var ctx = gctx.GetInitCtx()
// Available checks.
g.Dump(g.Cfg().Available(ctx))
// All key-value configurations.
g.Dump(g.Cfg().Data(ctx))
// Retrieve certain value by key.
g.Dump(g.Cfg().MustGet(ctx, "server.address"))
}
License
GoFrame apollo is licensed under the MIT License, 100% free and open-source, forever.