Files
go-admin/cmd/config/server.go
zhangwenjian 8ffde94433 chore🔧: move to go-admin-core v2
Every import of the module changes, not only the seven packages that
moved out of sdk/pkg: Go requires the major version in the path from v2
on. Both happen in one pass —

    go run github.com/go-admin-team/go-admin-core/tools/coreupgrade@v2.0.0 -w -v2 .
    go mod tidy

— which is the command the release notes give, run here as a consumer
would run it. 210 imports across 95 files.

The compatibility shims this used are gone in v2, so the paths that
moved had to move: sdk/pkg/captcha, sdk/pkg/jwtauth and its user
package, sdk/pkg/response and sdk/pkg/casbin.

The count of unformatted files is unchanged at 34, none of them touched
by this: the tool reformats a file only if it was already gofmt clean,
so a migration cannot disappear into whitespace.
2026-08-23 13:26:46 +08:00

64 lines
1.6 KiB
Go

package config
import (
"encoding/json"
"fmt"
"github.com/go-admin-team/go-admin-core/v2/config/source/file"
"github.com/spf13/cobra"
"github.com/go-admin-team/go-admin-core/v2/sdk/config"
)
var (
configYml string
StartCmd = &cobra.Command{
Use: "config",
Short: "Get Application config info",
Example: "go-admin config -c config/settings.yml",
Run: func(cmd *cobra.Command, args []string) {
run()
},
}
)
func init() {
StartCmd.PersistentFlags().StringVarP(&configYml, "config", "c", "config/settings.yml", "Start server with provided configuration file")
}
func run() {
config.Setup(file.NewSource(file.WithPath(configYml)))
application, errs := json.MarshalIndent(config.ApplicationConfig, "", " ") //转换成JSON返回的是byte[]
if errs != nil {
fmt.Println(errs.Error())
}
fmt.Println("application:", string(application))
jwt, errs := json.MarshalIndent(config.JwtConfig, "", " ") //转换成JSON返回的是byte[]
if errs != nil {
fmt.Println(errs.Error())
}
fmt.Println("jwt:", string(jwt))
// todo 需要兼容
database, errs := json.MarshalIndent(config.DatabasesConfig, "", " ") //转换成JSON返回的是byte[]
if errs != nil {
fmt.Println(errs.Error())
}
fmt.Println("database:", string(database))
gen, errs := json.MarshalIndent(config.GenConfig, "", " ") //转换成JSON返回的是byte[]
if errs != nil {
fmt.Println(errs.Error())
}
fmt.Println("gen:", string(gen))
loggerConfig, errs := json.MarshalIndent(config.LoggerConfig, "", " ") //转换成JSON返回的是byte[]
if errs != nil {
fmt.Println(errs.Error())
}
fmt.Println("logger:", string(loggerConfig))
}