cmd

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2024 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

build +linux

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Copyright © 2021 David Guadalupe <guadalupe.david@gmail.com>

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	SUCCESS  = 0
	FAILURE  = 1
	EPARSE   = 2
	ENOTCONF = 3
	ENOTDIR  = 4
	EACCESS  = 5
	EINVAL   = 6
	EALREADY = 16
	// EUSAGE = 66
	// ECOMPILE = 67
	EPERM     = 126
	ENOTFOUND = 127
)

Error codes

View Source
const (
	IOPRIO_CLASS_NONE = iota
	IOPRIO_CLASS_RT
	IOPRIO_CLASS_BE
	IOPRIO_CLASS_IDLE
)
View Source
const (
	IOPRIO_WHO_PROCESS
	IOPRIO_WHO_PGRP
	IOPRIO_WHO_USER
)
View Source
const (
	NONE = iota
	REALTIME
	BEST_EFFORT
	IDLE
)
View Source
const (
	SCHED_OTHER = iota
	SCHED_FIFO
	SCHED_RR
	SCHED_BATCH
	SCHED_ISO
	SCHED_IDLE
	SCHED_DEADLINE
)
View Source
const IOPRIO_CLASS_SHIFT = 13

Variables

View Source
var (
	ErrFailure        = customError{"fail", FAILURE}
	ErrParse          = customError{"cannot parse options", EPARSE}
	ErrNotConfDir     = customError{"unknown directory", ENOTCONF}
	ErrNotDir         = customError{"not a directory", ENOTDIR}
	ErrNotWritableDir = customError{"not writable directory", EACCESS}
	ErrInvalid        = customError{"invalid argument", EINVAL}
	ErrAlready        = customError{"already running", EALREADY}
	ErrPermission     = customError{"permission denied", EPERM}
	ErrNotFound       = customError{"not found", ENOTFOUND}
)
View Source
var CPUSched map[int]string
View Source
var GetScopeOnlyFilterer = GetFilterer

Functions

func ActivePreset added in v0.2.0

func ActivePreset[T Preset](s []T) (elem T)

func ChanFirst added in v0.2.1

func ChanFirst[C chan T, T any](ch C, f func(T) bool) T

func ChanMapFilter added in v0.2.1

func ChanMapFilter[C1 chan T1, C2 chan T2, T1, T2 any](in C1, out C2, f func(T1) (T2, bool))

func Clone added in v0.2.2

func Clone[S ~[]E, E any](s S) S

func Diff added in v0.2.0

func Diff[T BaseStruct](preset T, runtime T) (T, int)

func Execute

func Execute()

Execute adds all child commands to the root command and sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func Filter added in v0.2.0

func Filter[S ~[]E, E any](s S, f func(E) bool) S

func GetCgroup added in v0.2.2

func GetCgroup(pid int) (cgroup string, err error)

func GetOomScoreAdj added in v0.2.2

func GetOomScoreAdj(pid int) (score int, err error)

func GetPreset added in v0.2.0

func GetPreset[T Preset](m map[string][]T, key string, kind string) (T, error)

func GetResource added in v0.2.2

func GetResource(pid int, rc string) ([]byte, error)

func GetStat added in v0.2.2

func GetStat(path string) (stat unix.Stat_t, err error)

func GetStringFromFlags added in v0.2.0

func GetStringFromFlags(fallback string, names ...string) string

func GetUid added in v0.2.2

func GetUid(pid int) int

func GetUser added in v0.2.2

func GetUser(uid int) (*user.User, error)

func HasPreset added in v0.2.0

func HasPreset[T Preset](m map[string][]T, key string) bool

func IOPrio_Get added in v0.2.2

func IOPrio_Get(pid int) (int, error)

func IOPrio_Split added in v0.2.2

func IOPrio_Split(ioprio int, class, data *int)

func IterCache added in v0.2.0

func IterCache[T Preset](m map[string][]T) chan T

func List added in v0.2.0

func List[T Preset](m map[string][]T) (result []string)

func ListFrom added in v0.2.0

func ListFrom[T Preset](m map[string][]T, required string) (result []string)

func LoadConfig added in v0.2.0

func LoadConfig[T Preset](m map[string][]T, f func() chan T)

func LookAll added in v0.2.1

func LookAll(file string) chan string

LookAll searches for all executable named files in the directories named by the PATH environment variable. If file contains a slash, it is tried directly and the PATH is not consulted.

func LookPath added in v0.2.1

func LookPath(file string) string

LookPath looks for a valid executable file outside scripts location.

func Map added in v0.2.0

func Map[S1 ~[]E1, E1, E2 any](s S1, f func(E1) E2) []E2

func Properties added in v0.2.0

func Properties[T BaseStruct](st T) (result []string)

func Reduce added in v0.2.0

