当前位置: 首页>>代码示例>>Golang>>正文


Golang tabular.StrIn函数代码示例

本文整理汇总了Golang中github.com/CiscoCloud/distributive/tabular.StrIn函数的典型用法代码示例。如果您正苦于以下问题:Golang StrIn函数的具体用法?Golang StrIn怎么用?Golang StrIn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了StrIn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: getIPWorker

// getIPWorker(exitCode int, exitMessage string) is an abstraction of Ip4 and Ip6
func getIPWorker(name string, address string, version int) (exitCode int, exitMessage string) {
	ips := getInterfaceIPs(name, version)
	if tabular.StrIn(address, ips) {
		return 0, ""
	}
	return wrkutils.GenericError("Interface does not have IP", address, ips)
}
开发者ID:orimarti,项目名称:distributive,代码行数:8,代码来源:network.go

示例2: RoutingTableMatch

// RoutingTableMatch asks: Is this value in this column of the routing table?
func RoutingTableMatch(col string, str string) (int, string, error) {
	column := RoutingTableColumn(col)
	if tabular.StrIn(str, column) {
		return errutil.Success()
	}
	return errutil.GenericError("Not found in routing table", str, column)
}
开发者ID:allenbhuiyan,项目名称:distributive,代码行数:8,代码来源:network.go

示例3: routingTableMatch

// routingTableMatch(exitCode int, exitMessage string) constructs a Worker that returns whether or not the
// given string was found in the given column of the routing table. It is an
// astraction of routingTableDestination, routingTableInterface, and
// routingTableGateway
func routingTableMatch(col string, str string) (exitCode int, exitMessage string) {
	column := routingTableColumn(col)
	if tabular.StrIn(str, column) {
		return 0, ""
	}
	return wrkutils.GenericError("Not found in routing table", str, column)
}
开发者ID:orimarti,项目名称:distributive,代码行数:11,代码来源:network.go

示例4: timersWorker

// timers(exitCode int, exitMessage string) is pure DRY for systemctlTimer and systemctlTimerLoaded
func timersWorker(unit string, all bool) (exitCode int, exitMessage string) {
	timers := getTimers(all)
	if tabular.StrIn(unit, timers) {
		return 0, ""
	}
	return wrkutils.GenericError("Timer not found", unit, timers)
}
开发者ID:pinterb,项目名称:distributive,代码行数:8,代码来源:systemctl.go

示例5: timerCheck

// timerCheck is pure DRY for SystemctlTimer and SystemctlTimerLoaded
func timerCheck(unit string, all bool) (int, string, error) {
	timers, err := systemdstatus.Timers(all)
	if err != nil {
		return 1, "", err
	} else if tabular.StrIn(unit, timers) {
		return errutil.Success()
	}
	return errutil.GenericError("Timer not found", unit, timers)
}
开发者ID:allenbhuiyan,项目名称:distributive,代码行数:10,代码来源:systemctl.go

示例6: Status

func (chk SystemctlSockListening) Status() (int, string, error) {
	listening, err := systemdstatus.ListeningSockets()
	if err != nil {
		return 1, "", err
	}
	if tabular.StrIn(chk.path, listening) {
		return errutil.Success()
	}
	return errutil.GenericError("Socket wasn't listening", chk.path, listening)
}
开发者ID:allenbhuiyan,项目名称:distributive,代码行数:10,代码来源:systemctl.go

示例7: Status

func (chk DockerImage) Status() (int, string, error) {
	images, err := dockerstatus.DockerImageRepositories()
	if err != nil {
		return 1, "", err
	}
	if tabular.StrIn(chk.name, images) {
		return errutil.Success()
	}
	return errutil.GenericError("Docker image was not found", chk.name, images)
}
开发者ID:allenbhuiyan,项目名称:distributive,代码行数:10,代码来源:docker.go

示例8: TestGetManager

func TestGetManager(t *testing.T) {
	t.Parallel()
	man := getManager()
	supported := []string{"pacman", "dpkg", "rpm"}
	if !tabular.StrIn(man, supported) {
		msg := "getManager returned an unsupported package manager"
		msg += "\n\tReturned: " + man
		msg += "\n\tSupported: " + fmt.Sprint(supported)
		t.Error(msg)
	}
}
开发者ID:TanyaCouture,项目名称:distributive,代码行数:11,代码来源:packages_test.go

示例9: UserInGroup

