toolkit

package module
v0.0.0-...-1ff1beb Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: MIT Imports: 10 Imported by: 0

README

Toolbox

Some examples of a reusable module from the course on Go modules.

Included tools:

  • Read JSON
  • Write JSON
  • Produce JSON encoded error messages
  • Upload files
  • Download file
  • Generate random string of length n
  • Post JSON to remove service
  • Create dir, with parent dirs if they don't exist
  • Create URL safe slug

Installation

go get -u https://github.com/sanjib/tsawler-toolkit

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RandomString

func RandomString(n int) string

RandomString generates a base32 random string of n size.

Types

type Tools

type Tools struct {
	MaxFileSize      int
	AllowedFileTypes []string
}

Tools is the type that allows access to its various utility methods.

func (*Tools) RandomString

func (t *Tools) RandomString(n int) string

RandomString generates a random string from randomStringSource of n size.

func (*Tools) UploadFiles

func (t *Tools) UploadFiles(r *http.Request, uploadDir string, rename ...bool) ([]UploadedFile, error)

type UploadedFile

type UploadedFile struct {
	NewFileName      string
	OriginalFileName string
	FileSize         int64
}

UploadedFile save information about the file to send back to user.

Jump to

Keyboard shortcuts

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