Documentation ¶
Index ¶
- Constants
- func Clean(category string) error
- func Copy(src, dest string) error
- func CreateDirectoryIfNotExist(path string) error
- func CreateFileIfNotExist(path string) (*os.File, error)
- func CreateTemplate(category, name, content string) error
- func FileExists(file string) bool
- func FindGoModPath(dir string) (string, bool)
- func FindProjectPath(loc string) (string, bool)
- func GetCacheDir() (string, error)
- func GetCtlHome() (home string, err error)
- func GetDefaultCtlHome() (string, error)
- func GetGitHome() (string, error)
- func GetTemplateDir(category string) (string, error)
- func InitTemplates(category string, templates map[string]string) error
- func IsTemplateVariable(text string) bool
- func JoinPackages(pkgs ...string) string
- func LoadTemplate(category, file, builtin string) (string, error)
- func MaybeCreateFile(dir, subdir, file string) (fp *os.File, created bool, err error)
- func MkdirIfNotExist(dir string) error
- func NewFileBuild(tp *TemplateData, filePath string) error
- func PathFromGoSrc() (string, error)
- func ReadLink(name string) (string, error)
- func RegisterGoctlHome(home string)
- func SameFile(path1, path2 string) (bool, error)
- func TemplateVariable(text string) string
- type RpcMethod
- type TemplateData
- func (this *TemplateData) ExtractRPCMethods() []RpcMethod
- func (this *TemplateData) Parse() (*template.Template, error)
- func (this *TemplateData) SetFieldName(s string) *TemplateData
- func (this *TemplateData) SetModelName(s string) *TemplateData
- func (this *TemplateData) SetModelPath(s string) *TemplateData
- func (this *TemplateData) SetPackage(s string) *TemplateData
- func (this *TemplateData) SetProtoName(s string) *TemplateData
- func (this *TemplateData) SetRpcFilePath(s string) *TemplateData
Constants ¶
const (
NL = "\n"
)
const (
RpcServiceFieldPrefix = "Service"
)
Variables ¶
This section is empty.
Functions ¶
func CreateDirectoryIfNotExist ¶
CreateDirectoryIfNotExist 生成目录
func CreateFileIfNotExist ¶
CreateFileIfNotExist 生成文件
func CreateTemplate ¶
CreateTemplate writes template into file even it is exists.
func FileExists ¶
FileExists returns true if the specified file is exists.
func FindGoModPath ¶
FindGoModPath returns the path in project where has file go.mod, it returns empty string if there is no go.mod file in project.
func FindProjectPath ¶
FindProjectPath returns the parent directory where has file go.mod in project
func GetCtlHome ¶
GetCtlHome returns the path value of the goctl, the default path is ~/.goctl, if the path has been set by calling the RegisterGoctlHome method, the user-defined path refers to.
func GetDefaultCtlHome ¶
GetDefaultCtlHome returns the path value of the goctl home where Join $HOME with .goctl.
func GetTemplateDir ¶
GetTemplateDir returns the category path value in GoctlHome where could get it by GetctlHome.
func InitTemplates ¶
InitTemplates creates template files GoctlHome where could get it by GetGoctlHome.
func IsTemplateVariable ¶
IsTemplateVariable 函数会返回 true,如果文本是一个模板变量 文本必须以点号开头,并且是一个有效的模板。
func JoinPackages ¶
JoinPackages calls strings.Join and returns
func LoadTemplate ¶
LoadTemplate gets template content by the specified file.
func MaybeCreateFile ¶
MaybeCreateFile creates file if not exists
func MkdirIfNotExist ¶
MkdirIfNotExist makes directories if the input path is not exists
func NewFileBuild ¶
func NewFileBuild(tp *TemplateData, filePath string) error
NewFileBuild 基于template模板生成文件
func PathFromGoSrc ¶
PathFromGoSrc returns the path without slash where has been trim the prefix $GOPATH
func RegisterGoctlHome ¶
func RegisterGoctlHome(home string)
RegisterGoctlHome register goctl home path.
Types ¶
type TemplateData ¶
type TemplateData struct { Content []byte PackageName string ProtoName string FieldName string ModelPath string ModelName string RpcFilePath string RpcMethods []RpcMethod }
func NewTemplate ¶
func NewTemplate(content []byte) *TemplateData
func (*TemplateData) ExtractRPCMethods ¶
func (this *TemplateData) ExtractRPCMethods() []RpcMethod
func (*TemplateData) SetFieldName ¶
func (this *TemplateData) SetFieldName(s string) *TemplateData
func (*TemplateData) SetModelName ¶
func (this *TemplateData) SetModelName(s string) *TemplateData
func (*TemplateData) SetModelPath ¶
func (this *TemplateData) SetModelPath(s string) *TemplateData
func (*TemplateData) SetPackage ¶
func (this *TemplateData) SetPackage(s string) *TemplateData
func (*TemplateData) SetProtoName ¶
func (this *TemplateData) SetProtoName(s string) *TemplateData
func (*TemplateData) SetRpcFilePath ¶
func (this *TemplateData) SetRpcFilePath(s string) *TemplateData