Documentation ¶
Index ¶
- Constants
- func CreateCA(c, o, ou, cn string, caPemFile, caKeyFile string) (err error)
- func CreateCSR(c, o, ou, cn string, csrFile, keyFile string) (err error)
- func CreateCert(c, o, ou, cn string, caPemFile, caKeyFile, csrFile, crtFile, keyFile string, ...) (err error)
- func DoWriteFile(tmplStr string, params interface{}, absFile string, opts *DoWriteFileOption) (err error)
- func Gen(projectDir, projectName string) (err error)
- func GenCert(baseDir string, caPubFile, caKeyFile, csrFile, crtFile, keyFile string, ...) (err error)
- func GenFile(baseDir string, fileConfig *ProjectFileType) (err error)
- func GenerateSubjectKeyID(pub crypto.PublicKey) ([]byte, error)
- func GetTmpl(tmplName string) (tmplStr string, err error)
- func InitGenConfig() (err error)
- func Mkdir(absDir string) (err error)
- func ParseOptionMethodPath(opt *options.HttpRule) (method, path_ string, err error)
- func ParsePB()
- func ParseRequest(r io.Reader) (*plugin.CodeGeneratorRequest, error)
- type DoWriteFileOption
- type Option
- type ProjectFileType
- type RpcInfo
- type TemplateParams
Constants ¶
View Source
const ( //配置的类型 TemplateConfigFlagNone = 0 TemplateConfigFlagFile = 1 TemplateConfigFlagDir = 2 TemplateConfigFlagIyfiysi = 4 TemplateConfigFlagProtoc = 8 TemplateConfigFlagCopy = 16 //直接复制,没有这个标识代表使用模板复制 )
Variables ¶
This section is empty.
Functions ¶
func CreateCert ¶
func CreateCert(c, o, ou, cn string, caPemFile, caKeyFile, csrFile, crtFile, keyFile string, dnsName []string, expireDay int) (err error)
项目的证书
func DoWriteFile ¶
func DoWriteFile(tmplStr string, params interface{}, absFile string, opts *DoWriteFileOption) (err error)
DoWriteFile 生成模板并且写入文件
func Gen ¶
Gen 根据配置生成项目文件 projectDir 项目的目录,格式为:[pre/dir/path/]domain.com,例如:/a/b/c/google.com/ projectName 项目名称,格式为字符串
func GenCert ¶
func GenCert( baseDir string, caPubFile, caKeyFile, csrFile, crtFile, keyFile string, country, organization, organizationalUnit, commonName string, dnsName []string, expireDays int) (err error)
GenCert 生成证书
func GenFile ¶
func GenFile(baseDir string, fileConfig *ProjectFileType) (err error)
GenFile 根据模板,生成文件 baseDir: 举例:/data/go_path/src/github.com/app templateFile: init.go.tmpl dstFile: internal/pkg/utils/init.go
func GenerateSubjectKeyID ¶
GenerateSubjectKeyID generates SubjectKeyId used in Certificate Id is 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey
func InitGenConfig ¶
func InitGenConfig() (err error)
InitGenConfig 初始化生成配置,其实主要是将template/template.yaml的配置读进viper里面
func ParseOptionMethodPath ¶
func ParseRequest ¶
func ParseRequest(r io.Reader) (*plugin.CodeGeneratorRequest, error)
ParseRequest parses a code generator request from a proto Message.
Types ¶
type DoWriteFileOption ¶
type DoWriteFileOption struct { DoFormat bool //是否做格式化,true:yes Delims string //模板分隔符,如果是空,则默认为{{}} }
DoWriteFileOption 写入文件时候,带的参数
func NewDoWriteFileOption ¶
func NewDoWriteFileOption(opts ...Option) *DoWriteFileOption
NewDoWriteFileOption 新建一个DoWriteFileOption格式的option
type ProjectFileType ¶
type ProjectFileType struct { ID string `json:"id"` //id Flag int `json:"flag"` //类型,TemplateConfigType*,标识(比特组合),0:none,1:文件类型,2:目录类型,4:给iyfiysi使用,8:给protoc-gen-iyfiysi使用 Name string `json:"name"` //名称 Desc string `json:"desc"` //描述 Src string `json:"src"` //对应哪个template文件 Delims string `json:"delims"` //template文件对应的分割符,空代表使用默认的 Dst string `json:"dst"` //生成之后放在那个文件 Params map[string]interface{} `json:"params"` //参数,kv格式 }
ProjectFileType 项目文件结构
Click to show internal directories.
Click to hide internal directories.