builder

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2025 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFolderPermission os.FileMode = 0755
	DefaultFilePermission   os.FileMode = 0644
)

Define default permissions as constant for clarity Default permission 0755 (Owner: rwx, Group/Others: r-x) Fefault permission 0644 (Owner: read/write, Group/Others: read only)

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSystem

type FileSystem interface {
	CreateFolder(path string, permission os.FileMode) error
	WriteFile(path string, content []byte, permission os.FileMode) error
}

type OSFileSystem

type OSFileSystem struct{}

func NewOSFileSystem

func NewOSFileSystem() *OSFileSystem

func (*OSFileSystem) CreateFolder

func (o *OSFileSystem) CreateFolder(folderPath string, permission os.FileMode) error

Common Folder Permissions: 0755 → Owner: read/write/execute | Group: read/execute | Others: read/execute 0700 → Owner: read/write/execute | Group: no access | Others: no access 0777 → Everyone: read/write/execute (!! usually not recommended for security !!)

Common File Permissions (for reference): 0644 → Owner: read/write | Group: read | Others: read 0600 → Owner: read/write | Group: no access | Others: no access 0755 → Owner: read/write/execute | Group: read/execute | Others: read/execute (for executable files)

Octal Permission Breakdown:

0 = --- (no permission)
1 = --x (execute)
2 = -w- (write)
3 = -wx (write and execute)
4 = r-- (read)
5 = r-x (read and execute)
6 = rw- (read and write)
7 = rwx (read, write, and execute)

Format: 0<Owner><Group><Others> (each digit is a sum of r=4, w=2, x=1) Note: Permissions are based on standard UNIX file mode bits, stable across Go versions.

CreateFolder creates a folder

func (*OSFileSystem) WriteFile

func (o *OSFileSystem) WriteFile(path string, content []byte, permission os.FileMode) error

WriteFile ensures the parent directory exists, then creates or truncates the file at path and writes the provided content with the specified permission.

type StructureBuilder

type StructureBuilder struct {
	// contains filtered or unexported fields
}

StructureBuilder builds a project scaffold.

func NewStructureBuilder

func NewStructureBuilder(fs FileSystem) *StructureBuilder

func (*StructureBuilder) Build

func (b *StructureBuilder) Build(cfg *config.Config, root string) error

Build uses the Config's Structure tree to instantiate folders & files under root.

Jump to

Keyboard shortcuts

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