utils

package
v0.0.0-...-f8139d8 Latest Latest
Warning

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

Go to latest
Published: May 2, 2018 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package utils - additional supplementary functions.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func CliArgumentsList

func CliArgumentsList(osArgs []string) (arguments []string, options []string)

CliArgumentsList - return clean list of arguments and options

Example
args, options := CliArgumentsList(
	[]string{"cfy-go", "status", "-user", "admin"})
fmt.Printf("Args: %v, Options: %v.", args, options)
Output:

Args: [cfy-go status], Options: [-user admin].

func CliSubArgumentsList

func CliSubArgumentsList(osArgs []string) (arguments []string, options []string)

CliSubArgumentsList - return clean list of arguments and options

Example
args, options := CliSubArgumentsList([]string{
	"-data", "container-place/data", "-work-dir", "container-place/",
	"--", "cfy", "profile", "use", "local"})
fmt.Printf("Args: %v, Options: %v.", args, options)
Output:

Args: [-data container-place/data -work-dir container-place/], Options: [cfy profile use local].

func DirZipArchive

func DirZipArchive(paths []string) ([]byte, error)

DirZipArchive - create archive from directory and return as bytes array

func InList

func InList(source []string, value string) bool

InList - return true if string is already in list

Example
if !InList([]string{"a", "b"}, "c") {
	fmt.Print("'c' not in ['a', 'b'] list.")
}
Output:

'c' not in ['a', 'b'] list.

func PrintTable

func PrintTable(titles []string, lines [][]string)

PrintTable - print table with column titles and several lines

Example
PrintTable([]string{"1", "2", "3"}, [][]string{{"a", "-b", "c"}, {"d", "e", "-f-"}})
Output:

+---+----+-----+
| 1 | 2  | 3   |
+---+----+-----+
| a | -b | c   |
| d | e  | -f- |
+---+----+-----+

func ZipAttachDir

func ZipAttachDir(w *zip.Writer, currentPath string) error

ZipAttachDir - attach directory to zip archive

func ZipAttachFile

func ZipAttachFile(w *zip.Writer, zipFileName, fullPath string) error

ZipAttachFile - attach file to zip

Types

This section is empty.

Jump to

Keyboard shortcuts

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