Skip to content

Releases: cowoder/go-utils

Update path declaration

30 Jan 12:36
324b7bb

Choose a tag to compare

Updated the module path declaration

Initial release

07 Jan 20:25
8346e0d

Choose a tag to compare

// RandomString generates a random string of the specified length.
func (u *Utils) RandomString(length int) string {
	// implementation...
}

// UploadFiles uploads multiple files from a HTTP request to the specified directory.
func (u *Utils) UploadFiles(r *http.Request, uploadDir string, rename ...bool) ([]*UploadedFile, error) {
	// implementation...
}

// UploadFile uploads a single file from a HTTP request to the specified directory.
func (u *Utils) UploadFile(r *http.Request, uploadDir string, rename ...bool) (*UploadedFile, error) {
	// implementation...
}

// CreateDirIfNotExists creates a directory if it does not already exist.
func (u *Utils) CreateDirIfNotExists(dir string) error {
	// implementation...
}

// Slugify converts a text string into a URL-friendly slug.
func (u *Utils) Slugify(text string) (string, error) {
	// implementation...
}

// CtrlC listens for a Ctrl+C signal and executes the specified shutdown processes.
func (u *Utils) CtrlC(shutdownProcesses ...func()) {
	// implementation...
}

// DownloadStaticFile downloads a file and forces the browser to download it.
func (u *Utils) DownloadStaticFile(w http.ResponseWriter, r *http.Request, p string, file string, displayName string) {
	// implementation...
}

// ReadJSON reads and parses JSON data from a HTTP request.
func (u *Utils) ReadJSON(w http.ResponseWriter, r *http.Request, data interface{}) error {
	// implementation...
}

// WriteJSON writes JSON data to a HTTP response.
func (u *Utils) WriteJSON(w http.ResponseWriter, status int, data interface{}, headers ...http.Header) error {
	// implementation...
}

// ErrorJSON writes an error message as JSON to a HTTP response.
func (u *Utils) ErrorJSON(w http.ResponseWriter, err error, status ...int) error {
	// implementation...
}

// PushJSONToRemote sends JSON data to a remote server via HTTP POST request.
func (u *Utils) PushJSONToRemote(uri string, data interface{}, client ...*http.Client) (*http.Response, int, error) {
	// implementation...
}