func Reduce[S ~[]E, E, T any](s S, init T, f func(T, E) T) T

func ResetMatching added in v0.2.0

func ResetMatching[T1, T2 Struct](st1 *T1, st2 *T2)

ResetMatching iterate through st1 fields and, if set, resets matching fields in st2.

func Reverse added in v0.2.0

func Reverse[S ~[]E, E any](s S) S

func Sched_GetParam added in v0.2.2

func Sched_GetParam(pid int) (int, error)

func Sched_GetScheduler added in v0.2.2

func Sched_GetScheduler(pid int) (int, error)

func ShellJoin added in v0.2.0

func ShellJoin(words ...string) string

func ShellQuote added in v0.2.0

func ShellQuote(words []string) (result []string)

func ShellSplit added in v0.2.0

func ShellSplit(input string) (words []string, err error)

func ToInterface added in v0.2.0

func ToInterface[T Struct](st T) map[string]any

func ToJson added in v0.2.0

func ToJson[T Struct](st T) string

func UpdateRule added in v0.2.0

func UpdateRule[T BaseStruct](st T, rule *Rule)

UpdateRule iterates through st fields and, if set, updates matching fields in rule, if not set yet.

func ValidShell added in v0.2.1

func ValidShell(shell string) (string, error)

Types

type AppGroup added in v0.2.0

type AppGroup struct {
	Profile     Group    `yaml:"profile,omitempty,flow" json:"profile,omitempty"`
	Assignments []string `yaml:"assignments,omitempty,flow" json:"assignments,omitempty"`
}

type AppRule added in v0.2.0

type AppRule struct {
	ProfileKey  string            `yaml:"profile,omitempty" json:"profile,omitempty"`
	Nice        int               `yaml:"nice,omitempty" json:"nice,omitempty"`
	Sched       string            `yaml:"sched,omitempty" json:"sched,omitempty"`
	RTPrio      int               `yaml:"rtprio,omitempty" json:"rtprio,omitempty"`
	IOClass     string            `yaml:"ioclass,omitempty" json:"ioclass,omitempty"`
	IONice      int               `yaml:"ionice,omitempty" json:"ionice,omitempty"`
	OomScoreAdj int               `yaml:"oom_score_adj,omitempty" json:"oom_score_adj,omitempty"`
	CgroupKey   string            `yaml:"cgroup,omitempty" json:"cgroup,omitempty"`
	CPUQuota    string            `yaml:"CPUQuota,omitempty" json:"CPUQuota,omitempty"`
	IOWeight    string            `yaml:"IOWeight,omitempty" json:"IOWeight,omitempty"`
	MemoryHigh  string            `yaml:"MemoryHigh,omitempty" json:"MemoryHigh,omitempty"`
	MemoryMax   string            `yaml:"MemoryMax,omitempty" json:"MemoryMax,omitempty"`
	CmdArgs     []string          `yaml:"cmdargs,omitempty,flow" json:"cmdargs,omitempty"`
	Env         map[string]string `yaml:"env,omitempty,flow" json:"env,omitempty"`
}

func (AppRule) ToRule added in v0.2.0

func (a AppRule) ToRule(key, origin string) Rule

type BaseCgroup added in v0.2.0

type BaseCgroup struct {
	CPUQuota   string `yaml:"CPUQuota,omitempty" json:"CPUQuota,omitempty"`
	IOWeight   string `yaml:"IOWeight,omitempty" json:"IOWeight,omitempty"`
	MemoryHigh string `yaml:"MemoryHigh,omitempty" json:"MemoryHigh,omitempty"`
	MemoryMax  string `yaml:"MemoryMax,omitempty" json:"MemoryMax,omitempty"`
}

func (*BaseCgroup) HasScopeProperties added in v0.2.0

func (c *BaseCgroup) HasScopeProperties() bool

func (*BaseCgroup) ScopeProperties added in v0.2.0

func (c *BaseCgroup) ScopeProperties() (result []string)

type BaseProfile added in v0.2.0

type BaseProfile struct {
	Nice        int    `yaml:"nice,omitempty" json:"nice,omitempty"`
	Sched       string `yaml:"sched,omitempty" json:"sched,omitempty"`
	RTPrio      int    `yaml:"rtprio,omitempty" json:"rtprio,omitempty"`
	IOClass     string `yaml:"ioclass,omitempty" json:"ioclass,omitempty"`
	IONice      int    `yaml:"ionice,omitempty" json:"ionice,omitempty"`
	OomScoreAdj int    `yaml:"oom_score_adj,omitempty" json:"oom_score_adj,omitempty"`
}

type BaseRequest added in v0.2.1

type BaseRequest struct {
	Name    string `json:"name"`
	Path    string `json:"cmd"`
	Preset  string `json:"preset"`
	Shell   string `json:"shell"`
	NumCPU  int    `json:"nproc"`
	MaxNice int    `json:"max_nice"`
}

