sanitize

package module
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2020 License: MIT Imports: 6 Imported by: 0

README

sanitize

sanitize file name

Installation

go get github.com/prajaraksh/sanitize

Usage

str := "   ..  ..  ..CON .. .. "

s := sanitize.New()
nv := s.Name(str)  // "   ..  ..  ..CON"
cv := s.Clean(str) // " . . .CON"

Sanitize - CMD

Installation
go get github.com/prajaraksh/sanitize/cmd/sanitize
Usage
sanitize # print intended file name changes
sanitize -r # print intended file name changes recursively

sanitize -c # change intended file names
sanitize -c -r # change intended file names recursively

Documentation

Overview

Package sanitize goal is to have same fileName irrespective of platform. Incase of invalid fileName, a md5Sum of provided file is returned

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCntrl represents `replaceStr` contains Control Characters
	ErrCntrl = errors.New("replaceStr can't contain control characters")
	// ErrInval represents `replaceStr` contains Invalid Characters
	ErrInval = errors.New("replaceStr can't contain ., <, >, :, \", /, \\, |, ?, *")

	// ErrLen represents `maxLen` is greater than 255
	ErrLen = errors.New("maxLen can't be greater than 255")
)

Functions

This section is empty.

Types

type Sanitize

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

Sanitize struct

func New

func New() *Sanitize

New returns Sanitize

func NewWithOpts

func NewWithOpts(replaceStr string, maxLen int) (*Sanitize, error)

NewWithOpts returns Sanitize with opts set Certain conditions exist for replace Str and

func (*Sanitize) Clean

func (s *Sanitize) Clean(fileName string) string

Clean sanitizes ,removes invisible characters and repeated separators

func (*Sanitize) Name

func (s *Sanitize) Name(fileName string) string

Name sanitizies `fileName`

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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