本文整理匯總了Golang中github.com/derekparker/delve/service.Client.ListLocalVariables方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.ListLocalVariables方法的具體用法?Golang Client.ListLocalVariables怎麽用?Golang Client.ListLocalVariables使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/derekparker/delve/service.Client
的用法示例。
在下文中一共展示了Client.ListLocalVariables方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: locals
func locals(client service.Client, scope api.EvalScope, filter string) ([]string, error) {
locals, err := client.ListLocalVariables(scope)
if err != nil {
return nil, err
}
return filterVariables(locals, filter), nil
}
示例2: info
func info(client service.Client, args ...string) error {
if len(args) == 0 {
return fmt.Errorf("not enough arguments. expected info type [regex].")
}
// Allow for optional regex
var filter *regexp.Regexp
if len(args) >= 2 {
var err error
if filter, err = regexp.Compile(args[1]); err != nil {
return fmt.Errorf("invalid filter argument: %s", err.Error())
}
}
var data []string
switch args[0] {
case "sources":
regex := ""
if len(args) >= 2 && len(args[1]) > 0 {
regex = args[1]
}
sources, err := client.ListSources(regex)
if err != nil {
return err
}
data = sources
case "funcs":
regex := ""
if len(args) >= 2 && len(args[1]) > 0 {
regex = args[1]
}
funcs, err := client.ListFunctions(regex)
if err != nil {
return err
}
data = funcs
case "regs":
regs, err := client.ListRegisters()
if err != nil {
return err
}
data = append(data, regs)
case "args":
args, err := client.ListFunctionArgs()
if err != nil {
return err
}
data = filterVariables(args, filter)
case "locals":
locals, err := client.ListLocalVariables()
if err != nil {
return err
}
data = filterVariables(locals, filter)
case "vars":
regex := ""
if len(args) >= 2 && len(args[1]) > 0 {
regex = args[1]
}
vars, err := client.ListPackageVariables(regex)
if err != nil {
return err
}
data = filterVariables(vars, filter)
default:
return fmt.Errorf("unsupported info type, must be args, funcs, locals, sources or vars")
}
// sort and output data
sort.Sort(sort.StringSlice(data))
for _, d := range data {
fmt.Println(d)
}
return nil
}