celeritas

package module
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

README

Celeritas

This repo and package are for the Let's Build a Go version of Laravel course on Udemy.

I created a full package because I was having trouble with the go get command. I wanted to make sure that the package was available to everyone.

Documentation

Index

Constants

View Source
const (
	// Version is the current version of the Celeritas framework.
	Version = "1.0.0"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Celeritas

type Celeritas struct {
	AppName  string
	Debug    bool
	Version  string
	ErrorLog *log.Logger
	InfoLog  *log.Logger
	RootPath string
	Routes   *chi.Mux
	Render   *render.Render
	// contains filtered or unexported fields
}

Celeritas is the main struct for the Celeritas framework.

func (*Celeritas) CreateDirIfNotExist

func (c *Celeritas) CreateDirIfNotExist(path string) error

CreateDirIfNotExist is a method on the Celeritas struct. It checks if a directory at the provided path exists. If the directory does not exist, it creates the directory with the specified mode. The mode is set to 0755, which means the owner can read, write, and execute, while others can read and execute but not write.

Parameters: path: A string representing the path of the directory to check or create.

Returns: If the directory exists or is successfully created, it returns nil. If there is an error creating the directory, it returns the error.

func (*Celeritas) CreateFileIfNotExist

func (c *Celeritas) CreateFileIfNotExist(path string) error

CreateFileIfNotExist is a method on the Celeritas struct. It checks if a file at the provided path exists. If the file does not exist, it creates the file with the specified mode. The mode is set to 0644, which means the owner can read and write, while others can only read.

Parameters: path: A string representing the path of the file to check or create.

Returns: If the file exists or is successfully created, it returns nil. If there is an error creating the file, it returns the error.

func (*Celeritas) Init

func (c *Celeritas) Init(p initPaths) error

Init initializes the directory structure for a Celeritas project. It takes an initPaths struct as an argument which contains the root path and the names of the folders to be created. It iterates over the folder names, and for each one, it calls the CreateDirIfNotExist method. If the CreateDirIfNotExist method returns an error, it immediately returns this error. If no errors occur during the folder creation, it returns nil.

func (*Celeritas) ListenAndServe added in v1.0.3

func (c *Celeritas) ListenAndServe()

ListenAndServe starts the HTTP server and listens for incoming requests. It configures the server with the provided settings and routes, and logs any errors that occur during server startup or shutdown.

func (*Celeritas) New

func (c *Celeritas) New(rootPath string) error

New creates the initial directory structure for a new Celeritas project.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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