goes

package module
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: GPL-2.0, GPL-2.0-or-later Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const LogFlags = log.Lshortfile
View Source
const RpcNet = "unix"
View Source
const ServiceTimeout = 30 * time.Second
View Source
const ThisBuildId = BuildId("/proc/self/exe")

Variables

View Source
var (
	PageSz = os.Getpagesize()
	Page   = sync.Pool{
		New: func() interface{} {
			return make([]byte, PageSz, PageSz)
		},
	}
)
View Source
var BuiltIn = Selection{
	"build-id": func(ctx context.Context, args ...string) error {
		OutputOf(ctx).Println(ThisBuildId)
		return nil
	},
	"build-info": func(ctx context.Context, args ...string) error {
		if bi, ok := debug.ReadBuildInfo(); ok {
			OutputOf(ctx).Print(bi)
		}
		return nil
	},
	"cat":  Cat,
	"echo": Echo,
	"version": func(ctx context.Context, args ...string) error {
		if bi, ok := debug.ReadBuildInfo(); ok {
			OutputOf(ctx).Println(bi.Main.Version)
		}
		return nil
	},
}
View Source
var Fatal = log.Fatal
View Source
var LangPrecedence = []LANG{LANG(os.Getenv("LANG")), "", EnUS}
View Source
var Prog = filepath.Base(os.Args[0])
View Source
var RpcAddr = "@" + Prog
View Source
var TerminationSignals = []os.Signal{
	os.Interrupt,
	os.Signal(syscall.SIGTERM),
}

Functions

func Cat

func Cat(ctx context.Context, args ...string) error

func CompleteFiles

func CompleteFiles(args []string) (c []string)

func CompleteFlags

func CompleteFlags(fs *flag.FlagSet, args []string) (c []string)

func CompleteInterfaces

func CompleteInterfaces(args []string) (c []string)

func CompleteStrings

func CompleteStrings(l []string, args []string) (c []string)

func Echo

func Echo(ctx context.Context, args ...string) error

func ErrorfWith

func ErrorfWith(ctx context.Context, format string, args ...interface{}) error

ErrorfWith context path preface.

func Hereby

func Hereby(ctx context.Context, args []string) (context.Context, []string)

Hereby strips `<<< CONTENT` args to push context input.

func Herein

func Herein(ctx context.Context, args []string) (context.Context, []string)

Herein replaces a `<[FILE]` arg with `<<< CONTENT` of FILE or input context.

func LastArg

func LastArg(args []string) (s string)

func Listen

func Listen() (net.Listener, error)

func PathOf

func PathOf(ctx context.Context) []string

PathOf() returns a FIFO of each element appended to the context.

func PlainLog

func PlainLog()

func Preempt

func Preempt(ctx context.Context, args []string) (context.Context, []string)

Move the "complete" and "help" preeemptive command arguments to context.

func Preemption

func Preemption(ctx context.Context) string

Preemption returns "complete" or "help" if the context path is preempted by either; otherwise, this returns an empty string.

func RPC

func RPC(ctx context.Context, args ...string) error

func StyleLog

func StyleLog()

func Usage

func Usage(ctx context.Context, args ...interface{})

Usage prints this formatted text.

usage: PATH ARGS...

Where PATH is the space separated elements pushed onto the context. The ARGS are fomatted with `fmt.Print` WITHOUT space separation so include this w/in if desired.

A *flag.FlagSet arg is // printed with FlagSet.PrintDefault, and similarly for a Selection arg.

func UsageOf

func UsageOf(ctx context.Context) func()

func WithInput

func WithInput(ctx context.Context, r io.Reader) context.Context

func WithOutput

func WithOutput(ctx context.Context, w io.Writer) context.Context

func WithPath

func WithPath(ctx context.Context, name string) context.Context

Append a element to context.

func WithRoot

func WithRoot(ctx context.Context, m Selection) context.Context

func WithUsage

func WithUsage(ctx context.Context, f func()) context.Context

Types

type BuildId

type BuildId string

func (BuildId) MarshalText

func (proc BuildId) MarshalText() ([]byte, error)

func (BuildId) String

func (proc BuildId) String() string

type EmbeddedFile

type EmbeddedFile struct {
	FS   embed.FS
	Path string
}

func (EmbeddedFile) Bytes

func (f EmbeddedFile) Bytes() []byte

func (EmbeddedFile) Show

func (f EmbeddedFile) Show(ctx context.Context, _ ...string) error

func (EmbeddedFile) String

func (f EmbeddedFile) String() string

type Func

type Func = func(context.Context, ...string) error

type Input

type Input struct {
	context.Context
	// contains filtered or unexported fields
}

func InputOf

func InputOf(ctx context.Context) Input

func (Input) Read

func (in Input) Read(buf []byte) (int, error)

func (Input) Value

func (in Input) Value(k interface{}) interface{}

type LANG

