concatenate

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2016 License: MIT Imports: 8 Imported by: 1

README

go-concatenate Build Status Report

golang concatenate package and cli with focus on speed.

Cli Usage

install the commandline tool

go get github.com/paulvollmer/go-concatenate/bin/concat

concatenate files

concat target.src file1.src file2.src

Usage

go get github.com/paulvollmer/go-concatenate

install "github.com/paulvollmer/go-concatenate"

data := concatenate.StringsToString("-", "hello", "world")
data, err := concatenate.FilesToBytes("\n", "foo.txt", "bar.txt")

License

Licensed under MIT-License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToBytes

func BytesToBytes(del []byte, src ...[]byte) []byte

BytesToBytes concatenate a list of bytes by the given delimiter

func FilesToBytes

func FilesToBytes(del string, src ...string) ([]byte, error)

FilesToBytes concatenate a list of files by the given delimiter. you can set a matching pattern to select the sources you want to process.

func FilesToFile

func FilesToFile(filename string, perm os.FileMode, del string, src ...string) error

FilesToFile concatenate a list of files by the given delimiter

func StringsToString

func StringsToString(del string, src ...string) string

StringsToString concatenate a list of strings by the given delimiter

Types

type Config

type Config map[string]Sources

Config store a map of sources to concatenate.

func NewConfig

func NewConfig() *Config

NewConfig return a new Config element

func (Config) AddSet

func (c Config) AddSet(name string, src ...string) error

AddSet a new set (the name) and its sources (the filepaths) to the config.

func (Config) ExistSource

func (c Config) ExistSource(src string) bool

ExistSource return true i the given source was found at the sets

func (Config) TotalFiles

func (c Config) TotalFiles() (int, error)

TotalFiles return the number of files

func (Config) TotalFilesInSet

func (c Config) TotalFilesInSet(name string) (int, error)

TotalFilesInSet return the number of files of a sepcific set

func (Config) TotalSets

func (c Config) TotalSets() int

TotalSets return the number of total sets

type Manager

type Manager struct {
	Config Config
}

Manager create a manager to organize the source files and process the data.

func NewManager

func NewManager() *Manager

NewManager return a new Manager element

func (*Manager) GetDirs

func (m *Manager) GetDirs() ([]string, error)

GetDirs return a list of all target directories

func (*Manager) GetDirsOfSources

func (m *Manager) GetDirsOfSources() []string

GetDirsOfSources return a list of all source directories

func (*Manager) Process

func (m *Manager) Process(filename string, perm os.FileMode) error

Process a given set

func (*Manager) ProcessAll

func (m *Manager) ProcessAll(perm os.FileMode) error

ProcessAll run the Process func at all sets

func (*Manager) ReadConfig

func (m *Manager) ReadConfig(filename string) error

ReadConfig reads a json configuration file and set the data to the Config variable

type Sources

type Sources []string

Sources store a list of source paths

func NewSources

func NewSources() *Sources

NewSources return a new Sources element

func (*Sources) Add

func (s *Sources) Add(src string) error

Add a filepath to the Sources array. if src is an empty string or already exist, return an error.

func (*Sources) AddSources

func (s *Sources) AddSources(src ...string) error

AddSources add a list of sources to the array

func (*Sources) ExistSource

func (s *Sources) ExistSource(src string) bool

ExistSource return true i the given source was found at the sets

func (Sources) Get

func (s Sources) Get(i int) (string, error)

Get the source of the given index

func (*Sources) GetAllDirs

func (s *Sources) GetAllDirs() ([]string, error)

GetAllDirs get dir and get all dirs

func (*Sources) GetAllFilepaths

func (s *Sources) GetAllFilepaths() ([]string, error)

GetAllFilepaths return a list of all filepaths

func (Sources) GetFilepaths

func (s Sources) GetFilepaths(i int) ([]string, error)

GetFilepaths return a list of filepaths for the given source. if the source is a glob, the function return all matched paths.

func (*Sources) Total

func (s *Sources) Total() int

Total return the total number of sources

Directories

Path Synopsis
bin

Jump to

Keyboard shortcuts

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