mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 00:50:20 +08:00
parent
7954ad3759
commit
97c7835d9e
@ -3,7 +3,6 @@ package config
|
||||
import (
|
||||
_ "embed"
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -19,12 +18,8 @@ const (
|
||||
configFile = "goctl.yaml"
|
||||
)
|
||||
|
||||
var (
|
||||
//go:embed default.yaml
|
||||
defaultConfig []byte
|
||||
|
||||
ExternalConfig *External
|
||||
)
|
||||
//go:embed default.yaml
|
||||
var defaultConfig []byte
|
||||
|
||||
// Config defines the file naming style
|
||||
type (
|
||||
@ -77,14 +72,13 @@ func NewConfig(format string) (*Config, error) {
|
||||
return cfg, err
|
||||
}
|
||||
|
||||
func init() {
|
||||
func GetExternalConfig() (*External, error) {
|
||||
var cfg External
|
||||
err := loadConfig(&cfg)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
} else {
|
||||
ExternalConfig = &cfg
|
||||
return nil, err
|
||||
}
|
||||
return &cfg, nil
|
||||
}
|
||||
|
||||
func loadConfig(cfg *External) error {
|
||||
|
@ -258,10 +258,12 @@ func ConvertStringDataType(dataBaseType string, isDefaultNull, unsigned, strict
|
||||
}
|
||||
|
||||
func convertDatatypeWithConfig(dataBaseType string, isDefaultNull, unsigned bool) (string, string) {
|
||||
if config.ExternalConfig == nil {
|
||||
externalConfig, err := config.GetExternalConfig()
|
||||
if err != nil {
|
||||
return "", ""
|
||||
}
|
||||
opt, ok := config.ExternalConfig.Model.TypesMap[strings.ToLower(dataBaseType)]
|
||||
|
||||
opt, ok := externalConfig.Model.TypesMap[strings.ToLower(dataBaseType)]
|
||||
if !ok || (len(opt.Type) == 0 && len(opt.UnsignedType) == 0 && len(opt.NullType) == 0) {
|
||||
return "", ""
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user