utils

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

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

Go to latest
Published: Jun 13, 2018 License: GPL-3.0 Imports: 17 Imported by: 2

README

Utils - Collection of simple GOLANG functions

utils is a simple GO module with a collection of functions to simplify some tasks.

Contribution

Feel free to use it and contribute if few features are missing for you. Follow the usual Pull Request mechanism of Github to submit code or issues to discuss.

Forj Team

Documentation

Index

Constants

View Source
const RepoTag = "<repo>"

PluginTag to identify variable component name in a Document path.

Variables

This section is empty.

Functions

func Abs

func Abs(name string) (string, error)

Abs returns an absolute path

It expands ~ to $HOME
If path is already absolute, it cleans up (shortest path).
If the path is relative, it adds current directory to create it as absolute path

func ArrayStringDelete

func ArrayStringDelete(a []string, element string) []string

func BuildURLPath

func BuildURLPath(aPath, repo, subpath, document string) (fullFileName string)

BuildURLPath build the path logic introducing the pluginTag to replace.

func DefColor

func DefColor(colorNum int) (color, reset string)

func Evaluate

func Evaluate(value string, tmpl *template.Template, data interface{}, funcs template.FuncMap) (_ string, _ error)

func InStringList

func InStringList(element string, elements ...string) string

func ReadDocumentFrom

func ReadDocumentFrom(urls []*url.URL, repos, subPaths []string, document, contentType string) ([]byte, error)

ReadDocumentFrom is used to read a document from a url like github raw or directly from a local path It supports file or url stored in url.URL structure each urls can be defined with a plugin tag "<plugin>" which will be replaced by the document name(document) the file name and the extension is added at the end of the string.

func RunCmd

func RunCmd(command string, args ...string) int

RunCmd is a simple function to call a shell command and display to stdout stdout is displayed as is when it arrives, while stderr is displayed in Red, line per line.

func RunCmdOutput

func RunCmdOutput(command string, args ...string) (string, int)

RunCmdOutput run a command and return the standard output as result. stderr is displayed in Red, line per line.

func Touch

func Touch(file string) error

Types

type MLoop

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

func NewMLoop

func NewMLoop(max ...int) (ml *MLoop)

func (*MLoop) Cur

func (ml *MLoop) Cur() (_ []int)

func (*MLoop) Eol

func (ml *MLoop) Eol() bool

func (*MLoop) Increment

func (ml *MLoop) Increment() (_ []int)

Jump to

Keyboard shortcuts

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