本文整理汇总了Golang中camlistore/org/pkg/cmdmain.Errorf函数的典型用法代码示例。如果您正苦于以下问题:Golang Errorf函数的具体用法?Golang Errorf怎么用?Golang Errorf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Errorf函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: run
func (c *fixvCmd) run(args []string) (tofix []string, err error) {
var vendoredFiles []string
if len(args) != 0 {
vendoredFiles = args
} else {
repo, err := repoRoot()
if err != nil {
return nil, err
}
if !strings.HasSuffix(repo, string(filepath.Separator)) {
repo += string(filepath.Separator)
}
out, err := cmdOutputDirErr(".", "git", "diff-index", "--name-only", "--diff-filter=ACM", "--cached", "HEAD", "--")
if err != nil {
return nil, err
}
vendoredFiles = addRoot(repo, filter(isVendored, nonBlankLines(out)))
if len(vendoredFiles) == 0 {
return nil, nil
}
}
re := regexp.MustCompile(`("` + strings.Join(vendoredNames, `/|"`) + `/)`)
for _, filename := range vendoredFiles {
data, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
if m := re.Find(data); m == nil {
continue
}
if !c.fix {
cmdmain.Errorf("%v imports need fixing\n", filename)
tofix = append(tofix, filename)
continue
}
for _, importName := range vendoredNames {
re := regexp.MustCompile(`"(` + importName + "/)")
data = re.ReplaceAll(data, []byte(`"`+vendoringPath+`$1`))
}
if err := ioutil.WriteFile(filename, data, 0600); err != nil {
return nil, fmt.Errorf("failed to write modified file %v: %v", filename, err)
}
cmdmain.Errorf("%v imports now fixed\n", filename)
}
if !c.fix && len(tofix) > 0 {
return tofix, errImportsNeedsFixing
}
return nil, nil
}
示例2: exitf
func exitf(format string, args ...interface{}) {
if !strings.HasSuffix(format, "\n") {
format = format + "\n"
}
cmdmain.Errorf(format, args)
cmdmain.Exit(1)
}
示例3: formattedSearchHelp
func formattedSearchHelp() {
s := search.SearchHelp()
type help struct{ Name, Description string }
h := []help{}
err := json.Unmarshal([]byte(s), &h)
if err != nil {
cmdmain.Errorf("%v", err)
os.Exit(1)
}
w := new(tabwriter.Writer)
w.Init(cmdmain.Stdout, 0, 8, 0, '\t', 0)
fmt.Fprintln(w, "Predicates for search expressions")
fmt.Fprintln(w)
fmt.Fprintln(w, "Predicate\tDescription")
fmt.Fprintln(w)
for _, predicate := range h {
desc := strings.Split(predicate.Description, "\n")
for i, d := range desc {
if i == 0 {
fmt.Fprintf(w, "%s\t%s\n", predicate.Name, d)
} else {
fmt.Fprintf(w, "\t%s\n", d)
}
}
}
w.Flush()
}
示例4: handleResult
func handleResult(what string, pr *client.PutResult, err error) error {
if err != nil {
cmdmain.Errorf("Error putting %s: %s\n", what, err)
cmdmain.ExitWithFailure = true
return err
}
fmt.Fprintln(cmdmain.Stdout, pr.BlobRef.String())
return nil
}
示例5: printf
func printf(format string, args ...interface{}) {
cmdmain.Errorf(format, args...)
}
示例6: Usage
func (c *attrCmd) Usage() {
cmdmain.Errorf("Usage: camput [globalopts] attr [attroption] <permanode> <name> <value>")
}
示例7: Usage
func (c *permanodeCmd) Usage() {
cmdmain.Errorf("Usage: camput [globalopts] permanode [permanodeopts]\n")
}
示例8: Usage
func (c *rawCmd) Usage() {
cmdmain.Errorf("Usage: camput [globalopts] rawobj [rawopts]\n")
}
示例9: Usage
func (c *fixvCmd) Usage() {
cmdmain.Errorf("Usage: devcam [globalopts] fixv [args...]\n")
}
示例10: Usage
func (c *deleteCmd) Usage() {
cmdmain.Errorf("Usage: camput [globalopts] delete <blobref1> [blobref2]...")
}
示例11: Usage
func (c *searchDocCmd) Usage() {
cmdmain.Errorf("camtool searchdoc")
}