goes

package module
v1.19.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2021 License: GPL-2.0, GPL-2.0-or-later Imports: 20 Imported by: 3

README

When imported by a machine main, package goes provides a monolithic embedded distro for Linux systems,

How is this pronounced?

We prefer "go e-s", aka. "go e[mbedded]-s[ystem]".

How is it monlithic?

The Live CD of most Linux distributions is an assembly of binary packages and base configuration. It may also include a guided self installer that copies its contents to the target along with other network acquired packages. These binary packages are built from interdependent source packages by a maintainer.

With goes, the package assembly, base configuration, and interdependency is handled by go build. The result is a single, thus monolithic, program including all of the commands that the maintainer intends to support on the target machine. This may include a guided self installer that, generally, doesn't require network install of anything else.

Alternatively, goes may run as a self-spawning daemons and interactive sub- commands within a minimal Linux distribution.

What are machines?

Machines are main packages that provide a goes command manifest, configuration, and customization before calling Goes.Main(). See https://github.com/platinasystems/goes-MACHINE for examples.

These machines are available at https://github.com/platinasystems/,

Most machines are built with just go build but some, like the bmc, may also use goes-build to build a properly configured kernel and embed itself as an initrd.

To install,

$ sudo ./goes-MACHINE install
...

To stop and remove,

$ sudo goes uninstall

To enable BASH completion after install,

. /usr/share/bash-completion/completions/goes

To run commands without install,

$ ./goes-MACHINE COMMAND [ARGS]...
...

To see the commands available on the installed MACHINE,

$ goes help

Or,

$ goes
goes> help

Then man any of the listed commands or man cli to see how to use the command line interface.

To debug,

$ gdb ./goes-MACHINE

Each goes/cmd provides apropos, completion, man, and usage. The command may also provide context sensitive help, README, and godoc.

See also errata.


© 2015-2019 Platina Systems, Inc. All rights reserved. Use of this source code is governed by this BSD-style LICENSE.

Documentation

Overview

Package goes, combined with a compatibly configured Linux kernel, provides a monolithic embedded system.

Index

Constants

View Source
const (
	VerboseQuiet = iota
	VerboseVerify
	VerboseDebug
)

Variables

View Source
var (
	Stop chan struct{}
	WG   sync.WaitGroup
)

All goes go-routines should add them selves to the WG WaitGroup and quit on Stop like this,

goes.WG.Add(1)
go func() {
	defer goes.WG.Done()
	for {
		select {
		case <-goes.Stop:
			return
		default:
			...
		}
	}
}

Functions

func Replace

func Replace(s, name string) string

func Usage

func Usage(v Usager) string

Types

type Blocker

type Blocker interface {
	Block(*Goes, shellutils.List) (*shellutils.List,
		func(io.Reader, io.Writer, io.Writer) error,
		error)
}

type Function

type Function struct {
	Name       string
	Definition []string
	RunFun     func(stdin io.Reader, stdout io.Writer, stderr io.Writer) error
}

type Goes

type Goes struct {
	// These uppercased fields may/should be assigned at instantiation
	NAME, USAGE  string
	APROPOS, MAN lang.Alt

	ByName map[string]cmd.Cmd

	Catline io.ReadWriter

	Status    error
	Verbosity int

	EnvMap map[string]string

	FunctionMap map[string]Function
	// contains filtered or unexported fields
}

func (*Goes) Apropos

func (g *Goes) Apropos() lang.Alt

func (*Goes) Builtins

func (g *Goes) Builtins() map[string]func(...string) error

func (*Goes) Complete

func (g *Goes) Complete(args ...string) (completions []string)

func (*Goes) Fork

func (g *Goes) Fork(args ...string) *exec.Cmd

Fork returns an exec.Cmd ready to Run or Output this program with the given args.

func (*Goes) Goes

func (g *Goes) Goes(parent *Goes)

func (*Goes) Help

func (g *Goes) Help(args ...string) string

func (*Goes) Main

