utils

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTemplatePlaceholdersNotFound = errors.New("placeholders not found in template")
	ErrDelimitersNotPassed          = errors.New("delimiters did not passed")
	ErrBadTemplate                  = errors.New("can't open template file, it's broken")
	ErrPlaceholderWithWhitespaces   = errors.New("some placeholders template has leading or tailing whitespace")
)

Functions

func CompareSlicesAsSets added in v0.3.5

func CompareSlicesAsSets[T comparable](x, y []T) bool

Compare two slice without ordering

func CompressFiles

func CompressFiles(filenames []string, resultFilename string) error

func FindPlaceholders added in v0.3.5

func FindPlaceholders(templateBytes []byte, leftDelimiter string, rightDelimiter string) ([]string, error)

FindPlaceholders finds all placeholders inside of given docx file (as byte slice). Takes delimiter regex pattern. For example if placeholder is "{{my_key}}", then pattern would be "{{.*}}" If given pattern is empty string then func would use default pattern "{.*}".

Returns found placeholders as a string slice. Returns error: - If there were no placeholders - If given byte slice is not a valid docx file - If placeholders have leading or tailing whitespace inside of placeholder (like `{ key}`, `{key }` or `{ key }`)

func StreamToBytes added in v0.2.0

func StreamToBytes(stream io.Reader) ([]byte, error)

func UniqueStringSlice added in v0.3.5

func UniqueStringSlice(strings []string) []string

Types

This section is empty.

Jump to

Keyboard shortcuts

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