Binaries - craterdog/go-component-framework GitHub Wiki

Overview

A binary string is a sequence of bytes encoded with the base 64 character set:

['A'..'Z' 'a'..'z' '0'..'9' '+' '/']

Each binary string has the following string format:

binary$: "'>" (BASE64 | SPACE | EOL)* "<'"

The source of this format is Bali Document Notation™ (Bali) defined here.

UML Diagram

A Quick Example

To whet your appetite, here is some short example code that demonstrates the use of binary strings.

package main

import (
	fmt "fmt"
	fra "github.com/craterdog/go-component-framework/v7"
)

func main() {
	// Create some new binary strings using the module level constructor shortcuts.
	var binary = fra.BinaryFromString(
		`'>
    ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
    0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmn
    opqrstuvwxyz0123456789+/
<'
`,
	)
	fmt.Println(binary)
	binary = fra.Binary(
		[]byte{0, 1, 2, 3, 4, 5},
	)
	fmt.Println(binary)
	fmt.Println()

	// Iterate through the bytes for the binary string.
	var iterator = binary.GetIterator()
	for iterator.HasNext() {
		var next = iterator.GetNext()
		fmt.Println(next)
	}
}

Try it out in the Go Playground...