func NewBaseRequest added in v0.2.1

func NewBaseRequest(name, path, shell string) *BaseRequest

type BaseRule added in v0.2.0

type BaseRule struct {
	// Profile: assign to profile with `ProfileKey`
	// and eventually adjust process properties in Rule
	// Cgroup: assign to cgroup slice with `CgroupKey`
	// and eventually adjust scope properties in Rule
	ProfileKey      string            `yaml:"profile,omitempty" json:"profile,omitempty"`
	CgroupKey       string            `yaml:"cgroup,omitempty" json:"cgroup,omitempty"`
	CmdArgs         []string          `yaml:"cmdargs,omitempty,flow" json:"cmdargs,omitempty"`
	Env             map[string]string `yaml:"env,omitempty,flow" json:"env,omitempty"`
	SliceProperties []string          `yaml:"slice_properties,omitempty,flow" json:"slice_properties,omitempty"`
	Credentials     []string          `yaml:"cred,omitempty,flow" json:"cred,omitempty"`
}

type BaseStruct added in v0.2.2

type BaseStruct interface {
	BaseCgroup | BaseProfile | BaseRule
}

type Cgroup added in v0.2.0

type Cgroup struct {
	BaseCgroup `yaml:"basecgroup,omitempty,flow"`
	CgroupKey  string `yaml:"cgroup,omitempty" json:"cgroup,omitempty"`
	Origin     string `yaml:"origin,omitempty" json:"origin,omitempty"`
}

func (Cgroup) Keys added in v0.2.0

func (c Cgroup) Keys() (string, string)

func (Cgroup) String added in v0.2.0

func (c Cgroup) String() string

type Command added in v0.2.0

type Command struct {
	Tokener
	// contains filtered or unexported fields
}

func ManagerCommand added in v0.2.0

func ManagerCommand(shell string) Command

func NewCommand added in v0.2.0

func NewCommand(s ...string) Command

func SudoCommand added in v0.2.0

func SudoCommand(shell string) Command

func UserTernaryCommand added in v0.2.2

func UserTernaryCommand(shell string, ok string, ko string) Command

func (Command) Copy added in v0.2.0

func (c Command) Copy() Tokener

func (*Command) Exec added in v0.2.0

func (c *Command) Exec(tag string) error

func (*Command) Output added in v0.2.0

func (c *Command) Output() (output []string, err error)

func (*Command) RequireSysCapability added in v0.2.0

func (c *Command) RequireSysCapability() bool

func (*Command) Run added in v0.2.0

func (c *Command) Run(tag string, std *Streams) error

func (*Command) RunJob added in v0.2.1

func (c *Command) RunJob(shell string) (job *ProcJob, args []string, err error)

func (*Command) Runtime added in v0.2.0

func (c *Command) Runtime(pid, uid int) Command

func (*Command) Scan added in v0.2.0

func (c *Command) Scan(std *Streams) Command

func (*Command) Split added in v0.2.1

func (c *Command) Split() (path string, args []string, err error)

func (*Command) Start added in v0.2.0

func (c *Command) Start(tag string, std *Streams) (cmd *exec.Cmd, err error)

func (*Command) StartWait added in v0.2.0

func (c *Command) StartWait(tag string, std *Streams) (err error)

type Config added in v0.2.0

type Config struct {
	Path      string
	Origin    string
	Cgroups   map[string]BaseCgroup `yaml:"cgroups,flow" json:"cgroups"`
	AppGroups map[string]AppGroup   `yaml:"appgroups,flow" json:"appgroups"`
	Rules     map[string]AppRule    `yaml:"rules,flow" json:"rules"`
}

func NewConfig added in v0.2.0

func NewConfig(path string) (Config, error)

func (*Config) IterCgroups added in v0.2.0

func (c *Config) IterCgroups() chan Cgroup

func (*Config) IterProfiles added in v0.2.0

func (c *Config) IterProfiles() chan Profile

func (*Config) IterRules added in v0.2.0

func (c *Config) IterRules() chan Rule

func (*Config) SetOrigin added in v0.2.0

func (c *Config) SetOrigin(path string)

type FilterAny added in v0.2.2

type FilterAny[T any] struct {
	Filter  func(p *T, err error) bool
	Message string
}

type FilterProc added in v0.2.0

type FilterProc = FilterAny[Proc]

type Filterer added in v0.2.2

type Filterer[P Proc | ProcStat] interface {
	Filter(p *P, err error) bool
	String() string
}

func GetFilterer added in v0.2.0

func GetFilterer(scope string) Filterer[Proc]

func NewProcScopeFilter added in v0.2.0

func NewProcScopeFilter(scope string) Filterer[Proc]

type Formatter added in v0.2.2

type Formatter func(p *Proc) string

func GetFormatter added in v0.2.0

func GetFormatter(format string) Formatter

type Group added in v0.2.0

type Group struct {
	CgroupKey   string `yaml:"cgroup,omitempty" json:"cgroup,omitempty"`
	CPUQuota    string `yaml:"CPUQuota,omitempty" json:"CPUQuota,omitempty"`
	IOWeight    string `yaml:"IOWeight,omitempty" json:"IOWeight,omitempty"`
	MemoryHigh  string `yaml:"MemoryHigh,omitempty" json:"MemoryHigh,omitempty"`
	MemoryMax   string `yaml:"MemoryMax,omitempty" json:"MemoryMax,omitempty"`
	Nice        int    `yaml:"nice,omitempty" json:"nice,omitempty"`
	Sched       string `yaml:"sched,omitempty" json:"sched,omitempty"`
	Rtprio      int    `yaml:"rtprio,omitempty" json:"rtprio,omitempty"`
	Ioclass     string `yaml:"ioclass,omitempty" json:"ioclass,omitempty"`
	Ionice      int    `yaml:"ionice,omitempty" json:"ionice,omitempty"`
	OomScoreAdj int    `yaml:"oom_score_adj,omitempty" json:"oom_score_adj,omitempty"`
}

func (*Group) ToProfile added in v0.2.0

func (g *Group) ToProfile(key, origin string) Profile

type Preset added in v0.2.0

type Preset interface {
	Cgroup | Profile | Rule
	Keys() (string, string)
	String() string
}

type PresetCache added in v0.2.0

type PresetCache struct {
	Date       string               `yaml:"date" json:"date"`
	Cgroups    map[string][]Cgroup  `yaml:"cgroups,flow" json:"cgroups"`
	Profiles   map[string][]Profile `yaml:"profiles,flow" json:"profiles"`
	Rules      map[string][]Rule    `yaml:"rules,flow" json:"rules"`
	Origin     string               `yaml:"-" json:"-"`
	RuleFilter FilterProc           `yaml:"-" json:"-"`
}

func GetPresetCache added in v0.2.0

func GetPresetCache() PresetCache

func NewPresetCache added in v0.2.0

func NewPresetCache() PresetCache

func (*PresetCache) Cgroup added in v0.2.0

func (pc *PresetCache) Cgroup(key string) (Cgroup, error)

func (*PresetCache) CgroupCandidate added in v0.2.1

func (pc *PresetCache) CgroupCandidate(base BaseCgroup) (string, bool)

func (*PresetCache) DiffReview added in v0.2.1

func (pc *PresetCache) DiffReview(job *ProcGroupJob) (count int, err error)

func (*PresetCache) Expand added in v0.2.1

func (pc *PresetCache) Expand(rule *Rule) error

func (*PresetCache) FilteredProcs added in v0.2.2

func (pc *PresetCache) FilteredProcs(inputs <-chan []*Proc, outputs chan<- []*Proc, wg *sync.WaitGroup)

func (*PresetCache) GenerateGroupJobs added in v0.2.1

func (pc *PresetCache) GenerateGroupJobs(inputs <-chan []*Proc, output chan<- *ProcGroupJob, wgmain *sync.WaitGroup) (err error)

func (*PresetCache) GenerateJobs added in v0.2.1

func (pc *PresetCache) GenerateJobs(inputs <-chan *Request, outputs chan<- *ProcJob, wgmain *sync.WaitGroup) (err error)

func (*PresetCache) GetContent added in v0.2.0

func (pc *PresetCache) GetContent() ([]byte, error)

func (*PresetCache) GetFilterer added in v0.2.1

func (pc *PresetCache) GetFilterer(scope string) ProcFilterer

func (*PresetCache) HasPreset added in v0.2.0

func (pc *PresetCache) HasPreset(category string, key string) bool

func (*PresetCache) List added in v0.2.0

func (pc *PresetCache) List(category string) (result []string, err error)

func (*PresetCache) ListFrom added in v0.2.0

func (pc *PresetCache) ListFrom(category, origin string) (result []string, err error)

func (*PresetCache) LoadFromCache added in v0.2.0

func (pc *PresetCache) LoadFromCache(cacheFile string) error

func (*PresetCache) LoadFromConfig added in v0.2.0

func (pc *PresetCache) LoadFromConfig() (err error)

func (*PresetCache) Profile added in v0.2.0

func (pc *PresetCache) Profile(key string) (Profile, error)

func (*PresetCache) RawGroupJobs added in v0.2.1

func (pc *PresetCache) RawGroupJobs(inputs <-chan []*Proc, output chan<- *ProcGroupJob, wg *sync.WaitGroup)

func (*PresetCache) RawRule added in v0.2.1