// UserInGroup asks whether or not the given user is a part of the given group.
func UserInGroup(username, groupname string) (bool, error) {
	groups, err := Groups()
	if err != nil {
		return false, err
	}
	for _, group := range groups {
		if group.Name == groupname && tabular.StrIn(username, group.Users) {
			return true, nil
		}
	}
	return false, nil
}
开发者ID:allenbhuiyan,项目名称:distributive,代码行数:13,代码来源:usrstatus.go

示例10: systemctlSock

// systemctlSock is an abstraction of systemctlSockPath and systemctlSockUnit,
// it reads from `systemctl list-sockets` and sees if the value is in the
// appropriate column.
func systemctlSock(value string, column string) (exitCode int, exitMessage string) {
	outstr := wrkutils.CommandOutput(exec.Command("systemctl", "list-sockets"))
	lines := tabular.Lines(outstr)
	msg := "systemctl list-sockers didn't output enough rows"
	wrkutils.IndexError(msg, len(lines)-4, lines)
	unlines := tabular.Unlines(lines[:len(lines)-4])
	table := tabular.SeparateOnAlignment(unlines)
	values := tabular.GetColumnByHeader(column, table)
	if tabular.StrIn(value, values) {
		return 0, ""
	}
	return wrkutils.GenericError("Socket not found", value, values)
}
开发者ID:pinterb,项目名称:distributive,代码行数:16,代码来源:systemctl.go

示例11: Status

func (chk Module) Status() (int, string, error) {
	// kernelModules returns a list of all Modules that are currently loaded
	// TODO just read from /proc/Modules
	kernelModules := func() (Modules []string) {
		cmd := exec.Command("/sbin/lsmod")
		return chkutil.CommandColumnNoHeader(0, cmd)
	}
	Modules := kernelModules()
	if tabular.StrIn(chk.name, Modules) {
		return errutil.Success()
	}
	return errutil.GenericError("Module is not loaded", chk.name, Modules)
}
开发者ID:nyanshak,项目名称:distributive,代码行数:13,代码来源:misc.go

示例12: New

func (chk SystemctlUnitFileStatus) New(params []string) (chkutil.Check, error) {
	if len(params) != 2 {
		return chk, errutil.ParameterLengthError{2, params}
	}
	validStatuses := []string{"static", "enabled", "disabled"}
	if !tabular.StrIn(strings.ToLower(params[1]), validStatuses) {
		validStatusesStr := "static | enabled | disabled"
		return chk, errutil.ParameterTypeError{params[1], validStatusesStr}
	}
	chk.unit = params[0]
	chk.status = params[1]
	return chk, nil
}
开发者ID:allenbhuiyan,项目名称:distributive,代码行数:13,代码来源:systemctl.go

示例13: userInGroup

// userInGroup checks whether or not a given user is in a given group
func userInGroup(parameters []string) (exitCode int, exitMessage string) {
	user := parameters[0]
	group := parameters[0]
	groups := getGroups()
	for _, g := range groups {
		if g.Name == group {
			if tabular.StrIn(user, g.Users) {
				return 0, ""
			}
			return wrkutils.GenericError("User not found in group", user, g.Users)
		}
	}
	return groupNotFound(group)
}
开发者ID:pinterb,项目名称:distributive,代码行数:15,代码来源:users-and-groups.go

示例14: module

// module checks to see if a kernel module is installed
func module(parameters []string) (exitCode int, exitMessage string) {
	// kernelModules returns a list of all modules that are currently loaded
	// TODO just read from /proc/modules
	kernelModules := func() (modules []string) {
		cmd := exec.Command("/sbin/lsmod")
		return wrkutils.CommandColumnNoHeader(0, cmd)
	}
	name := parameters[0]
	modules := kernelModules()
	if tabular.StrIn(name, modules) {
		return 0, ""
	}
	return wrkutils.GenericError("Module is not loaded", name, modules)
}
开发者ID:pinterb,项目名称:distributive,代码行数:15,代码来源:misc.go

示例15: New

func (chk RepoExistsURI) New(params []string) (chkutil.Check, error) {
	if len(params) != 2 {
		return chk, errutil.ParameterLengthError{2, params}
	}
	re, err := regexp.Compile(params[1])
	if err != nil {
		return chk, errutil.ParameterTypeError{params[1], "regexp"}
	}
	chk.re = re
	if !tabular.StrIn(params[0], keys) {
		return chk, errutil.ParameterTypeError{params[0], "package manager"}
	}
	chk.manager = params[0]
	return chk, nil
}
开发者ID:TanyaCouture,项目名称:distributive,代码行数:15,代码来源:packages.go


注:本文中的github.com/CiscoCloud/distributive/tabular.StrIn函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。