bash

package
v0.0.0-...-549aca6 Latest Latest
Warning

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

Go to latest
Published: May 23, 2022 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Overview

bash package implements simple bash commands that are sometimes useful when writing go scripts

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToBuffer

func BytesToBuffer(reader *GunzipReader) *bytes.Buffer

BytesToBuffer will parse []byte and return a pointer to the same underlying bytes.Buffer

func Cut

func Cut(line string, d byte, f ...int) []string

Cut mimics the basic bash command to cut a column by any delim and returns the fields indices you specify indices start at 0

func DirectorySetUp

func DirectorySetUp(dir string, golang string) *api.Bash

func GetColumnCount

func GetColumnCount(line string, delim byte) int

func LatestGoResource

func LatestGoResource() *api.Bash

func Mkdir

func Mkdir(path string, perm os.FileMode)

Mkdir will create all parent directories of a provided path

func NewPzip

func NewPzip(filename string, data []string)

func ReadLine

func ReadLine(reader *GunzipReader) (*bytes.Buffer, bool)

Types

type Cmd

type Cmd struct {
	*exec.Cmd
}

func (*Cmd) StdinChannel

func (c *Cmd) StdinChannel() (chan string, error)

StdinChannel returns a channel that will be connected to the command's standard error when the command starts.

type GunzipReader

type GunzipReader struct {
	*bufio.Reader
	Unzip io.Reader
	Cmd   *exec.Cmd

	Buffer *bytes.Buffer
	// contains filtered or unexported fields
}

GunzipReader uncompress the input using the system's gzip. Apparently, the system gzip is much much faster than the go library, so I wrote some bench marks and tests

func NewGunzipReader

func NewGunzipReader(filename string) *GunzipReader

func (GunzipReader) Close

func (gz GunzipReader) Close()

func (GunzipReader) Read

func (gz GunzipReader) Read(data []byte) (int, error)

type GzipWriter

type GzipWriter struct {
	*bufio.Writer
	Gzip   *pgzip.Writer
	Buffer *bytes.Buffer
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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