func (pc *PresetCache) RawRule(input *Request) (Rule, error)

func (*PresetCache) RequestJob added in v0.2.1

func (pc *PresetCache) RequestJob(input *Request) *ProcJob

func (*PresetCache) RequestRule added in v0.2.1

func (pc *PresetCache) RequestRule(input *Request) Rule

func (*PresetCache) Rule added in v0.2.0

func (pc *PresetCache) Rule(key string) (Rule, error)

func (*PresetCache) SliceProperties added in v0.2.1

func (pc *PresetCache) SliceProperties(rule Rule) (result []string)

func (*PresetCache) WriteCache added in v0.2.0

func (pc *PresetCache) WriteCache(cacheFile string) error

type Proc added in v0.2.0

type Proc struct {
	ProcStat
	Uid int `json:"uid"`

	Cgroup      string `json:"cgroup"`
	Slice       string `json:"slice"`
	Unit        string `json:"unit"`
	OomScoreAdj int    `json:"oom_score_adj"`
	IOPrioClass int    `json:"ioprio_class"`
	IOPrioData  int    `json:"ionice"`
	// contains filtered or unexported fields
}

func AllProcs added in v0.2.2

func AllProcs() (result []*Proc)

AllProcs returns a slice of Proc for all processes.

func FilteredProcs added in v0.2.0

func FilteredProcs(filter Filterer[Proc]) (result []*Proc)

FilteredProcs returns a slice of Proc for filtered processes.

func GetCalling added in v0.2.0

func GetCalling() *Proc

func NewProc added in v0.2.2

func NewProc(pid int) *Proc

func NewProcFromStat added in v0.2.0

func NewProcFromStat(stat []byte) (p *Proc, err error)

func (*Proc) CPUSchedInfo added in v0.2.2

func (p *Proc) CPUSchedInfo() string

func (*Proc) GetStringMap added in v0.2.2

func (p *Proc) GetStringMap() (result map[string]interface{})

func (*Proc) GoString added in v0.2.2

func (p *Proc) GoString() string

func (*Proc) IOClass added in v0.2.2

func (p *Proc) IOClass() string

func (*Proc) IOSchedInfo added in v0.2.2

func (p *Proc) IOSchedInfo() string

func (*Proc) InSystemSlice added in v0.2.2

func (p *Proc) InSystemSlice() bool

func (*Proc) InUserSlice added in v0.2.2

func (p *Proc) InUserSlice() bool

func (Proc) Json added in v0.2.2

func (p Proc) Json() (result string)

func (Proc) Raw added in v0.2.2

func (p Proc) Raw() string

func (*Proc) Runtime added in v0.2.2

func (p *Proc) Runtime() BaseProfile

func (*Proc) Sched added in v0.2.2

func (p *Proc) Sched() string

func (*Proc) String added in v0.2.2

func (p *Proc) String() string

func (*Proc) Username added in v0.2.2

func (p *Proc) Username() string

func (*Proc) Values added in v0.2.2

func (p *Proc) Values() string

type ProcByPgrp added in v0.2.2

type ProcByPgrp []*Proc

ProcByPgrp implements sort.Interface for []*Proc based on Pgrp field

func (ProcByPgrp) ByPgrp added in v0.2.2

func (s ProcByPgrp) ByPgrp() chan []*Proc

func (ProcByPgrp) Len added in v0.2.2

func (s ProcByPgrp) Len() int

func (ProcByPgrp) Less added in v0.2.2

func (s ProcByPgrp) Less(i, j int) bool

func (ProcByPgrp) Swap added in v0.2.2

func (s ProcByPgrp) Swap(i, j int)

type ProcByPid added in v0.2.2

type ProcByPid []*Proc

ProcByPid implements sort.Interface for []*Proc based on Pid field

func (ProcByPid) Len added in v0.2.2

func (s ProcByPid) Len() int

func (ProcByPid) Less added in v0.2.2

func (s ProcByPid) Less(i, j int) bool

func (ProcByPid) Swap added in v0.2.2

func (s ProcByPid) Swap(i, j int)

type ProcFilter added in v0.2.0

type ProcFilter struct {
	FilterProc
	Scope string
}

func (ProcFilter) Filter added in v0.2.2

func (pf ProcFilter) Filter(p *Proc, err error) bool

func (ProcFilter) String added in v0.2.2

func (pf ProcFilter) String() string

type ProcFilterer added in v0.2.0

type ProcFilterer = Filterer[Proc]

type ProcGroupJob added in v0.2.0

type ProcGroupJob struct {
	Pgrp     int        `json:"pgrp"`
	Pids     []int      `json:"pids"`
	Diff     Rule       `json:"diff"`
	Commands []Command  `json:"commands"`
	Jobs     []*ProcJob `json:"jobs"`
	// contains filtered or unexported fields
}

