本文整理汇总了Golang中github.com/derekparker/delve/service.Client.ListSources方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.ListSources方法的具体用法?Golang Client.ListSources怎么用?Golang Client.ListSources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/derekparker/delve/service.Client
的用法示例。
在下文中一共展示了Client.ListSources方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: sources
func sources(client service.Client, filter string) ([]string, error) {
return client.ListSources(filter)
}
示例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
}