本文整理汇总了Golang中v/io/jiri/profiles.Target.Version方法的典型用法代码示例。如果您正苦于以下问题:Golang Target.Version方法的具体用法?Golang Target.Version怎么用?Golang Target.Version使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类v/io/jiri/profiles.Target
的用法示例。
在下文中一共展示了Target.Version方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: targetAtDefaultVersion
func targetAtDefaultVersion(mgr profiles.Manager, target profiles.Target) (profiles.Target, error) {
def := target
version, err := mgr.VersionInfo().Select(target.Version())
if err != nil {
return profiles.Target{}, err
}
def.SetVersion(version)
return def, nil
}
示例2: 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
}
示例3: Uninstall
func (eg *exampleManager) Uninstall(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
}
dir := eg.filename(root, target).Abs(jirix)
if err := jirix.NewSeq().WriteFile(filepath.Join(dir, "version"), []byte(version), profilesutil.DefaultFilePerm).
WriteFile(filepath.Join(dir, version), []byte(version), profilesutil.DefaultFilePerm).
Remove(filepath.Join(dir, version)).
Done(); err != nil {
return err
}
if pdb.RemoveProfileTarget(eg.installer, eg.name, target) {
eg.profile = nil
}
return nil
}
示例4: 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)
}
示例5: 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)
}