func (g *Goes) Main(args ...string) error

Run a command in the current context.

If len(args) == 1 and args[0] doesn't match a mapped command, this will run the "cli".

If the args has "-help", or "--help", this runs ByName("help").Main(args...) to print text.

Similarly for "-apropos", "-complete", "-man", and "-usage".

If the command is a daemon, this fork exec's itself twice to disassociate the daemon from the tty and initiating process.

func (*Goes) MakeListFunc

func (g *Goes) MakeListFunc(pipeline []piperun) (func(stdin io.Reader, stdout io.Writer, stderr io.Writer) error, error)

func (*Goes) MakePipefun

func (g *Goes) MakePipefun(pipeline []func(io.Reader, io.Writer, io.Writer) error, closers *[]io.Closer) (func(io.Reader, io.Writer, io.Writer) error, error)

func (*Goes) Man

func (g *Goes) Man() lang.Alt

func (*Goes) Names

func (g *Goes) Names() []string

func (*Goes) Path

func (g *Goes) Path() []string

set Path of sub-goes. e.g. "ip address"

func (*Goes) ProcessCommand

func (g *Goes) ProcessCommand(cl shellutils.Cmdline, closers *[]io.Closer) (func(stdin io.Reader, stdout io.Writer, stderr io.Writer) error, error)

func (*Goes) ProcessList

func (g *Goes) ProcessList(ls shellutils.List) (*shellutils.List, *shellutils.Word, func(stdin io.Reader, stdout io.Writer, stderr io.Writer) error, error)

func (*Goes) ProcessPipeline

func (g *Goes) ProcessPipeline(ls shellutils.List) (*shellutils.List, *shellutils.Word, func(io.Reader, io.Writer, io.Writer) error, error)

func (*Goes) String

func (g *Goes) String() string

func (*Goes) Usage

func (g *Goes) Usage() string

type Usager

type Usager interface {
	Usage() string
}

Directories

