Documentation
¶
Index ¶
- Constants
- func BytesToString(bytes []byte) string
- func ContextualRead(context contextpkg.Context, reader io.Reader, p []byte) (int, error)
- func CopySSH(host string, port int, username string, key string, reader io.Reader, ...) error
- func CreateSelfSignedTLSConfig(organization string, host string) (*tls.Config, error)
- func CreateTLSConfig(certificate []byte, key []byte) (*tls.Config, error)
- func CreateX509Certificate(organization string, host string, rsa bool, ca bool) (*x509.Certificate, error)
- func DoesFileExist(path string) (bool, error)
- func DumpIPAddress(address any)
- func ExecSSH(host string, port int, username string, key string, stdin io.Reader, ...) (string, error)
- func Exit(code int)
- func ExitOnSignals()
- func Fail(message string)
- func FailOnError(err error)
- func Failf(f string, args ...any)
- func FixTarballEntryPath(path string) string
- func FromBase64(b64 string) ([]byte, error)
- func GetFileHash(path string) (string, error)
- func GetGoBin() (string, error)
- func GetGoPath() (string, error)
- func InitializeCPUProfiling(path string)
- func InitializeColorization(colorize string)
- func IsFileExecutable(mode fs.FileMode) bool
- func IsFileHidden(path string) bool
- func IsFloat(value any) bool
- func IsIPv6(address string) bool
- func IsInteger(value any) bool
- func IsNumber(value any) bool
- func IsUDPAddrEqual(a *net.UDPAddr, b *net.UDPAddr) bool
- func JoinIPAddressPort(address string, port int) string
- func JoinQuote(strings []string, separator string) string
- func JoinQuoteL(strings []string, separator string, lastSeparator string, ...) string
- func NewContextualReadCloser(context contextpkg.Context, reader io.ReadCloser) io.ReadCloser
- func NewContextualReader(context contextpkg.Context, reader io.Reader) io.Reader
- func NewMockLocker() sync.Locker
- func ParseX509CertPool(bytes []byte) (*x509.CertPool, error)
- func ParseX509Certificates(bytes []byte) ([]*x509.Certificate, error)
- func ReaderSize(reader io.Reader) (int64, error)
- func ResetAdHocLocks()
- func SanitizeFilename(name string) string
- func SetFlagsFromEnvironment(prefix string)
- func SetupSignalHandler() <-chan struct{}
- func SignX509Certificate(certificate *x509.Certificate, privateKey any, publicKey any) (*x509.Certificate, error)
- func StringToBytes(string_ string) (bytes []byte)
- func ToBase64(bytes []byte) string
- func ToBroadcastIPAddress(address string) (string, string, error)
- func ToBytes(content any) []byte
- func ToDromedaryCase(name string) string
- func ToFloat64(value any) (float64, bool)
- func ToInt64(value any) (int64, bool)
- func ToKebabCase(name string) string
- func ToRawTerminal(f func() error)
- func ToReachableIPAddress(address string) (string, string, error)
- func ToSnakeCase(name string) string
- func ToString(value any) string
- func ToStrings(values []any) []string
- func ToUInt64(value any) (uint64, bool)
- func Touch(path string, permissions fs.FileMode, dirPermissions fs.FileMode) error
- func WriteBytesToChannel(ch chan []byte, p []byte, copy bool) (int, error)
- func WriteNewline(writer io.Writer) error
- type BufferedWriter
- type ChannelReader
- type ChannelWriter
- type ContextualReadCloser
- type ContextualReader
- type CoordinatedWork
- type ExitFunctionHandle
- type ForceHTTPSRoundTripper
- type LockType
- type LockableEntity
- type MockLocker
- type MockRWLocker
- type NamedPipe
- type Promise
- type RWLocker
- type SyncedWriter
- type TarEncoder
- type TarballEntryReader
- type TarballReader
- type TestLogWriter
Constants ¶
const BUFFER_SIZE = 65536
Variables ¶
This section is empty.
Functions ¶
func BytesToString ¶
This conversion *does not* copy data. Note that converting via "(string)([]byte)" *does* copy data. Also note that you *should not* change the byte slice after conversion, because Go strings are treated as immutable. This would cause a segmentation violation panic.
func ContextualRead ¶ added in v0.2.2
func CreateSelfSignedTLSConfig ¶ added in v0.1.38
func CreateTLSConfig ¶ added in v0.1.38
func CreateX509Certificate ¶ added in v0.1.38
func DoesFileExist ¶ added in v0.1.59
func DumpIPAddress ¶ added in v0.1.60
func DumpIPAddress(address any)
func ExitOnSignals ¶ added in v0.3.11
func ExitOnSignals()
func FailOnError ¶
func FailOnError(err error)
func FixTarballEntryPath ¶ added in v0.3.7
func FromBase64 ¶ added in v0.1.4
func GetFileHash ¶
func InitializeCPUProfiling ¶ added in v0.2.6
func InitializeCPUProfiling(path string)
func InitializeColorization ¶ added in v0.2.6
func InitializeColorization(colorize string)
Attempts to enable colorization for os.Stdout and os.Stderr according to the colorize argument. If cleanup is required, will set register it with OnExit. Errors will Fail.
The colorize argument can be:
- "true", "TRUE", "True", "t", "T", "1": Attempts to enable colorization if os.Stdout and os.Stdout support it. If it succeeds will set [ColorizeStdout], [StdoutStylist], [ColorizeStderr], and [StderrStylist] accordingly.
- "false", "FALSE", "False", "f", "F", "0": Does nothing.
- "force": Sets [ColorizeStdout], [StdoutStylist], [ColorizeStderr], and [StderrStylist] as if coloriziation were enabled.
Other colorize values will Fail.
func IsFileExecutable ¶ added in v0.1.59
func IsFileHidden ¶ added in v0.1.59
func IsInteger ¶ added in v0.3.3
Returns true if value is an int64, int32, int16, int8, int, uint64, uint32, uint16, uint8, or uint.
func IsNumber ¶ added in v0.3.3
Returns true if value is an int64, int32, int16, int8, int, uint64, uint32, uint16, uint8, uint, float64, or float32.
func JoinIPAddressPort ¶ added in v0.1.60
func JoinQuoteL ¶ added in v0.1.60
func NewContextualReadCloser ¶ added in v0.2.2
func NewContextualReadCloser(context contextpkg.Context, reader io.ReadCloser) io.ReadCloser
Creates a io.ReadCloser
func NewContextualReader ¶ added in v0.2.2
func NewMockLocker ¶ added in v0.1.51
func ParseX509CertPool ¶ added in v0.1.6
func ParseX509Certificates ¶ added in v0.1.6
func ParseX509Certificates(bytes []byte) ([]*x509.Certificate, error)
func ResetAdHocLocks ¶ added in v0.1.51
func ResetAdHocLocks()
func SanitizeFilename ¶
func SetFlagsFromEnvironment ¶
func SetFlagsFromEnvironment(prefix string)
func SetupSignalHandler ¶
func SetupSignalHandler() <-chan struct{}
Registers handlers for SIGINT and (on Posix systems) SIGTERM. The returned channel will be closed when either signal is sent.
func SignX509Certificate ¶ added in v0.1.38
func SignX509Certificate(certificate *x509.Certificate, privateKey any, publicKey any) (*x509.Certificate, error)
func StringToBytes ¶
This conversion *does not* copy data. Note that converting via "([]byte)(string)" *does* copy data. Also note that you *should not* change the byte slice after conversion, because Go strings are treated as immutable. This would cause a segmentation violation panic.
func ToBroadcastIPAddress ¶ added in v0.1.60
func ToDromedaryCase ¶ added in v0.1.61
func ToFloat64 ¶ added in v0.3.3
Converts any number type to float64.
Support types are int64, int32, int16, int8, int, uint64, uint32, uint16, uint8, uint, float64, and float32.
Precision may be lost.
func ToInt64 ¶ added in v0.3.3
Converts any number type to int64.
Supported types are int64, int32, int16, int8, int, uint64, uint32, uint16, uint8, uint, float64, and float32.
Precision may be lost.
func ToKebabCase ¶ added in v0.1.61
func ToRawTerminal ¶ added in v0.1.63
func ToRawTerminal(f func() error)
func ToReachableIPAddress ¶ added in v0.1.60
func ToSnakeCase ¶ added in v0.1.61
func ToString ¶ added in v0.1.59
Converts any value to a string.
Will use the fmt.Stringer interface if implemented.
Will use the [error] interface if implemented.
nil will become "nil". []byte will become a string. Primitive types will use strconv. Any other type will use fmt.Sprintf("%+v").
func ToUInt64 ¶ added in v0.3.3
Converts any number type to uint64.
Support types are int64, int32, int16, int8, int, uint64, uint32, uint16, uint8, uint, float64, and float32.
Precision may be lost.
func WriteBytesToChannel ¶ added in v0.3.5
Sends the byte slice to a channel and returns its length.
When copy is true will copy the byte slice before sending it to the channel. This is necessary for ensuring that the submitted data is indeed the data that will be received, even if the underlying array changes after this call.
func WriteNewline ¶ added in v0.1.27
Types ¶
type BufferedWriter ¶ added in v0.1.22
type BufferedWriter struct {
// contains filtered or unexported fields
}
func NewBufferedWriter ¶ added in v0.1.22
func NewBufferedWriter(writer io.Writer, size int, copy bool) *BufferedWriter
Creates a thread-safe io.WriterCloser that separates the acceptance of byte slices via BufferedWriter.Write from the actual writing of the data to the underlying io.Writer, which occurs on a separate goroutine.
The size argument is for the internal channel, referring to the maximum number of write submissions to be buffered (not the number of bytes). If the buffering channel is full then BufferedWriter.Write will return an error. The actual write errors are ignored.
When copy is true the implementation copies the byte slice before sending it to the separate goroutine. This ensures that the submitted data is indeed the data that will be written, even if the underlying array changes after submission.
func (*BufferedWriter) Close ¶ added in v0.1.22
func (self *BufferedWriter) Close() error
(io.Closer interface)
type ChannelReader ¶ added in v0.1.59
type ChannelReader struct {
// contains filtered or unexported fields
}
func NewChannelReader ¶ added in v0.1.59
func NewChannelReader(ch chan []byte) *ChannelReader
Creates an io.Reader that reads bytes from a channel. This works via a separate goroutine that pipes (via io.Pipe) the channel data.
type ChannelWriter ¶ added in v0.1.57
type ChannelWriter struct {
// contains filtered or unexported fields
}
func NewChannelWriter ¶ added in v0.1.57
func NewChannelWriter(ch chan []byte, copy bool) *ChannelWriter
Creates an io.Writer that writes bytes to a channel. The expectation is that something else will be receiving from the channel and processing the bytes. Writing is non-blocking: if the channel is full then ChannelWriter.Write will return an error.
When copy is true the implementation copies the byte slice before sending it to the channel. This ensures that the submitted data is indeed the data that will be received, even if the underlying array changes after submission.
type ContextualReadCloser ¶ added in v0.2.2
type ContextualReadCloser struct {
// contains filtered or unexported fields
}
Creates a io.ReadCloser that allows cancellation of reading via a provided context. Note that cancellation is not guaranteed because the underlying reader is called in-thread. At best we can guarantee that subsequent calls to ContextualReadCloser.Read will fail after cancellation.
func (ContextualReadCloser) Close ¶ added in v0.2.2
func (self ContextualReadCloser) Close() error
(io.Closer interface)
type ContextualReader ¶ added in v0.2.2
type ContextualReader struct {
// contains filtered or unexported fields
}
Creates a io.Reader that allows cancellation of reading via a provided context. Note that cancellation is not guaranteed because the underlying reader is called in-thread. At best we can guarantee that subsequent calls to ContextualReader.Read will fail after cancellation.
type CoordinatedWork ¶ added in v0.1.52
func NewCoordinatedWork ¶ added in v0.1.52
func NewCoordinatedWork() *CoordinatedWork
func (*CoordinatedWork) Start ¶ added in v0.1.52
func (self *CoordinatedWork) Start(context contextpkg.Context, key string) (Promise, bool)
type ExitFunctionHandle ¶ added in v0.1.22
type ExitFunctionHandle int
func OnExit ¶ added in v0.1.22
func OnExit(exitFunction func()) ExitFunctionHandle
func OnExitError ¶ added in v0.1.50
func OnExitError(exitFunction func() error) ExitFunctionHandle
func (ExitFunctionHandle) Cancel ¶ added in v0.1.22
func (self ExitFunctionHandle) Cancel()
type ForceHTTPSRoundTripper ¶ added in v0.1.4
type ForceHTTPSRoundTripper struct {
// contains filtered or unexported fields
}
func NewForceHTTPSRoundTripper ¶ added in v0.1.4
func NewForceHTTPSRoundTripper(roundTripper http.RoundTripper) *ForceHTTPSRoundTripper
type LockableEntity ¶ added in v0.1.51
type LockableEntity interface {
GetEntityLock() RWLocker
}
type MockLocker ¶ added in v0.1.51
type MockLocker struct{}
type MockRWLocker ¶ added in v0.1.51
type MockRWLocker struct {
MockLocker
}
func (MockRWLocker) RLocker ¶ added in v0.1.51
func (self MockRWLocker) RLocker() sync.Locker
(RWLocker interface)
func (MockRWLocker) RUnlock ¶ added in v0.1.51
func (self MockRWLocker) RUnlock()
(RWLocker interface)
type NamedPipe ¶ added in v0.1.58
type NamedPipe struct {
// contains filtered or unexported fields
}
func NewTempNamedPipe ¶ added in v0.1.58
Creates a named pipe using syscall.Mkfifo in the OS temp directory. Currently only supported on Linux.
type Promise ¶ added in v0.1.52
type Promise chan struct{}
func NewPromise ¶ added in v0.1.52
func NewPromise() Promise
type RWLocker ¶ added in v0.1.51
func GetAdHocLock ¶ added in v0.1.51
Warning: Because pointers can be re-used after the resource is freed, there is no way for us to guarantee ad-hoc locks would not be reused Thus this facililty should only be used for objects with a known and managed life span.
func GetEntityLock ¶ added in v0.1.51
From LockableEntity interface.
func NewDebugRWLocker ¶ added in v0.1.51
func NewDebugRWLocker() RWLocker
func NewDefaultRWLocker ¶ added in v0.1.51
func NewDefaultRWLocker() RWLocker
func NewMockRWLocker ¶ added in v0.1.51
func NewMockRWLocker() RWLocker
func NewRWLocker ¶ added in v0.1.51
func NewSyncRWLocker ¶ added in v0.1.52
func NewSyncRWLocker() RWLocker
type SyncedWriter ¶ added in v0.1.22
func NewSyncedWriter ¶ added in v0.1.22
func NewSyncedWriter(writer io.Writer) *SyncedWriter
Creates a thread-safe io.WriterCloser that synchronizes all the SyncedWriter.Write calls via a mutex.
If the underlying writer does not support io.Closer then SyncedWriter.Close will do nothing.
func (*SyncedWriter) Close ¶ added in v0.1.22
func (self *SyncedWriter) Close() error
(io.Closer interface)
type TarEncoder ¶
type TarEncoder struct {
// contains filtered or unexported fields
}
func NewTarEncoder ¶
func NewTarEncoder(reader io.Reader, name string, size int64) *TarEncoder
func (*TarEncoder) Drain ¶
func (self *TarEncoder) Drain()
func (*TarEncoder) Encode ¶
func (self *TarEncoder) Encode() io.Reader
type TarballEntryReader ¶ added in v0.3.7
type TarballEntryReader struct {
TarballReader *TarballReader
}
func NewTarballEntryReader ¶ added in v0.3.7
func NewTarballEntryReader(tarballReader *TarballReader) *TarballEntryReader
func (*TarballEntryReader) Close ¶ added in v0.3.7
func (self *TarballEntryReader) Close() error
(io.Closer interface)
type TarballReader ¶ added in v0.3.7
type TarballReader struct {
TarReader *tar.Reader
ArchiveReader io.ReadCloser
CompressionReader io.ReadCloser
}
func NewTarballReader ¶ added in v0.3.7
func NewTarballReader(reader *tar.Reader, archiveReader io.ReadCloser, compressionReader io.ReadCloser) *TarballReader
func (*TarballReader) Close ¶ added in v0.3.7
func (self *TarballReader) Close() error
(io.Closer interface)
func (*TarballReader) Has ¶ added in v0.3.7
func (self *TarballReader) Has(path string) (bool, error)
func (*TarballReader) Iterate ¶ added in v0.3.7
func (self *TarballReader) Iterate(f func(*tar.Header) bool) error
func (*TarballReader) Open ¶ added in v0.3.7
func (self *TarballReader) Open(path string) (*TarballEntryReader, error)
type TestLogWriter ¶ added in v0.1.51
type TestLogWriter struct {
// contains filtered or unexported fields
}
func NewTestLogWriter ¶ added in v0.1.51
func NewTestLogWriter(t *testing.T) *TestLogWriter