本文整理汇总了Golang中github.com/gpmgo/gopm/modules/errors.SetError函数的典型用法代码示例。如果您正苦于以下问题:Golang SetError函数的具体用法?Golang SetError怎么用?Golang SetError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: runTest
func runTest(ctx *cli.Context) {
if err := setup(ctx); err != nil {
errors.SetError(err)
return
}
os.RemoveAll(setting.DefaultVendor)
if !setting.Debug {
defer os.RemoveAll(setting.DefaultVendor)
}
if err := linkVendors(ctx, ""); err != nil {
errors.SetError(err)
return
}
log.Info("Testing...")
cmdArgs := []string{"go", "test"}
cmdArgs = append(cmdArgs, ctx.Args()...)
if err := execCmd(setting.DefaultVendor, setting.WorkDir, cmdArgs...); err != nil {
errors.SetError(fmt.Errorf("fail to run program: %v", err))
return
}
log.Info("Command executed successfully!")
}
示例2: runConfigUnset
func runConfigUnset(ctx *cli.Context) {
if err := setup(ctx); err != nil {
errors.SetError(err)
return
}
if len(ctx.Args()) != 1 {
errors.SetError(fmt.Errorf("Incorrect number of arguments for command: should have 1"))
return
}
var err error
switch ctx.Args().First() {
case "proxy":
err = setting.DeleteConfigOption("settings", "HTTP_PROXY")
case "github":
if err = setting.DeleteConfigOption("github", "CLIENT_ID"); err != nil {
errors.SetError(err)
return
}
err = setting.DeleteConfigOption("github", "CLIENT_SECRET")
}
if err != nil {
errors.SetError(err)
return
}
}
示例3: runList
func runList(ctx *cli.Context) {
if err := setup(ctx); err != nil {
errors.SetError(err)
return
}
if !setting.HasGOPATHSetting && !base.IsFile(setting.DefaultGopmfile) {
log.Warn("Dependency list may contain package itself without GOPATH setting and gopmfile.")
}
gf, target, err := parseGopmfile(setting.DefaultGopmfile)
if err != nil {
errors.SetError(err)
return
}
list, err := getDepList(ctx, target, setting.WorkDir, setting.DefaultVendor)
if err != nil {
errors.SetError(err)
return
}
fmt.Printf("Dependency list (%d):\n", len(list))
for _, name := range list {
fmt.Printf("-> %s%s\n", name, verSuffix(gf, name))
}
}
示例4: runTest
func runTest(ctx *cli.Context) {
if err := setup(ctx); err != nil {
errors.SetError(err)
return
}
if err := linkVendors(ctx, ""); err != nil {
errors.SetError(err)
return
}
log.Info("Testing...")
cmdArgs := []string{"go", "test"}
if len(ctx.String("tags")) > 0 {
cmdArgs = append(cmdArgs, "-tags")
cmdArgs = append(cmdArgs, ctx.String("tags"))
}
if ctx.IsSet("verbose") {
cmdArgs = append(cmdArgs, "-v")
}
cmdArgs = append(cmdArgs, ctx.Args()...)
if err := execCmd(setting.DefaultVendor, setting.WorkDir, cmdArgs...); err != nil {
errors.SetError(fmt.Errorf("fail to run program: %v", err))
return
}
log.Info("Command executed successfully!")
}
示例5: runGet
func runGet(ctx *cli.Context) {
if err := setup(ctx); err != nil {
errors.SetError(err)
return
}
// Check option conflicts.
hasConflict := false
names := ""
switch {
case ctx.Bool("local") && ctx.Bool("gopath"):
hasConflict = true
names = "'--local, -l' and '--gopath, -g'"
case ctx.Bool("local") && ctx.Bool("remote"):
hasConflict = true
names = "'--local, -l' and '--remote, -r'"
case ctx.Bool("gopath") && ctx.Bool("remote"):
hasConflict = true
names = "'--gopath, -g' and '--remote, -r'"
}
if hasConflict {
errors.SetError(fmt.Errorf("Command options have conflicts: %s", names))
return
}
var err error
// Check number of arguments to decide which function to call.
if len(ctx.Args()) == 0 {
if ctx.Bool("download") {
errors.SetError(fmt.Errorf("Not enough arguments for option: '--download, -d'"))
return
}
err = getByGopmfile(ctx)
} else {
err = getByPaths(ctx)
}
if err != nil {
errors.SetError(err)
return
}
if len(ctx.Args()) > 0 && ctx.Bool("save") {
gf, _, err := parseGopmfile(setting.GOPMFILE)
if err != nil {
errors.SetError(err)
return
}
for _, info := range ctx.Args() {
if i := strings.Index(info, "@"); i > -1 {
gf.SetValue("deps", info[:i], info[i+1:])
} else {
gf.SetValue("deps", info, "")
}
}
setting.SaveGopmfile(gf, setting.GOPMFILE)
}
}
示例6: runBuild
func runBuild(ctx *cli.Context) {
if err := setup(ctx); err != nil {
errors.SetError(err)
return
}
if err := buildBinary(ctx, ctx.Args()...); err != nil {
errors.SetError(err)
return
}
log.Info("Command executed successfully!")
}
示例7: runConfigSetProxy
func runConfigSetProxy(ctx *cli.Context) {
if err := setup(ctx); err != nil {
errors.SetError(err)
return
}
if len(ctx.Args()) != 1 {
errors.SetError(fmt.Errorf("Incorrect number of arguments for command: should have 1"))
return
}
if err := setting.SetConfigValue("settings", "HTTP_PROXY", ctx.Args().First()); err != nil {
errors.SetError(err)
return
}
}
示例8: runClean
func runClean(ctx *cli.Context) {
if err := setup(ctx); err != nil {
errors.SetError(err)
return
}
os.RemoveAll(setting.DefaultVendor)
}
示例9: runBuild
func runBuild(ctx *cli.Context) {
if err := setup(ctx); err != nil {
errors.SetError(err)
return
}
os.RemoveAll(setting.DefaultVendor)
if !setting.Debug {
defer os.RemoveAll(setting.DefaultVendor)
}
if err := buildBinary(ctx, ctx.Args()...); err != nil {
errors.SetError(err)
return
}
log.Info("Command executed successfully!")
}
示例10: runExec
func runExec(ctx *cli.Context) {
if err := setup(ctx); err != nil {
errors.SetError(err)
return
}
// TODO: download and build command
// TODO: exec command
}
示例11: runConfigSetGitHub
func runConfigSetGitHub(ctx *cli.Context) {
if err := setup(ctx); err != nil {
errors.SetError(err)
return
}
if len(ctx.Args()) != 2 {
errors.SetError(fmt.Errorf("Incorrect number of arguments for command: should have 2"))
return
}
if err := setting.SetConfigValue("github", "CLIENT_ID", ctx.Args().First()); err != nil {
errors.SetError(err)
return
}
if err := setting.SetConfigValue("github", "CLIENT_SECRET", ctx.Args().Get(1)); err != nil {
errors.SetError(err)
return
}
}
示例12: runClean
func runClean(ctx *cli.Context) {
if err := setup(ctx); err != nil {
errors.SetError(err)
return
}
os.RemoveAll(path.Join(setting.HomeDir, ".gopm/temp"))
if ctx.Bool("all") {
os.RemoveAll(setting.InstallRepoPath)
}
}
示例13: runConfigGet
func runConfigGet(ctx *cli.Context) {
if err := setup(ctx); err != nil {
errors.SetError(err)
return
}
if len(ctx.Args()) != 1 {
errors.SetError(fmt.Errorf("Incorrect number of arguments for command: should have 1"))
return
}
switch ctx.Args().First() {
case "proxy":
fmt.Printf("[%s]\n", "settings")
showSettingString("settings", "HTTP_PROXY")
case "github":
fmt.Printf("[%s]\n", "github")
showSettingString("github", "CLIENT_ID")
showSettingString("github", "CLIENT_SECRET")
}
}
示例14: runGet
func runGet(ctx *cli.Context) {
if err := setup(ctx); err != nil {
errors.SetError(err)
return
}
// Check option conflicts.
hasConflict := false
names := ""
switch {
case ctx.Bool("local") && ctx.Bool("gopath"):
hasConflict = true
names = "'--local, -l' and '--gopath, -g'"
case ctx.Bool("local") && ctx.Bool("remote"):
hasConflict = true
names = "'--local, -l' and '--remote, -r'"
case ctx.Bool("gopath") && ctx.Bool("remote"):
hasConflict = true
names = "'--gopath, -g' and '--remote, -r'"
}
if hasConflict {
errors.SetError(fmt.Errorf("Command options have conflicts: %s", names))
return
}
var err error
// Check number of arguments to decide which function to call.
if len(ctx.Args()) == 0 {
if ctx.Bool("download") {
errors.SetError(fmt.Errorf("Not enough arguments for option: '--download, -d'"))
return
}
err = getByGopmfile(ctx)
} else {
err = getByPaths(ctx)
}
if err != nil {
errors.SetError(err)
}
}
示例15: runInstall
func runInstall(ctx *cli.Context) {
if err := setup(ctx); err != nil {
errors.SetError(err)
return
}
os.RemoveAll(setting.DefaultVendor)
if !setting.Debug {
defer os.RemoveAll(setting.DefaultVendor)
}
if err := linkVendors(ctx, ""); err != nil {
errors.SetError(err)
return
}
// Get target name.
gfPath := path.Join(setting.WorkDir, setting.GOPMFILE)
_, target, err := parseGopmfile(gfPath)
if err != nil {
errors.SetError(fmt.Errorf("fail to parse gopmfile: %v", err))
return
}
log.Info("Installing...")
cmdArgs := []string{"go", "install"}
if ctx.Bool("verbose") {
cmdArgs = append(cmdArgs, "-v")
}
cmdArgs = append(cmdArgs, target)
if err := execCmd(setting.DefaultVendor, setting.WorkDir, cmdArgs...); err != nil {
errors.SetError(fmt.Errorf("fail to run program: %v", err))
return
}
log.Info("Command executed successfully!")
}