當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。