Documentation ¶
Index ¶
- Constants
- func Clean(category string) error
- func CreateIfNotExist(file string) (*os.File, error)
- func CreateTemplate(category, name, content string) error
- func FileExists(file string) bool
- func FileNameWithoutExt(file string) string
- func FindGoModPath(dir string) (string, bool)
- func FindProjectPath(loc string) (string, bool)
- func GetGoctlHome() (string, error)
- func GetHead(source string) string
- func GetTemplateDir(category string) (string, error)
- func Index(slice []string, item string) int
- func InitTemplates(category string, templates map[string]string) error
- func JoinPackages(pkgs ...string) string
- func LoadTemplate(category, file, builtin string) (string, error)
- func MkdirIfNotExist(dir string) error
- func PathFromGoSrc() (string, error)
- func RemoveIfExist(filename string) error
- func RemoveOrQuit(filename string) error
- func Title(s string) string
- func Untitle(s string) string
- type DefaultTemplate
Constants ¶
const (
NL = "\n"
)
NL defines a new line
Variables ¶
This section is empty.
Functions ¶
func CreateIfNotExist ¶
CreateIfNotExist creates a file if it is not exists
func CreateTemplate ¶
CreateTemplate writes template into file even it is exists
func FileExists ¶
FileExists returns true if the specified file is exists
func FileNameWithoutExt ¶
FileNameWithoutExt returns a file name without suffix
func FindGoModPath ¶
FindGoModPath returns the path in project where has file go.mod, it maybe return 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 GetGoctlHome ¶
GetGoctlHome 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 GetGoctlHome
func InitTemplates ¶
InitTemplates creates template files GoctlHome where could get it by GetGoctlHome
func JoinPackages ¶
JoinPackages calls strings.Join and returns
func LoadTemplate ¶
LoadTemplate gets template content by the specified file
func MkdirIfNotExist ¶
MkdirIfNotExist makes directories if the input path is not exists
func PathFromGoSrc ¶
PathFromGoSrc returns the path without slash where has been trim the prefix $GOPATH
func RemoveIfExist ¶
RemoveIfExist deletes the specified file if it is exists
func RemoveOrQuit ¶
RemoveOrQuit deletes the specified file if read a permit command from stdin
Types ¶
type DefaultTemplate ¶
type DefaultTemplate struct {
// contains filtered or unexported fields
}
DefaultTemplate is a tool to provides the text/template operations
func (*DefaultTemplate) Execute ¶
func (t *DefaultTemplate) Execute(data interface{}) (*bytes.Buffer, error)
Execute returns the codes after the template executed
func (*DefaultTemplate) GoFmt ¶
func (t *DefaultTemplate) GoFmt(format bool) *DefaultTemplate
GoFmt sets the value to goFmt and marks the generated codes will be formatted or not
func (*DefaultTemplate) Parse ¶
func (t *DefaultTemplate) Parse(text string) *DefaultTemplate
Parse accepts a source template and returns DefaultTemplate
Directories ¶
Path | Synopsis |
---|---|
Package name provides methods to verify naming style and format naming style See the method IsNamingValid, FormatFilename
|
Package name provides methods to verify naming style and format naming style See the method IsNamingValid, FormatFilename |