config

package
v1.8.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2024 License: GPL-3.0 Imports: 2 Imported by: 8

README

配置项管理

名称 是否可选 说明
namingFormat YES 文件名称格式化符

naming-format

namingFormat可以用于对生成代码的文件名称进行格式化,和日期格式化符(yyyy-MM-dd)类似,在代码生成时可以根据这些配置项的格式化符进行格式化。

格式化符(gozero)

格式化符由go,zero组成,如常见的三种格式化风格你可以这样编写:

  • lower: gozero
  • camel: goZero
  • snake: go_zero

常见格式化符生成示例 源字符:welcome_to_go_zero

格式化符 格式化结果 说明
gozero welcometogozero 小写
goZero welcomeToGoZero 驼峰
go_zero welcome_to_go_zero snake
Go#zero Welcome#to#go#zero #号分割Title类型
GOZERO WELCOMETOGOZERO 大写
_go#zero_ _welcome#to#go#zero_ 下划线做前后缀,并且#分割

错误格式化符示例

  • go
  • gOZero
  • zero
  • goZEro
  • goZERo
  • goZeRo
  • tal

使用方法

目前可通过在生成api、rpc、model时通过--style参数指定format格式,如:

goctl api go test.api -dir . -style gozero
 goctl rpc proto -src test.proto -dir . -style go_zero
goctl model mysql datasource -url="" -table="*" -dir ./snake -style GoZero

默认值

当不指定-style时默认值为gozero

Documentation

Index

Constants

View Source
const CoreVersion = "v1.5.4"

CoreVersion is the core service version.

View Source
const DefaultFormat = "go_zero"

DefaultFormat defines a default naming style

View Source
const DefaultGoZeroVersion = "v1.7.0"

DefaultGoZeroVersion defines the default version of go zero for migrate

View Source
const DefaultToolVersion = "v1.7.0"

DefaultToolVersion defines the default version of simple admin tools for migrate

View Source
const GoctlsVersion = "v1.8.6"

GoctlsVersion is goctls version

View Source
const LangEnvKey = "SIMPLE_LANG"

LangEnvKey is the environment variable name to control the tools help info language

Variables

View Source
var OldGoZeroVersion = []string{"v1.6.0", "v1.6.1", "v1.6.2", "v1.6.3", "v1.6.4", "v1.6.5", "v1.6.6"}

OldGoZeroVersion defines the old version of go zero for update

Functions

This section is empty.

Types

type Config

type Config struct {
	// NamingFormat is used to define the naming format of the generated file name.
	// just like time formatting, you can specify the formatting style through the
	// two format characters go, and zero. for example: snake format you can
	// define as go_zero, camel case format you can it is defined as goZero,
	// and even split characters can be specified, such as go#zero. in theory,
	// any combination can be used, but the prerequisite must meet the naming conventions
	// of each operating system file name.
	// Note: NamingFormat is based on snake or camel string
	NamingFormat string `yaml:"namingFormat"`
}

Config defines the file naming style

func NewConfig

func NewConfig(format string) (*Config, error)

NewConfig creates an instance for Config

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL