本文整理汇总了Golang中github.com/Masterminds/glide/repo.Installer.Install方法的典型用法代码示例。如果您正苦于以下问题:Golang Installer.Install方法的具体用法?Golang Installer.Install怎么用?Golang Installer.Install使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/Masterminds/glide/repo.Installer
的用法示例。
在下文中一共展示了Installer.Install方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Install
// Install installs a vendor directory based on an existing Glide configuration.
func Install(installer *repo.Installer, stripVendor bool) {
cache.SystemLock()
base := "."
// Ensure GOPATH
EnsureGopath()
EnsureVendorDir()
conf := EnsureConfig()
// Lockfile exists
if !gpath.HasLock(base) {
msg.Info("Lock file (glide.lock) does not exist. Performing update.")
Update(installer, false, stripVendor)
return
}
// Load lockfile
lock, err := cfg.ReadLockFile(filepath.Join(base, gpath.LockFile))
if err != nil {
msg.Die("Could not load lockfile.")
}
// Verify lockfile hasn't changed
hash, err := conf.Hash()
if err != nil {
msg.Die("Could not load lockfile.")
} else if hash != lock.Hash {
fmt.Println(hash, lock.Hash)
foo, _ := conf.Marshal()
fmt.Println(string(foo))
msg.Warn("Lock file may be out of date. Hash check of YAML failed. You may need to run 'update'")
}
// Install
newConf, err := installer.Install(lock, conf)
if err != nil {
msg.Die("Failed to install: %s", err)
}
msg.Info("Setting references.")
// Set reference
if err := repo.SetReference(newConf, installer.ResolveTest); err != nil {
msg.Die("Failed to set references: %s (Skip to cleanup)", err)
}
err = installer.Export(newConf)
if err != nil {
msg.Die("Unable to export dependencies to vendor directory: %s", err)
}
if stripVendor {
msg.Info("Removing nested vendor and Godeps/_workspace directories...")
err := gpath.StripVendor()
if err != nil {
msg.Err("Unable to strip vendor directories: %s", err)
}
}
}
示例2: Install
// Install installs a vendor directory based on an existing Glide configuration.
func Install(installer *repo.Installer) {
base := "."
// Ensure GOPATH
EnsureGopath()
EnsureVendorDir()
conf := EnsureConfig()
// Lockfile exists
if !gpath.HasLock(base) {
msg.Info("Lock file (glide.lock) does not exist. Performing update.")
Update(installer, false)
return
}
// Load lockfile
lock, err := LoadLockfile(base, conf)
if err != nil {
msg.Die("Could not load lockfile.")
}
// Delete unused packages
if installer.DeleteUnused {
// It's unclear whether this should operate off of the lock, or off
// of the glide.yaml file. I'd think that doing this based on the
// lock would be much more reliable.
dependency.DeleteUnused(conf)
}
// Install
newConf, err := installer.Install(lock, conf)
if err != nil {
msg.Die("Failed to install: %s", err)
}
msg.Info("Setting references.")
// Set reference
if err := repo.SetReference(newConf); err != nil {
msg.Error("Failed to set references: %s (Skip to cleanup)", err)
}
// VendoredCleanup. This should ONLY be run if UpdateVendored was specified.
if installer.UpdateVendored {
repo.VendoredCleanup(newConf)
}
}
示例3: Install
// Install installs a vendor directory based on an existing Glide configuration.
func Install(installer *repo.Installer, strip, stripVendor bool) {
if installer.UseCache {
cache.SystemLock()
}
base := "."
// Ensure GOPATH
EnsureGopath()
EnsureVendorDir()
conf := EnsureConfig()
// Lockfile exists
if !gpath.HasLock(base) {
msg.Info("Lock file (glide.lock) does not exist. Performing update.")
Update(installer, false, strip, stripVendor)
return
}
// Load lockfile
lock, err := LoadLockfile(base, conf)
if err != nil {
msg.Die("Could not load lockfile.")
}
// Delete unused packages
if installer.DeleteUnused {
// It's unclear whether this should operate off of the lock, or off
// of the glide.yaml file. I'd think that doing this based on the
// lock would be much more reliable.
dependency.DeleteUnused(conf)
}
// Install
newConf, err := installer.Install(lock, conf)
if err != nil {
msg.Die("Failed to install: %s", err)
}
msg.Info("Setting references.")
// Set reference
if err := repo.SetReference(newConf); err != nil {
msg.Err("Failed to set references: %s (Skip to cleanup)", err)
}
// VendoredCleanup. This should ONLY be run if UpdateVendored was specified.
// When stripping VCS happens this will happen as well. No need for double
// effort.
if installer.UpdateVendored && !strip {
repo.VendoredCleanup(newConf)
}
if strip {
msg.Info("Removing version control data from vendor directory...")
gpath.StripVcs()
}
if stripVendor {
msg.Info("Removing nested vendor and Godeps/_workspace directories...")
err := gpath.StripVendor()
if err != nil {
msg.Err("Unable to strip vendor directories: %s", err)
}
}
}