toolkit

package module
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 11 Imported by: 0

README

Toolkit

A simple example of how to create a reusable Go module with commonly used tools.

The included tools are:

  • Read JSON
  • Write JSON
  • Produce a JSON encoded error response
  • Upload a file to a specified directory
  • Download a static file
  • Get a random string of length n
  • Post JSON to a remote service
  • Create a directory, including all parent directories, if it does not already exist
  • Create a URL safe slug from a string

Installation

go get -u github.com/akash-codes93/toolkit

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MerkelNode added in v2.1.0

type MerkelNode struct {
	HashValue string
	FileName  string
	Left      *MerkelNode
	Right     *MerkelNode
}

fields hasto be capital

func (*MerkelNode) IsLeaf added in v2.1.0

func (m *MerkelNode) IsLeaf() bool

type Tools

type Tools struct {
	MaxFileSize        int
	AllowedFileTypes   []string
	MAXJSONSize        int
	AllowUnknownFields bool
}

func (*Tools) CreateDirIfNotExists

func (t *Tools) CreateDirIfNotExists(path string) error

create a dir if not exists and create all the necessary parents

func (*Tools) FindChangesInFolder added in v2.1.0

func (t *Tools) FindChangesInFolder(path string) ([]string, error)

gives the list of files that have changed in a folder

func (*Tools) RandomString

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

generates a random string og length n, using randomSourceString

func (*Tools) Slugify

func (t *Tools) Slugify(s string) (string, error)

slugify function enables you to generate a slug from a string

func (*Tools) UploadedFiles

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

type UploadedFile

type UploadedFile struct {
	NewFileName      string
	OriginalFileName string
	FileSize         int64
}

uploaded file is a struct used to save information.

Jump to

Keyboard shortcuts

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