Documentation ¶
Index ¶
- Constants
- func CopyFile(src string, dest string) (int64, error)
- func CreateFile(fileName string, content string) (int, error)
- func GetCurrentModulePath() (string, error)
- func GetGOPATH() string
- func GetGoModule(modulePath string) (*module.Version, error)
- func IsDirExists(path string) bool
- type File
- type GoProjectStructureGenerator
Constants ¶
const ( SrcDirectory = "src" AssetsDirectory = "assets" ReadmeMD = "README.md" Module = "module" ProjectModuleName = "github.com/xkmsoft/go-project-structure-generator" )
Variables ¶
This section is empty.
Functions ¶
func CopyFile ¶
CopyFile copies the file from the src into des. It returns the number of bytes copied and error if anything goes wrong
func CreateFile ¶ added in v0.1.1
CreateFile simply creates file from given filename and content. It returns the number of bytes written and error
func GetCurrentModulePath ¶ added in v0.1.1
GetCurrentModulePath returns the current project's module path
func GetGoModule ¶ added in v0.1.1
GetGoModule reads and parses the go.mod file and returns the go module path and its version if the desired module name is found in the file
func IsDirExists ¶
IsDirExists simply checks whether a directory exists or not
Types ¶
type GoProjectStructureGenerator ¶
type GoProjectStructureGenerator struct { ModuleName string Directories map[string][]string AdditionalDirectories map[string][]File ModuleFiles []string Permission os.FileMode }
GoProjectStructureGenerator represents the necessary data types to generate standard go project structure
func NewGoProjectStructureGenerator ¶
func NewGoProjectStructureGenerator(moduleName string) *GoProjectStructureGenerator
NewGoProjectStructureGenerator returns new *GoProjectStructureGenerator with provided project name
func (*GoProjectStructureGenerator) Generate ¶
func (g *GoProjectStructureGenerator) Generate() error
Generate simply generates the project structure on the following path GOPATH/src/<provided-project-name> And copies all the README.md files from the assets directory into the project directory
func (*GoProjectStructureGenerator) GetAssetDirectory ¶ added in v0.1.1
func (g *GoProjectStructureGenerator) GetAssetDirectory() (string, error)
GetAssetDirectory returns the asset directory of the project or a non-nil error if anything goes wrong.