libgosimpleton

package module
v0.0.0-...-6244057 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2018 License: AGPL-3.0 Imports: 1 Imported by: 0

README

libgosimpleton

libgosimpleton is a library for functionality i commonly use.

old description: a minimalistic library for simpletons like me that don't wanna reserve memory in their minds for stuff like:

copy(a[i:], a[j:])
for k, n := len(a)-j+i, len(a); k < n; k ++ {
       a[k] = s.empty
}
a = a[:len(a)-j+i]

PARALLEL

Do some work in parallel:

work, count := parallel.NewWorkManual(16), 0
work.Do(func() {
	work.Lock()
	count++
	work.Unlock()
})

println(count) // prints 16

Open a file, read in one thread do your function in another thread:

work := OpenFileDoWork(helper, path, func(buffered *NamedBuffer) {
	into := make([]byte, 512)
	for {
		println("reading " + buffered.Name())
		read, e := buffered.Read(into); if e != nil { /* handle errors and EOF */ }
 		/* do work */
	}
})

work.Wait()

hash files, print to Stdout

OpenFilesFromListDoWork(helper, func(buffered *iotool.NamedBuffer) {
	hasher := sha256.New()
	io.Copy(hasher, buffered)
	println(hex.EncodeToString(hasher.Sum(nil)))	
}, path1, path2, paths...).Wait()

IOTOOL

Functions for io. Open files with a helper capable of doing file advice. This also makes opening files clearer compared to os.Open in the standard library.

helper := iotool.ReadOnly().FileAdviceReadSequential()
handler, e := iotool.Open(helper, "filename")

SLICES

run MAKE_SLICES.sh to make slices.

CREDENTIALS

credentials library (and credentialstool) for editing user and password infrastructure. currently unix (/etc/shadow) and sql is implemented (not fully in credentialstool).

LICENCE

see LICENCE

Documentation

Index

Constants

View Source
const (
	DEBUG = false

	// global setting for FADVICE_DONTNEED before reading
	SET_FILE_ADVICE_DONTNEED = true
)
View Source
const (
	// only changes with major changes
	MAJOR_VERSION = "0"

	// new features, maybe incompatible changes
	MINOR_VERSION = "3"

	// no incompatible changes, just bug fixes
	BUGFIX_VERSION = "0"

	// munchies
	VERSION = MAJOR_VERSION + "." + MINOR_VERSION + "." + BUGFIX_VERSION

	// should one be using this
	FROM_MASTER = true
)

Variables

This section is empty.

Functions

func Version

func Version()

Types

This section is empty.

Jump to

Keyboard shortcuts

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