command

package module
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2026 License: MIT Imports: 4 Imported by: 0

README

Documentation

Index

Examples

Constants

View Source
const (
	Base64Decode   base64DecodeFlag = true
	Base64NoDecode base64DecodeFlag = false
)
View Source
const (
	Base64IgnoreGarbage   base64IgnoreGarbageFlag = true
	Base64NoIgnoreGarbage base64IgnoreGarbageFlag = false
)

Variables

This section is empty.

Functions

func Base64

func Base64(opts ...any) gloo.Command[[]byte, []byte]

Base64 returns a command that base64-encodes or -decodes its whole input, matching GNU coreutils base64.

Encode (default): the entire input is treated as one byte stream and encoded; output is wrapped at column 76, or at the column given by Base64Wrap(COLS). Base64Wrap(0) disables wrapping.

Decode (Base64Decode / -d): the entire input is concatenated and decoded. Without Base64IgnoreGarbage, a byte outside the base64 alphabet is an error; with it (-i / --ignore-garbage), such bytes are discarded before decoding.

Example
package main

import (
	"fmt"

	"github.com/gloo-foo/testable"

	command "github.com/gloo-foo/cmd-base64"
)

func main() {
	lines, _ := testable.TestLines(command.Base64(), "Hello World\n")
	for _, line := range lines {
		fmt.Println(line)
	}
}
Output:
SGVsbG8gV29ybGQ=
Example (Decode)
package main

import (
	"fmt"

	"github.com/gloo-foo/testable"

	command "github.com/gloo-foo/cmd-base64"
)

func main() {
	lines, _ := testable.TestLines(command.Base64(command.Base64Decode), "SGVsbG8gV29ybGQ=\n")
	for _, line := range lines {
		fmt.Println(line)
	}
}
Output:
Hello World
Example (Wrap)
package main

import (
	"fmt"

	"github.com/gloo-foo/testable"

	command "github.com/gloo-foo/cmd-base64"
)

func main() {
	lines, _ := testable.TestLines(command.Base64(command.Base64Wrap(10)), "Hello World\n")
	for _, line := range lines {
		fmt.Println(line)
	}
}
Output:
SGVsbG8gV2
9ybGQ=

Types

type Base64Wrap

type Base64Wrap uint

Base64Wrap sets the column at which encoded output is wrapped (-w / --wrap). Base64Wrap(0) disables wrapping. When no Base64Wrap is supplied the GNU default of 76 applies (see defaultWrap).

Directories

Path Synopsis
Package alias provides unprefixed names for base64 command flags.
Package alias provides unprefixed names for base64 command flags.

Jump to

Keyboard shortcuts

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