generator

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
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

func CopyFile(src string, dest string) (int64, error)

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

func CreateFile(fileName string, content string) (int, error)

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

func GetCurrentModulePath() (string, error)

GetCurrentModulePath returns the current project's module path

func GetGOPATH

func GetGOPATH() string

GetGOPATH returns the GOPATH environment variable

func GetGoModule added in v0.1.1

func GetGoModule(modulePath string) (*module.Version, error)

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

func IsDirExists(path string) bool

IsDirExists simply checks whether a directory exists or not

Types

type File added in v0.1.1

type File struct {
	Name    string
	Content string
}

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.

Jump to

Keyboard shortcuts

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