本文整理汇总了Golang中v/io/jiri/profiles.DB.LookupProfileTarget方法的典型用法代码示例。如果您正苦于以下问题:Golang DB.LookupProfileTarget方法的具体用法?Golang DB.LookupProfileTarget怎么用?Golang DB.LookupProfileTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v/io/jiri/profiles.DB
的用法示例。
在下文中一共展示了DB.LookupProfileTarget方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: ensureAction
// ensureAction ensures that the requested profile and target
// is installed/uninstalled, installing/uninstalling it if and only if necessary.
func ensureAction(jirix *jiri.X, pdb *profiles.DB, action profiles.Action, installer, profile string, root jiri.RelPath, target profiles.Target) error {
verb := ""
switch action {
case profiles.Install:
verb = "install"
case profiles.Uninstall:
verb = "uninstall"
default:
return fmt.Errorf("unrecognised action %v", action)
}
if jirix.Verbose() {
fmt.Fprintf(jirix.Stdout(), "%s %v %s\n", verb, action, target)
}
if t := pdb.LookupProfileTarget(installer, profile, target); t != nil {
if jirix.Verbose() {
fmt.Fprintf(jirix.Stdout(), "%v %v is already %sed as %v\n", profile, target, verb, t)
}
return nil
}
mgr := LookupManager(profiles.QualifiedProfileName(installer, profile))
if mgr == nil {
return fmt.Errorf("profile %v is not supported", profile)
}
version, err := mgr.VersionInfo().Select(target.Version())
if err != nil {
return err
}
target.SetVersion(version)
if jirix.Verbose() {
fmt.Fprintf(jirix.Stdout(), "%s %s %s\n", verb, profile, target.DebugString())
}
if action == profiles.Install {
return mgr.Install(jirix, pdb, root, target)
}
return mgr.Uninstall(jirix, pdb, root, target)
}