func (*ProcGroupJob) Add added in v0.2.0

func (job *ProcGroupJob) Add(p *ProcJob) (err error)

func (*ProcGroupJob) LeaderInfo added in v0.2.0

func (job *ProcGroupJob) LeaderInfo() (result string)

func (*ProcGroupJob) PrepareAdjust added in v0.2.0

func (job *ProcGroupJob) PrepareAdjust() error

func (*ProcGroupJob) Run added in v0.2.0

func (job *ProcGroupJob) Run(tag string, std *Streams) error

type ProcJob added in v0.2.0

type ProcJob struct {
	*Proc
	*Request `json:"request"`
	Rule     `json:"rule"`
	Commands []Command `json:"commands"`
}

func NewProcJob added in v0.2.2

func NewProcJob(p *Proc) *ProcJob

func ProcToProcJob added in v0.2.2

func ProcToProcJob(procs []*Proc) []*ProcJob

func (*ProcJob) AddCommand added in v0.2.0

func (job *ProcJob) AddCommand(c Command)

func (*ProcJob) AddExecCmd added in v0.2.0

func (job *ProcJob) AddExecCmd() error

func (*ProcJob) AddProfileCommand added in v0.2.0

func (job *ProcJob) AddProfileCommand(property string, c Command)

func (*ProcJob) AdjustIOClassIONice added in v0.2.0

func (job *ProcJob) AdjustIOClassIONice(pid int) error

func (*ProcJob) AdjustNice added in v0.2.0

func (job *ProcJob) AdjustNice(pid int) error

func (*ProcJob) AdjustOomScoreAdj added in v0.2.0

func (job *ProcJob) AdjustOomScoreAdj(pid int) error

func (*ProcJob) AdjustSchedRTPrio added in v0.2.0

func (job *ProcJob) AdjustSchedRTPrio(pid int) error

func (ProcJob) IsPrivilegeRequired added in v0.2.0

func (job ProcJob) IsPrivilegeRequired(command string) bool

func (ProcJob) IsSudoSet added in v0.2.0

func (job ProcJob) IsSudoSet() bool

func (*ProcJob) NicyExec added in v0.2.1

func (job *ProcJob) NicyExec() string

func (*ProcJob) PrepareCommands added in v0.2.0

func (job *ProcJob) PrepareCommands() error

func (*ProcJob) Run added in v0.2.0

func (job *ProcJob) Run(tag string, args []string, std *Streams) (err error)

func (*ProcJob) Script added in v0.2.1

func (job *ProcJob) Script(shell string) (result []string, err error)

func (*ProcJob) SetPrivilege added in v0.2.0

func (job *ProcJob) SetPrivilege(command string)

func (*ProcJob) SetSudoIfRequired added in v0.2.0

func (job *ProcJob) SetSudoIfRequired()

func (*ProcJob) Show added in v0.2.0

func (job *ProcJob) Show() (result []string, err error)

type ProcStat added in v0.2.2

type ProcStat struct {
	Pid                 int    `json:"pid"`                   // (1) %d *
	Comm                string `json:"comm"`                  // (2) %s *
	State               string `json:"state"`                 // (3) %c *
	Ppid                int    `json:"ppid"`                  // (4) %d *
	Pgrp                int    `json:"pgrp"`                  // (5) %d *
	Session             int    `json:"session"`               // (6) %d
	TtyNr               int    `json:"tty_nr"`                // (7) %d
	TPGid               int    `json:"tpgid"`                 // (8) %d
	Flags               uint   `json:"flags"`                 // (9) %u
	MinFlt              uint   `json:"minflt"`                // (10) %lu
	CMinFlt             uint   `json:"cminflt"`               // (11) %lu
	MajFlt              uint   `json:"majflt"`                // (12) %lu
	CMajFlt             uint   `json:"cmajflt"`               // (13) %lu
	UTime               uint   `json:"utime"`                 // (14) %lu
	STime               uint   `json:"stime"`                 // (15) %lu
	CUTime              int    `json:"cutime"`                // (16) %ld
	CSTime              int    `json:"cstime"`                // (17) %ld
	Priority            int    `json:"priority"`              // (18) %ld *
	Nice                int    `json:"nice"`                  // (19) %ld *
	NumThreads          int    `json:"num_threads"`           // (20) %ld *
	ITRealValue         int    `json:"itrealvalue"`           // (21) %ld
	StartTime           uint64 `json:"starttime"`             // (22) %llu
	VSize               uint   `json:"vsize"`                 // (23) %lu
	Rss                 int    `json:"rss"`                   // (24) %ld
	RssLim              uint   `json:"rsslim"`                // (25) %lu
	StartCode           uint   `json:"startcode"`             // (26) %lu
	EndCode             uint   `json:"endcode"`               // (27) %lu
	StartStack          uint   `json:"startstack"`            // (28) %lu
	KStkESP             uint   `json:"kstkesp"`               // (29) %lu
	KStkEIP             uint   `json:"kstkeip"`               // (30) %lu
	Signal              uint   `json:"signal"`                // (31) %lu
	Blocked             uint   `json:"blocked"`               // (32) %lu
	SigIgnore           uint   `json:"sigignore"`             // (33) %lu
	SigCatch            uint   `json:"sigcatch"`              // (34) %lu
	WChan               uint   `json:"wchan"`                 // (35) %lu
	NSwap               uint   `json:"nswap"`                 // (36) %lu -
	CNSwap              uint   `json:"cnswap"`                // (37) %lu -
	ExitSignal          int    `json:"exit_signal"`           // (38) %d
	Processor           int    `json:"processor"`             // (39) %d
	RTPrio              int    `json:"rtprio"`                // (40) %u *
	Policy              int    `json:"policy"`                // (41) %u *
	DelayAcctBlkIOTicks uint64 `json:"delayacct_blkio_ticks"` // (42) %llu
	GuestTime           uint   `json:"guest_time"`            // (43) %lu
	CGuestTime          int    `json:"cguest_time"`           // ((44) %ld
	StartData           uint   `json:"start_data"`            // (45) %lu
	EndData             uint   `json:"end_data"`              // (46) %lu
	StartBrk            uint   `json:"start_brk"`             // (47) %lu
	ArgStart            uint   `json:"arg_start"`             // (48) %lu
	ArgEnd              uint   `json:"arg_end"`               // (49) %lu
	EnvStart            uint   `json:"env_start"`             // (50) %lu
	EnvEnd              uint   `json:"env_end"`               // (51) %lu
	ExitCode            int    `json:"exit_code"`             // (52) %d
	// contains filtered or unexported fields
}