Path Synopsis
cmd
cat
cd
cli
cli/internal/liner
Package liner is a wrapper to Peter Harris' <pharris@opentext.com> "Go line editor" <github.com:peterh/liner>.
Package liner is a wrapper to Peter Harris' <pharris@opentext.com> "Go line editor" <github.com:peterh/liner>.
cli/internal/notliner
Package notliner provides an alternative command.Prompter for shell scripts and tty's unsupported by liner.
Package notliner provides an alternative command.Prompter for shell scripts and tty's unsupported by liner.
cp
dhcpcd
Package dhcpcd is a simple dhcp client
Package dhcpcd is a simple dhcp client
env
for
gpio
Package gpio provides cli command to query/configure GPIO pins.
Package gpio provides cli command to query/configure GPIO pins.
i2c
Package i2c provides cli command to access i2c devices.
Package i2c provides cli command to access i2c devices.
i2cd
Package ucd9090 provides access to the UCD9090 Power Sequencer/Monitor chip
Package ucd9090 provides access to the UCD9090 Power Sequencer/Monitor chip
ip
ip/internal/group
Cache parse of /etc/iproute2/group
Cache parse of /etc/iproute2/group
ip/route/show
ip route show (default) | flush | get | save | restore
ip route show (default) | flush | get | save | restore
ldp
ln
log
ls
nop
platina/mk1/toggle
Package ucd9090 provides access to the UCD9090 Power Sequencer/Monitor chip
Package ucd9090 provides access to the UCD9090 Power Sequencer/Monitor chip
ps
pwd
redisd
Package redisd provides a redis server daemon that is started by /sbin/init or /usr/sbin/goesd *before* all other daemons.
Package redisd provides a redis server daemon that is started by /sbin/init or /usr/sbin/goesd *before* all other daemons.
reload
Package reload provides the named command that sends SIGHUP to all of the daemons associated with this executable.
Package reload provides the named command that sends SIGHUP to all of the daemons associated with this executable.
rm
scp
sshd
Package sshd is a ssh server daemon
Package sshd is a ssh server daemon
start
Package start provides the named command that runs a redis server followed by all of the configured daemons.
Package start provides the named command that runs a redis server followed by all of the configured daemons.
stop
Package stop provides the named command that kills all of the daemons associated with this executable.
Package stop provides the named command that kills all of the daemons associated with this executable.
telnetd
This telnet daemon is only run from an embedded machine's /init, not /usr/bin/goes start
This telnet daemon is only run from an embedded machine's /init, not /usr/bin/goes start
test/sleeper
Package sleeper provides a test ticker daemon.
Package sleeper provides a test ticker daemon.
ubi
uptime
Package uptime returns the current system uptime.
Package uptime returns the current system uptime.
uptimed
Package uptimed publishes the system uptime every 60 seconds to the local redis server.
Package uptimed publishes the system uptime every 60 seconds to the local redis server.
watchdog
Watchdog is only run by an embedded machine's /init, not by /usr/bin/goes start
Watchdog is only run by an embedded machine's /init, not by /usr/bin/goes start
external
atsock
Package atsock provides an interface to linux abstract sockets named "@NAME"
Package atsock provides an interface to linux abstract sockets named "@NAME"
dbg
Package dbg provides yet another stylized debug printer.
Package dbg provides yet another stylized debug printer.
flags
Package flags parses boolean options from command arguments.
Package flags parses boolean options from command arguments.
i2c
Package i2c provides an interface to Linux I2C devices.
Package i2c provides an interface to Linux I2C devices.
log
Package log prints messages to a given writer, /dev/log, /dev/kmsg, or a byte buffer until one of these are available.
Package log prints messages to a given writer, /dev/log, /dev/kmsg, or a byte buffer until one of these are available.
redis
Package redis provides an interface to query and modify a local server.
Package redis provides an interface to query and modify a local server.
redis/rpc
Package rpc provides remote calls to a redis server.
Package rpc provides remote calls to a redis server.
redis/rpc/args
Package args provides types for the redis RPC arguments.
Package args provides types for the redis RPC arguments.
redis/rpc/reg
Package reg provides an RPC to register redis handlers.
Package reg provides an RPC to register redis handlers.
redis/rpc/reply
Package reply provides types and methods for the redis RPC replies.
Package reply provides types and methods for the redis RPC replies.
xeth
This package provides a sideband control interface to an XETH driver.
This package provides a sideband control interface to an XETH driver.
internal
assert
Package assert provides various assertions.
Package assert provides various assertions.
buildid
This package gets a GO program's BuildId.
This package gets a GO program's BuildId.
buildinfo
This package provides a runtime/debug.BuildInfo Formatter.
This package provides a runtime/debug.BuildInfo Formatter.
cmdline
Package cmdline maps /proc/cmdline
Package cmdline maps /proc/cmdline
fields
Slice a string into args while combining single, double, or backslash escaped spaced arguments, e.g.: echo hello\ beautiful\ world echo "hello 'beautiful world'" echo 'hello \"beautiful world\"'
Slice a string into args while combining single, double, or backslash escaped spaced arguments, e.g.: echo hello\ beautiful\ world echo "hello 'beautiful world'" echo 'hello \"beautiful world\"'
fit
Package fit parses Flattened Image Tree image tree blob files.
Package fit parses Flattened Image Tree image tree blob files.
group
Package group provides an /etc/group parser.
Package group provides an /etc/group parser.
kill
Package kill provides a method to signal process groups.
Package kill provides a method to signal process groups.
nl
nocomment
Package nocomment strips a string trailing '#' prefaced comments along with its leading whitespace.
Package nocomment strips a string trailing '#' prefaced comments along with its leading whitespace.
pizza
Slice args at boundary.
Slice args at boundary.
prog
Package prog provides methods that return the current program base and full name along with it's minimal PATH.
Package prog provides methods that return the current program base and full name along with it's minimal PATH.
Package lang provides text in alternative languages.
Package lang provides text in alternative languages.

Jump to

Keyboard shortcuts

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