comm

package
v0.0.0-...-019d37c Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2021 License: BSD-3-Clause, MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//配置的类型
	TemplateConfigFlagNone    = 0
	TemplateConfigFlagFile    = 1
	TemplateConfigFlagDir     = 2
	TemplateConfigFlagIyfiysi = 4
	TemplateConfigFlagProtoc  = 8
	TemplateConfigFlagCopy    = 16 //直接复制,没有这个标识代表使用模板复制
)

Variables

This section is empty.

Functions

func CreateCA

func CreateCA(c, o, ou, cn string, caPemFile, caKeyFile string) (err error)

项目的签发证书

func CreateCSR

func CreateCSR(c, o, ou, cn string, csrFile, keyFile string) (err error)

项目的csr

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

func Gen(projectDir, projectName string) (err error)

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

func GenerateSubjectKeyID(pub crypto.PublicKey) ([]byte, error)

GenerateSubjectKeyID generates SubjectKeyId used in Certificate Id is 160-bit SHA-1 hash of the value of the BIT STRING subjectPublicKey

func GetTmpl

func GetTmpl(tmplName string) (tmplStr string, err error)

GetTmpl 获取模板内容 tmplName 是一个模板文件名(不包含目录)

func InitGenConfig

func InitGenConfig() (err error)

InitGenConfig 初始化生成配置,其实主要是将template/template.yaml的配置读进viper里面

func Mkdir

func Mkdir(absDir string) (err error)

func ParseOptionMethodPath

func ParseOptionMethodPath(opt *options.HttpRule) (method, path_ string, err error)

func ParsePB

func ParsePB()

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 Option

type Option func(msg *DoWriteFileOption)

Option 选项内容

func DoDelims

func DoDelims(delim string) Option

DoDelims 选项-分隔符

func DoFormat

func DoFormat() Option

DoFormat 选项-格式化

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 项目文件结构

type RpcInfo

type RpcInfo struct {
	ServiceName  string
	RpcName      string
	RequestName  string
	ResponseName string
	Methods      []string
	Paths        []string
}

func (*RpcInfo) String

func (this *RpcInfo) String() string

type TemplateParams

type TemplateParams struct {
	CreateTime time.Time //创建时间
	Domain     string    //域名
	AppName    string    //App名称
	Param1     string    //额外的
}

TemplateParams 模板参数

Jump to

Keyboard shortcuts

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