util

package
v0.0.0-...-56aa1ee Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2020 License: Apache-2.0 Imports: 18 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckConfirmation

func CheckConfirmation(stdin io.Reader, stdout io.Writer, name string) (bool, error)

CheckConfirmation prompts the user for confirmation and returns true IFF the user responds with 'yes'

func EightRandomLetters

func EightRandomLetters() string

EightRandomLetters generates a random string

func FindUserIP

func FindUserIP() (string, error)

FindUserIP gets the user's public IP by querying whatismyip.akamai.com

func GeneratePasswordWithLength

func GeneratePasswordWithLength(length int) string

GeneratePasswordWithLength a random password with the given length

func GenerateRSAKeyPair

func GenerateRSAKeyPair() ([]byte, []byte, error)

GenerateRSAKeyPair generates a new RSA key pair https://stackoverflow.com/questions/13555085/save-and-load-crypto-rsa-privatekey-to-and-from-the-disk

func GenerateSSHKeyPair

func GenerateSSHKeyPair() ([]byte, []byte, string, error)

GenerateSSHKeyPair generates a new ssh public key pair http://stackoverflow.com/questions/21151714/go-generate-an-ssh-public-key

func RenderTemplate

func RenderTemplate(name string, templateStr string, params interface{}) ([]byte, error)

RenderTemplate renders a template to a string

Types

type TempDir

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

TempDir represents a temporary directory to store files

func NewTempDir

func NewTempDir() (*TempDir, error)

NewTempDir returns a new temporary directory

func (*TempDir) Cleanup

func (tempDir *TempDir) Cleanup() error

Cleanup deletes the tempDir

func (*TempDir) Path

func (tempDir *TempDir) Path(filename string) string

Path returns a path for the given file into the tempDir

func (*TempDir) PushDir

func (tempDir *TempDir) PushDir(callback func() error) error

PushDir runs the function in the tempDir

func (*TempDir) Save

func (tempDir *TempDir) Save(filename string, contents []byte) (string, error)

Save writes the given file into the tempDir

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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