type LANG string
const (
	AaDJ  LANG = "aa_DJ.UTF-8"
	AfZA  LANG = "af_ZA.UTF-8"
	AnES  LANG = "an_ES.UTF-8"
	ArAE  LANG = "ar_AE.UTF-8"
	ArBH  LANG = "ar_BH.UTF-8"
	ArDZ  LANG = "ar_DZ.UTF-8"
	ArEG  LANG = "ar_EG.UTF-8"
	ArIQ  LANG = "ar_IQ.UTF-8"
	ArJO  LANG = "ar_JO.UTF-8"
	ArKW  LANG = "ar_KW.UTF-8"
	ArLB  LANG = "ar_LB.UTF-8"
	ArLY  LANG = "ar_LY.UTF-8"
	ArMA  LANG = "ar_MA.UTF-8"
	ArOM  LANG = "ar_OM.UTF-8"
	ArQA  LANG = "ar_QA.UTF-8"
	ArSA  LANG = "ar_SA.UTF-8"
	ArSD  LANG = "ar_SD.UTF-8"
	ArSY  LANG = "ar_SY.UTF-8"
	ArTN  LANG = "ar_TN.UTF-8"
	ArYE  LANG = "ar_YE.UTF-8"
	AstES LANG = "ast_ES.UTF-8"
	BeBY  LANG = "be_BY.UTF-8"
	BgBG  LANG = "bg_BG.UTF-8"
	BrFR  LANG = "br_FR.UTF-8"
	BsBA  LANG = "bs_BA.UTF-8"
	CaAD  LANG = "ca_AD.UTF-8"
	CaES  LANG = "ca_ES.UTF-8"
	CaFR  LANG = "ca_FR.UTF-8"
	CaIT  LANG = "ca_IT.UTF-8"
	CsCZ  LANG = "cs_CZ.UTF-8"
	CyGB  LANG = "cy_GB.UTF-8"
	DaDK  LANG = "da_DK.UTF-8"
	DeAT  LANG = "de_AT.UTF-8"
	DeBE  LANG = "de_BE.UTF-8"
	DeCH  LANG = "de_CH.UTF-8"
	DeDE  LANG = "de_DE.UTF-8"
	DeLI  LANG = "de_LI.UTF-8"
	DeLU  LANG = "de_LU.UTF-8"
	ElCY  LANG = "el_CY.UTF-8"
	ElGR  LANG = "el_GR.UTF-8"
	EnAU  LANG = "en_AU.UTF-8"
	EnBW  LANG = "en_BW.UTF-8"
	EnCA  LANG = "en_CA.UTF-8"
	EnDK  LANG = "en_DK.UTF-8"
	EnGB  LANG = "en_GB.UTF-8"
	EnHK  LANG = "en_HK.UTF-8"
	EnIE  LANG = "en_IE.UTF-8"
	EnNZ  LANG = "en_NZ.UTF-8"
	EnPH  LANG = "en_PH.UTF-8"
	EnSG  LANG = "en_SG.UTF-8"
	EnUS  LANG = "en_US.UTF-8"
	EnZA  LANG = "en_ZA.UTF-8"
	EnZW  LANG = "en_ZW.UTF-8"
	EsAR  LANG = "es_AR.UTF-8"
	EsBO  LANG = "es_BO.UTF-8"
	EsCL  LANG = "es_CL.UTF-8"
	EsCO  LANG = "es_CO.UTF-8"
	EsCR  LANG = "es_CR.UTF-8"
	EsDO  LANG = "es_DO.UTF-8"
	EsEC  LANG = "es_EC.UTF-8"
	EsES  LANG = "es_ES.UTF-8"
	EsGT  LANG = "es_GT.UTF-8"
	EsHN  LANG = "es_HN.UTF-8"
	EsMX  LANG = "es_MX.UTF-8"
	EsNI  LANG = "es_NI.UTF-8"
	EsPA  LANG = "es_PA.UTF-8"
	EsPE  LANG = "es_PE.UTF-8"
	EsPR  LANG = "es_PR.UTF-8"
	EsPY  LANG = "es_PY.UTF-8"
	EsSV  LANG = "es_SV.UTF-8"
	EsUS  LANG = "es_US.UTF-8"
	EsUY  LANG = "es_UY.UTF-8"
	EsVE  LANG = "es_VE.UTF-8"
	EtEE  LANG = "et_EE.UTF-8"
	EuES  LANG = "eu_ES.UTF-8"
	EuFR  LANG = "eu_FR.UTF-8"
	FiFI  LANG = "fi_FI.UTF-8"
	FoFO  LANG = "fo_FO.UTF-8"
	FrBE  LANG = "fr_BE.UTF-8"
	FrCA  LANG = "fr_CA.UTF-8"
	FrCH  LANG = "fr_CH.UTF-8"
	FrFR  LANG = "fr_FR.UTF-8"
	FrLU  LANG = "fr_LU.UTF-8"
	GaIE  LANG = "ga_IE.UTF-8"
	GdGB  LANG = "gd_GB.UTF-8"
	GlES  LANG = "gl_ES.UTF-8"
	GvGB  LANG = "gv_GB.UTF-8"
	HeIL  LANG = "he_IL.UTF-8"
	HrHR  LANG = "hr_HR.UTF-8"
	HsbDE LANG = "hsb_DE.UTF-8"
	HuHU  LANG = "hu_HU.UTF-8"
	IdID  LANG = "id_ID.UTF-8"
	IsIS  LANG = "is_IS.UTF-8"
	ItCH  LANG = "it_CH.UTF-8"
	ItIT  LANG = "it_IT.UTF-8"
	IwIL  LANG = "iw_IL.UTF-8"
	JaJP  LANG = "ja_JP.UTF-8"
	KaGE  LANG = "ka_GE.UTF-8"
	KkKZ  LANG = "kk_KZ.UTF-8"
	KlGL  LANG = "kl_GL.UTF-8"
	KoKR  LANG = "ko_KR.UTF-8"
	KuTR  LANG = "ku_TR.UTF-8"
	KwGB  LANG = "kw_GB.UTF-8"
	LgUG  LANG = "lg_UG.UTF-8"
	LtLT  LANG = "lt_LT.UTF-8"
	LvLV  LANG = "lv_LV.UTF-8"
	MgMG  LANG = "mg_MG.UTF-8"
	MiNZ  LANG = "mi_NZ.UTF-8"
	MkMK  LANG = "mk_MK.UTF-8"
	MsMY  LANG = "ms_MY.UTF-8"
	MtMT  LANG = "mt_MT.UTF-8"
	NbNO  LANG = "nb_NO.UTF-8"
	NlBE  LANG = "nl_BE.UTF-8"
	NlNL  LANG = "nl_NL.UTF-8"
	NnNO  LANG = "nn_NO.UTF-8"
	OcFR  LANG = "oc_FR.UTF-8"
	OmKE  LANG = "om_KE.UTF-8"
	PlPL  LANG = "pl_PL.UTF-8"
	PtBR  LANG = "pt_BR.UTF-8"
	PtPT  LANG = "pt_PT.UTF-8"
	RoRO  LANG = "ro_RO.UTF-8"
	RuRU  LANG = "ru_RU.UTF-8"
	RuUA  LANG = "ru_UA.UTF-8"
	SkSK  LANG = "sk_SK.UTF-8"
	SlSI  LANG = "sl_SI.UTF-8"
	SoDJ  LANG = "so_DJ.UTF-8"
	SoKE  LANG = "so_KE.UTF-8"
	SoSO  LANG = "so_SO.UTF-8"
	SqAL  LANG = "sq_AL.UTF-8"
	StZA  LANG = "st_ZA.UTF-8"
	SvFI  LANG = "sv_FI.UTF-8"
	SvSE  LANG = "sv_SE.UTF-8"
	TgTJ  LANG = "tg_TJ.UTF-8"
	ThTH  LANG = "th_TH.UTF-8"
	TlPH  LANG = "tl_PH.UTF-8"
	TrCY  LANG = "tr_CY.UTF-8"
	TrTR  LANG = "tr_TR.UTF-8"
	UkUA  LANG = "uk_UA.UTF-8"
	UzUZ  LANG = "uz_UZ.UTF-8"
	WaBE  LANG = "wa_BE.UTF-8"
	XhZA  LANG = "xh_ZA.UTF-8"
	YiUS  LANG = "yi_US.UTF-8"
	ZhCN  LANG = "zh_CN.UTF-8"
	ZhHK  LANG = "zh_HK.UTF-8"
	ZhSG  LANG = "zh_SG.UTF-8"
	ZhTW  LANG = "zh_TW.UTF-8"
	ZuZA  LANG = "zu_ZA.UTF-8"
)