func (*ProcStat) CPUTime added in v0.2.2

func (stat *ProcStat) CPUTime() float64

CPUTime returns the total CPU user and system time in seconds.

func (*ProcStat) GoString added in v0.2.2

func (stat *ProcStat) GoString() string

func (*ProcStat) Read added in v0.2.2

func (stat *ProcStat) Read(pid int) error

func (*ProcStat) String added in v0.2.2

func (stat *ProcStat) String() string

func (*ProcStat) UnmarshalText added in v0.2.2

func (stat *ProcStat) UnmarshalText(buffer []byte) (err error)

type Profile added in v0.2.0

type Profile struct {
	// Cgroup: assign to cgroup slice with `CgroupKey`
	// and eventually adjust scope properties in BaseCgroup
	BaseCgroup  `yaml:"basecgroup,omitempty,flow"`
	BaseProfile `yaml:"baseprofile,omitempty,flow"`
	CgroupKey   string `yaml:"cgroup,omitempty" json:"cgroup,omitempty"`
	ProfileKey  string `yaml:"profile,omitempty" json:"profile,omitempty"`
	Origin      string `yaml:"origin,omitempty" json:"origin,omitempty"`
}

func (Profile) Keys added in v0.2.0

func (p Profile) Keys() (string, string)

func (Profile) String added in v0.2.0

func (p Profile) String() string

func (*Profile) ToRule added in v0.2.0

func (p *Profile) ToRule() Rule

type Request added in v0.2.1

type Request struct {
	*BaseRequest
	*Proc
	CgroupKey   string `json:"cgroup"`
	ForceCgroup bool   `json:"probe_cgroup"`
	Managed     bool   `json:"managed"`
	Quiet       bool   `json:"quiet"`
	Verbosity   int    `json:"verbosity"`
}

func NewPathRequest added in v0.2.1

func NewPathRequest(path, shell string) *Request

func NewRequest added in v0.2.2

func NewRequest(name, path, shell string) *Request

func (*Request) MergeFlags added in v0.2.1

func (r *Request) MergeFlags()

type Rule added in v0.2.0

type Rule struct {
	BaseProfile `yaml:"baseprofile,omitempty,flow"`
	BaseCgroup  `yaml:"basecgroup,omitempty,flow"`
	BaseRule    `yaml:"baserule,omitempty,flow"`
	RuleKey     string `yaml:"name,omitempty" json:"name,omitempty"`
	Origin      string `yaml:"origin,omitempty" json:"origin,omitempty"`
}

func (*Rule) CgroupEntries added in v0.2.0

func (r *Rule) CgroupEntries() (BaseCgroup, bool)

func (*Rule) CgroupOnly added in v0.2.0

func (r *Rule) CgroupOnly()

func (*Rule) Copy added in v0.2.0

func (r *Rule) Copy() Rule

func (*Rule) GetCredentials added in v0.2.0

func (r *Rule) GetCredentials() (result []string)

func (*Rule) GetDiff added in v0.2.0

