本文整理匯總了Golang中v/io/jiri/profiles.Target.SetVersion方法的典型用法代碼示例。如果您正苦於以下問題:Golang Target.SetVersion方法的具體用法?Golang Target.SetVersion怎麽用?Golang Target.SetVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類v/io/jiri/profiles.Target
的用法示例。
在下文中一共展示了Target.SetVersion方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: applyCommand
func applyCommand(names []string, env *cmdline.Env, ctx *tool.Context, target profiles.Target, fn func(profiles.Manager, *tool.Context, profiles.Target) error) error {
for _, n := range names {
mgr := profiles.LookupManager(n)
version, err := mgr.VersionInfo().Select(target.Version())
if err != nil {
return err
}
target.SetVersion(version)
mgr.SetRoot(rootDir)
if err := fn(mgr, ctx, target); err != nil {
return err
}
}
return nil
}
示例2: Install
func (eg *exampleManager) Install(jirix *jiri.X, pdb *profiles.DB, root jiri.RelPath, target profiles.Target) error {
version, err := eg.versionInfo.Select(target.Version())
if err != nil {
return err
}
target.SetVersion(version)
dir := eg.filename(root, target).Abs(jirix)
if err := jirix.NewSeq().
MkdirAll(dir, profilesutil.DefaultDirPerm).
WriteFile(filepath.Join(dir, "version"), []byte(version), profilesutil.DefaultFilePerm).
WriteFile(filepath.Join(dir, version), []byte(version), profilesutil.DefaultFilePerm).
Done(); err != nil {
return err
}
eg.profile = pdb.InstallProfile(eg.installer, eg.name, string(root))
target.InstallationDir = string(root)
return pdb.AddProfileTarget(eg.installer, eg.name, target)
}
示例3: 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)
}