type Lang

type Lang map[LANG]string

func (Lang) String

func (l Lang) String() string

Returns TrimSpace'd text in the preferred language.

type Output

type Output struct {
	context.Context
	// contains filtered or unexported fields
}

func OutputOf

func OutputOf(ctx context.Context) Output

func (Output) Print

func (o Output) Print(args ...interface{})

func (Output) Printf

func (o Output) Printf(format string, args ...interface{})

func (Output) Println

func (o Output) Println(args ...interface{})

func (Output) ReadFrom

func (o Output) ReadFrom(r io.Reader) (n int64, err error)

func (Output) Value

func (o Output) Value(k interface{}) interface{}

func (Output) Write

func (o Output) Write(data []byte) (int, error)

type Selection

type Selection map[string]Func

func RootOf

func RootOf(ctx context.Context) Selection

func (Selection) Keys

func (m Selection) Keys() []string

func (Selection) Main

func (m Selection) Main()

func (Selection) Select

func (m Selection) Select(ctx context.Context, args ...string) error

func (Selection) Service

func (m Selection) Service(
	ctx context.Context,
	wg *sync.WaitGroup,
	ln net.Listener,
)

type Service

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

func (*Service) Select

func (svc *Service) Select(
	args []string,
	result *string,
) error

type Value

type Value struct {
	V interface{}
}

func (Value) Show

func (val Value) Show(ctx context.Context, _ ...string) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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