func (r *Rule) GetDiff(runtime Rule) (Rule, int)

func (*Rule) HasCPUQuota added in v0.2.0

func (r *Rule) HasCPUQuota() bool

func (*Rule) HasCgroupKey added in v0.2.0

func (r *Rule) HasCgroupKey() bool

func (*Rule) HasIOWeight added in v0.2.0

func (r *Rule) HasIOWeight() bool

func (*Rule) HasIoclass added in v0.2.0

func (r *Rule) HasIoclass() bool

func (*Rule) HasIonice added in v0.2.0

func (r *Rule) HasIonice() bool

func (*Rule) HasMemoryHigh added in v0.2.0

func (r *Rule) HasMemoryHigh() bool

func (*Rule) HasMemoryMax added in v0.2.0

func (r *Rule) HasMemoryMax() bool

func (*Rule) HasNice added in v0.2.0

func (r *Rule) HasNice() bool

func (*Rule) HasOomScoreAdj added in v0.2.0

func (r *Rule) HasOomScoreAdj() bool

func (*Rule) HasProfileKey added in v0.2.0

func (r *Rule) HasProfileKey() bool

func (*Rule) HasRtprio added in v0.2.0

func (r *Rule) HasRtprio() bool

func (*Rule) HasSched added in v0.2.0

func (r *Rule) HasSched() bool

func (Rule) Keys added in v0.2.0

func (r Rule) Keys() (string, string)

func (*Rule) NeedScope added in v0.2.0

func (r *Rule) NeedScope() bool

func (Rule) Path added in v0.2.1

func (r Rule) Path() string

func (*Rule) SetCgroup added in v0.2.0

func (r *Rule) SetCgroup(cgroup string)

func (*Rule) SetCredentials added in v0.2.0

func (r *Rule) SetCredentials()

func (*Rule) SetSliceProperties added in v0.2.0

func (r *Rule) SetSliceProperties(properties []string)

func (Rule) String added in v0.2.0

func (r Rule) String() string

type Sched_Param added in v0.2.2

type Sched_Param struct {
	Sched_Priority int
}

type SchedulingPolicy added in v0.2.2

type SchedulingPolicy struct {
	Class           map[int]string
	NeedPriority    []int
	NeedCredentials []int
	Low             int
	High            int
	None            int
}
var CPU SchedulingPolicy = SchedulingPolicy{
	Class: map[int]string{
		0: "SCHED_OTHER",
		1: "SCHED_FIFO",
		2: "SCHED_RR",
		3: "SCHED_BATCH",

		5: "SCHED_IDLE",
		6: "SCHED_DEADLINE",
	},
	NeedPriority:    []int{1, 2},
	NeedCredentials: []int{1, 2},
	Low:             1,
	High:            99,
	None:            0,
}
var IO SchedulingPolicy = SchedulingPolicy{
	Class: map[int]string{
		0: "none",
		1: "realtime",
		2: "best-effort",
		3: "idle",
	},
	NeedPriority:    []int{1, 2},
	NeedCredentials: []int{1},
	Low:             7,
	High:            0,
	None:            4,
}

type Script

type Script []Command

func (Script) String added in v0.2.0

func (s Script) String() string

type Streams added in v0.2.0

type Streams struct {
	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer
}

type Struct added in v0.2.0

type Struct interface {
	BaseCgroup | Cgroup | BaseProfile | Profile | BaseRule | Rule
}

type Tokener added in v0.2.0

type Tokener interface {
	Len() int
	Copy() Tokener
	Append(s ...string) Tokener
	Prepend(s ...string) Tokener
	Content() []string
	IsEmpty() bool
	Index(pos int) string
	ShellCmd() string
	String() string
	WriteTo(dest io.Writer) (n int, err error)
}

type Tokens added in v0.2.0

type Tokens []string

func (Tokens) Append added in v0.2.0

func (t Tokens) Append(s ...string) Tokener

func (Tokens) Content added in v0.2.0

func (t Tokens) Content() []string

func (Tokens) Copy added in v0.2.0

func (t Tokens) Copy() Tokener

func (Tokens) Index added in v0.2.0

func (t Tokens) Index(pos int) (result string)

func (Tokens) IsEmpty added in v0.2.0

func (t Tokens) IsEmpty() bool

func (Tokens) Len added in v0.2.0

func (t Tokens) Len() int

func (Tokens) Prepend added in v0.2.0

func (t Tokens) Prepend(s ...string) Tokener

func (Tokens) ShellCmd added in v0.2.0

func (t Tokens) ShellCmd() string

func (Tokens) String added in v0.2.0

func (t Tokens) String() string

func (Tokens) WriteTo added in v0.2.0

func (t Tokens) WriteTo(dest io.Writer) (n int, err error)

Jump to

Keyboard shortcuts

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