本文整理汇总了Golang中github.com/Masterminds/glide/msg.Warn函数的典型用法代码示例。如果您正苦于以下问题:Golang Warn函数的具体用法?Golang Warn怎么用?Golang Warn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Warn函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: EnsureGoVendor
// EnsureGoVendor ensures that the Go version is correct.
func EnsureGoVendor() {
// 6l was removed in 1.5, when vendoring was introduced.
cmd := exec.Command("go", "tool", "6l")
if _, err := cmd.CombinedOutput(); err == nil {
msg.Warn("You must install the Go 1.5 or greater toolchain to work with Glide.\n")
os.Exit(1)
}
if os.Getenv("GO15VENDOREXPERIMENT") != "1" {
msg.Warn("To use Glide, you must set GO15VENDOREXPERIMENT=1\n")
os.Exit(1)
}
// Verify the setup isn't for the old version of glide. That is, this is
// no longer assuming the _vendor directory as the GOPATH. Inform of
// the change.
if _, err := os.Stat("_vendor/"); err == nil {
msg.Warn(`Your setup appears to be for the previous version of Glide.
Previously, vendor packages were stored in _vendor/src/ and
_vendor was set as your GOPATH. As of Go 1.5 the go tools
recognize the vendor directory as a location for these
files. Glide has embraced this. Please remove the _vendor
directory or move the _vendor/src/ directory to vendor/.` + "\n")
os.Exit(1)
}
}
开发者ID:gus,项目名称:glide,代码行数:26,代码来源:ensure.go
示例2: Get
// Get fetches one or more dependencies and installs.
//
// This includes resolving dependency resolution and re-generating the lock file.
func Get(names []string, installer *repo.Installer, insecure, skipRecursive bool) {
base := gpath.Basepath()
EnsureGopath()
EnsureVendorDir()
conf := EnsureConfig()
glidefile, err := gpath.Glide()
if err != nil {
msg.Die("Could not find Glide file: %s", err)
}
// Add the packages to the config.
if err := addPkgsToConfig(conf, names, insecure); err != nil {
msg.Die("Failed to get new packages: %s", err)
}
// Fetch the new packages. Can't resolve versions via installer.Update if
// get is called while the vendor/ directory is empty so we checkout
// everything.
installer.Checkout(conf, false)
// Prior to resolving dependencies we need to start working with a clone
// of the conf because we'll be making real changes to it.
confcopy := conf.Clone()
if !skipRecursive {
// Get all repos and update them.
// TODO: Can we streamline this in any way? The reason that we update all
// of the dependencies is that we need to re-negotiate versions. For example,
// if an existing dependency has the constraint >1.0 and this new package
// adds the constraint <2.0, then this may re-resolve the existing dependency
// to be between 1.0 and 2.0. But changing that dependency may then result
// in that dependency's dependencies changing... so we sorta do the whole
// thing to be safe.
err = installer.Update(confcopy)
if err != nil {
msg.Die("Could not update packages: %s", err)
}
}
// Set Reference
if err := repo.SetReference(confcopy); err != nil {
msg.Error("Failed to set references: %s", err)
}
// VendoredCleanup
if installer.UpdateVendored {
repo.VendoredCleanup(confcopy)
}
// Write YAML
if err := conf.WriteFile(glidefile); err != nil {
msg.Die("Failed to write glide YAML file: %s", err)
}
if !skipRecursive {
// Write lock
writeLock(conf, confcopy, base)
} else {
msg.Warn("Skipping lockfile generation because full dependency tree is not being calculated")
}
}
开发者ID:litixsoft,项目名称:lxb,代码行数:63,代码来源:get.go
示例3: Parse
// Parse parses a GPM-flavored Godeps file.
func Parse(dir string) ([]*cfg.Dependency, error) {
path := filepath.Join(dir, "Godeps")
if i, err := os.Stat(path); err != nil {
return []*cfg.Dependency{}, nil
} else if i.IsDir() {
msg.Info("Godeps is a directory. This is probably a Godep project.\n")
return []*cfg.Dependency{}, nil
}
msg.Info("Found Godeps file.\n")
buf := []*cfg.Dependency{}
file, err := os.Open(path)
if err != nil {
return buf, err
}
scanner := bufio.NewScanner(file)
for scanner.Scan() {
parts, ok := parseGodepsLine(scanner.Text())
if ok {
dep := &cfg.Dependency{Name: parts[0]}
if len(parts) > 1 {
dep.Reference = parts[1]
}
buf = append(buf, dep)
}
}
if err := scanner.Err(); err != nil {
msg.Warn("Scan failed: %s\n", err)
return buf, err
}
return buf, nil
}
开发者ID:bacongobbler,项目名称:glide,代码行数:35,代码来源:gpm.go
示例4: List
func (i *Installer) List(conf *cfg.Config) []*cfg.Dependency {
base := "."
vpath := i.VendorPath()
ic := newImportCache()
v := &VersionHandler{
Destination: vpath,
Use: ic,
Imported: make(map[string]bool),
Conflicts: make(map[string]bool),
Config: conf,
}
// Update imports
res, err := dependency.NewResolver(base)
if err != nil {
msg.Die("Failed to create a resolver: %s", err)
}
res.Config = conf
res.VersionHandler = v
msg.Info("Resolving imports")
_, err = allPackages(conf.Imports, res)
if err != nil {
msg.Die("Failed to retrieve a list of dependencies: %s", err)
}
msg.Warn("devImports not resolved.")
return conf.Imports
}
开发者ID:litixsoft,项目名称:lxb,代码行数:32,代码来源:installer.go
示例5: guessImportDeps
func guessImportDeps(base string, config *cfg.Config) {
msg.Info("Attempting to import from other package managers (use --skip-import to skip)")
deps := []*cfg.Dependency{}
absBase, err := filepath.Abs(base)
if err != nil {
msg.Die("Failed to resolve location of %s: %s", base, err)
}
if d, ok := guessImportGodep(absBase); ok {
msg.Info("Importing Godep configuration")
msg.Warn("Godep uses commit id versions. Consider using Semantic Versions with Glide")
deps = d
} else if d, ok := guessImportGPM(absBase); ok {
msg.Info("Importing GPM configuration")
deps = d
} else if d, ok := guessImportGB(absBase); ok {
msg.Info("Importing GB configuration")
deps = d
}
for _, i := range deps {
if i.Reference == "" {
msg.Info("--> Found imported reference to %s", i.Name)
} else {
msg.Info("--> Found imported reference to %s at revision %s", i.Name, i.Reference)
}
config.Imports = append(config.Imports, i)
}
}
开发者ID:treejames,项目名称:glide-1,代码行数:30,代码来源:create.go
示例6: singleWarn
func singleWarn(ft string, v ...interface{}) {
m := fmt.Sprintf(ft, v...)
_, f := warningMessage[m]
if !f {
msg.Warn(m)
warningMessage[m] = true
}
}
开发者ID:litixsoft,项目名称:lxb,代码行数:8,代码来源:installer.go
示例7: EnsureConfig
// EnsureConfig loads and returns a config file.
//
// Any error will cause an immediate exit, with an error printed to Stderr.
func EnsureConfig() *cfg.Config {
yamlpath, err := gpath.Glide()
if err != nil {
msg.ExitCode(2)
msg.Die("Failed to find %s file in directory tree: %s", gpath.GlideFile, err)
}
yml, err := ioutil.ReadFile(yamlpath)
if err != nil {
msg.ExitCode(2)
msg.Die("Failed to load %s: %s", yamlpath, err)
}
conf, err := cfg.ConfigFromYaml(yml)
if err != nil {
msg.ExitCode(3)
msg.Die("Failed to parse %s: %s", yamlpath, err)
}
b := filepath.Dir(yamlpath)
buildContext, err := util.GetBuildContext()
if err != nil {
msg.Die("Failed to build an import context while ensuring config: %s", err)
}
cwd, err := os.Getwd()
if err != nil {
msg.Err("Unable to get the current working directory")
} else {
// Determining a package name requires a relative path
b, err = filepath.Rel(b, cwd)
if err == nil {
name := buildContext.PackageName(b)
if name != conf.Name {
msg.Warn("The name listed in the config file (%s) does not match the current location (%s)", conf.Name, name)
}
} else {
msg.Warn("Problem finding the config file path (%s) relative to the current directory (%s): %s", b, cwd, err)
}
}
err = mirrors.Load()
if err != nil {
msg.Err("Unable to load mirrors: %s", err)
}
return conf
}
开发者ID:albrow,项目名称:glide,代码行数:49,代码来源:ensure.go
示例8: EnsureGoVendor
// EnsureGoVendor ensures that the Go version is correct.
func EnsureGoVendor() {
// 6l was removed in 1.5, when vendoring was introduced.
cmd := exec.Command(goExecutable(), "tool", "6l")
if _, err := cmd.CombinedOutput(); err == nil {
msg.Warn("You must install the Go 1.5 or greater toolchain to work with Glide.\n")
os.Exit(1)
}
// Check if this is go15, which requires GO15VENDOREXPERIMENT
// Any release after go15 does not require that env var.
cmd = exec.Command(goExecutable(), "version")
if out, err := cmd.CombinedOutput(); err != nil {
msg.Err("Error getting version: %s.\n", err)
os.Exit(1)
} else if strings.HasPrefix(string(out), "go version 1.5") {
// This works with 1.5 and 1.6.
cmd = exec.Command(goExecutable(), "env", "GO15VENDOREXPERIMENT")
if out, err := cmd.CombinedOutput(); err != nil {
msg.Err("Error looking for $GOVENDOREXPERIMENT: %s.\n", err)
os.Exit(1)
} else if strings.TrimSpace(string(out)) != "1" {
msg.Err("To use Glide, you must set GO15VENDOREXPERIMENT=1")
os.Exit(1)
}
}
// In the case where vendoring is explicitly disabled, balk.
if os.Getenv("GO15VENDOREXPERIMENT") == "0" {
msg.Err("To use Glide, you must set GO15VENDOREXPERIMENT=1")
os.Exit(1)
}
// Verify the setup isn't for the old version of glide. That is, this is
// no longer assuming the _vendor directory as the GOPATH. Inform of
// the change.
if _, err := os.Stat("_vendor/"); err == nil {
msg.Warn(`Your setup appears to be for the previous version of Glide.
Previously, vendor packages were stored in _vendor/src/ and
_vendor was set as your GOPATH. As of Go 1.5 the go tools
recognize the vendor directory as a location for these
files. Glide has embraced this. Please remove the _vendor
directory or move the _vendor/src/ directory to vendor/.` + "\n")
os.Exit(1)
}
}
开发者ID:Zuozuohao,项目名称:glide,代码行数:46,代码来源:ensure.go
示例9: 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)
}
}
}
开发者ID:albrow,项目名称:glide,代码行数:58,代码来源:install.go
示例10: NotFound
// NotFound attempts to retrieve a package when not found in the local vendor/
// folder. It will attempt to get it from the remote location info.
func (m *MissingPackageHandler) NotFound(pkg string, addTest bool) (bool, error) {
root := util.GetRootFromPackage(pkg)
// Skip any references to the root package.
if root == m.Config.Name {
return false, nil
}
dest := filepath.Join(m.destination, root)
// This package may have been placed on the list to look for when it wasn't
// downloaded but it has since been downloaded before coming to this entry.
if _, err := os.Stat(dest); err == nil {
// Make sure the location contains files. It may be an empty directory.
empty, err := gpath.IsDirectoryEmpty(dest)
if err != nil {
return false, err
}
if empty {
msg.Warn("%s is an existing location with no files. Fetching a new copy of the dependency.", dest)
msg.Debug("Removing empty directory %s", dest)
err := os.RemoveAll(dest)
if err != nil {
msg.Debug("Installer error removing directory %s: %s", dest, err)
return false, err
}
} else {
msg.Debug("Found %s", dest)
return true, nil
}
}
msg.Info("Fetching %s into %s", pkg, m.destination)
d := m.Config.Imports.Get(root)
if d == nil && addTest {
d = m.Config.DevImports.Get(root)
}
// If the dependency is nil it means the Config doesn't yet know about it.
if d == nil {
d, _ = m.Use.Get(root)
// We don't know about this dependency so we create a basic instance.
if d == nil {
d = &cfg.Dependency{Name: root}
}
if addTest {
m.Config.DevImports = append(m.Config.DevImports, d)
} else {
m.Config.Imports = append(m.Config.Imports, d)
}
}
if err := VcsGet(d, dest, m.home, m.cache, m.cacheGopath, m.useGopath); err != nil {
return false, err
}
return true, nil
}
开发者ID:Zuozuohao,项目名称:glide,代码行数:58,代码来源:installer.go
示例11: buildPath
func buildPath(path string) error {
msg.Info("Running go build %s\n", path)
// . in a filepath.Join is removed so it needs to be prepended separately.
p := "." + string(filepath.Separator) + filepath.Join("vendor", path)
out, err := exec.Command("go", "install", p).CombinedOutput()
if err != nil {
msg.Warn("Failed to run 'go install' for %s: %s", path, string(out))
}
return err
}
开发者ID:karfield,项目名称:glide,代码行数:10,代码来源:rebuild.go
示例12: walkDeps
func walkDeps(b *util.BuildCtxt, base, myName string) []string {
externalDeps := []string{}
filepath.Walk(base, func(path string, fi os.FileInfo, err error) error {
if err != nil {
return err
}
if !dependency.IsSrcDir(fi) {
if fi.IsDir() {
return filepath.SkipDir
}
return nil
}
var imps []string
pkg, err := b.ImportDir(path, 0)
if err != nil && strings.HasPrefix(err.Error(), "found packages ") {
// If we got here it's because a package and multiple packages
// declared. This is often because of an example with a package
// or main but +build ignore as a build tag. In that case we
// try to brute force the packages with a slower scan.
imps, _, err = dependency.IterativeScan(path)
if err != nil {
msg.Err("Error walking dependencies for %s: %s", path, err)
return err
}
} else if err != nil {
if !strings.HasPrefix(err.Error(), "no buildable Go source") {
msg.Warn("Error: %s (%s)", err, path)
// Not sure if we should return here.
//return err
}
} else {
imps = pkg.Imports
}
if pkg.Goroot {
return nil
}
for _, imp := range imps {
//if strings.HasPrefix(imp, myName) {
////Info("Skipping %s because it is a subpackage of %s", imp, myName)
//continue
//}
if imp == myName {
continue
}
externalDeps = append(externalDeps, imp)
}
return nil
})
return externalDeps
}
开发者ID:albrow,项目名称:glide,代码行数:55,代码来源:tree.go
示例13: Rebuild
// Rebuild rebuilds '.a' files for a project.
//
// Prior to Go 1.4, this could substantially reduce time on incremental compiles.
// It remains to be seen whether this is tremendously beneficial to modern Go
// programs.
func Rebuild() {
msg.Warn("The rebuild command is deprecated and will be removed in a future version")
msg.Warn("Use the go install command instead")
conf := EnsureConfig()
vpath, err := gpath.Vendor()
if err != nil {
msg.Die("Could not get vendor path: %s", err)
}
msg.Info("Building dependencies.\n")
if len(conf.Imports) == 0 {
msg.Info("No dependencies found. Nothing built.\n")
return
}
for _, dep := range conf.Imports {
if err := buildDep(dep, vpath); err != nil {
msg.Warn("Failed to build %s: %s\n", dep.Name, err)
}
}
}
开发者ID:karfield,项目名称:glide,代码行数:27,代码来源:rebuild.go
示例14: NoVendor
// NoVendor generates a list of source code directories, excepting `vendor/`.
//
// If "onlyGo" is true, only folders that have Go code in them will be returned.
//
// If suffix is true, this will append `/...` to every directory.
func NoVendor(path string, onlyGo, suffix bool) {
// This is responsible for printing the results of noVend.
paths, err := noVend(path, onlyGo, suffix)
if err != nil {
msg.Error("Failed to walk file tree: %s", err)
msg.Warn("FIXME: NoVendor should exit with non-zero exit code.")
return
}
for _, p := range paths {
msg.Puts(p)
}
}
开发者ID:litixsoft,项目名称:lxb,代码行数:18,代码来源:no_vendor.go
示例15: Update
// Update updates all dependencies.
//
// It begins with the dependencies in the config file, but also resolves
// transitive dependencies. The returned lockfile has all of the dependencies
// listed, but the version reconciliation has not been done.
//
// In other words, all versions in the Lockfile will be empty.
func (i *Installer) Update(conf *cfg.Config) error {
base := "."
vpath := i.VendorPath()
ic := newImportCache()
m := &MissingPackageHandler{
destination: vpath,
cache: i.UseCache,
cacheGopath: i.UseCacheGopath,
useGopath: i.UseGopath,
home: i.Home,
force: i.Force,
updateVendored: i.UpdateVendored,
Config: conf,
Use: ic,
updated: i.Updated,
}
v := &VersionHandler{
Destination: vpath,
Use: ic,
Imported: make(map[string]bool),
Conflicts: make(map[string]bool),
Config: conf,
}
// Update imports
res, err := dependency.NewResolver(base)
if err != nil {
msg.Die("Failed to create a resolver: %s", err)
}
res.Config = conf
res.Handler = m
res.VersionHandler = v
res.ResolveAllFiles = i.ResolveAllFiles
msg.Info("Resolving imports")
_, err = allPackages(conf.Imports, res)
if err != nil {
msg.Die("Failed to retrieve a list of dependencies: %s", err)
}
if len(conf.DevImports) > 0 {
msg.Warn("dev imports not resolved.")
}
err = ConcurrentUpdate(conf.Imports, vpath, i, conf)
return err
}
开发者ID:treejames,项目名称:glide-1,代码行数:58,代码来源:installer.go
示例16: SetVersion
// SetVersion sets the version for a package. If that package version is already
// set it handles the case by:
// - keeping the already set version
// - proviting messaging about the version conflict
// TODO(mattfarina): The way version setting happens can be improved. Currently not optimal.
func (d *VersionHandler) SetVersion(pkg string) (e error) {
root := util.GetRootFromPackage(pkg)
// Skip any references to the root package.
if root == d.Config.Name {
return nil
}
v := d.Config.Imports.Get(root)
dep, req := d.Use.Get(root)
if dep != nil && v != nil {
if v.Reference == "" && dep.Reference != "" {
v.Reference = dep.Reference
// Clear the pin, if set, so the new version can be used.
v.Pin = ""
dep = v
} else if v.Reference != "" && dep.Reference != "" && v.Reference != dep.Reference {
dest := filepath.Join(d.Destination, filepath.FromSlash(v.Name))
dep = determineDependency(v, dep, dest, req)
} else {
dep = v
}
} else if v != nil {
dep = v
} else if dep != nil {
// We've got an imported dependency to use and don't already have a
// record of it. Append it to the Imports.
d.Config.Imports = append(d.Config.Imports, dep)
} else {
// If we've gotten here we don't have any depenency objects.
r, sp := util.NormalizeName(pkg)
dep = &cfg.Dependency{
Name: r,
}
if sp != "" {
dep.Subpackages = []string{sp}
}
d.Config.Imports = append(d.Config.Imports, dep)
}
err := VcsVersion(dep, d.Destination)
if err != nil {
msg.Warn("Unable to set version on %s to %s. Err: %s", root, dep.Reference, err)
e = err
}
return
}
开发者ID:treejames,项目名称:glide-1,代码行数:55,代码来源:installer.go
示例17: ConcurrentUpdate
// ConcurrentUpdate takes a list of dependencies and updates in parallel.
func ConcurrentUpdate(deps []*cfg.Dependency, cwd string, i *Installer) error {
done := make(chan struct{}, concurrentWorkers)
in := make(chan *cfg.Dependency, concurrentWorkers)
var wg sync.WaitGroup
var lock sync.Mutex
var returnErr error
msg.Info("Downloading dependencies. Please wait...")
for ii := 0; ii < concurrentWorkers; ii++ {
go func(ch <-chan *cfg.Dependency) {
for {
select {
case dep := <-ch:
dest := filepath.Join(i.VendorPath(), dep.Name)
if err := VcsUpdate(dep, dest, i.Home, i.UseCache, i.UseCacheGopath, i.UseGopath, i.Force, i.UpdateVendored); err != nil {
msg.Warn("Update failed for %s: %s\n", dep.Name, err)
// Capture the error while making sure the concurrent
// operations don't step on each other.
lock.Lock()
if returnErr == nil {
returnErr = err
} else {
returnErr = cli.NewMultiError(returnErr, err)
}
lock.Unlock()
}
wg.Done()
case <-done:
return
}
}
}(in)
}
for _, dep := range deps {
wg.Add(1)
in <- dep
}
wg.Wait()
// Close goroutines setting the version
for ii := 0; ii < concurrentWorkers; ii++ {
done <- struct{}{}
}
return returnErr
}
开发者ID:karfield,项目名称:glide,代码行数:50,代码来源:installer.go
示例18: ListDeps
// ListDeps lists all of the dependencies of the current project.
//
// Params:
// - dir (string): basedir
// - deep (bool): whether to do a deep scan or a shallow scan
//
// Returns:
//
func ListDeps(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt) {
basedir := p.Get("dir", ".").(string)
deep := p.Get("deep", true).(bool)
basedir, err := filepath.Abs(basedir)
if err != nil {
return nil, err
}
r, err := dependency.NewResolver(basedir)
if err != nil {
return nil, err
}
h := &dependency.DefaultMissingPackageHandler{Missing: []string{}, Gopath: []string{}}
r.Handler = h
sortable, err := r.ResolveLocal(deep)
if err != nil {
return nil, err
}
sort.Strings(sortable)
fmt.Println("INSTALLED packages:")
for _, k := range sortable {
v, err := filepath.Rel(basedir, k)
if err != nil {
msg.Warn("Failed to Rel path: %s", err)
v = k
}
fmt.Printf("\t%s\n", v)
}
if len(h.Missing) > 0 {
fmt.Println("\nMISSING packages:")
for _, pkg := range h.Missing {
fmt.Printf("\t%s\n", pkg)
}
}
if len(h.Gopath) > 0 {
fmt.Println("\nGOPATH packages:")
for _, pkg := range h.Gopath {
fmt.Printf("\t%s\n", pkg)
}
}
return nil, nil
}
开发者ID:andrewzeneski,项目名称:glide,代码行数:56,代码来源:tree.go
示例19: MirrorsRemove
// MirrorsRemove removes a mirrors setting
func MirrorsRemove(k string) error {
if k == "" {
msg.Err("The mirror to remove is required")
return nil
}
home := gpath.Home()
op := filepath.Join(home, "mirrors.yaml")
if _, err := os.Stat(op); os.IsNotExist(err) {
msg.Err("mirrors.yaml file not found")
return nil
}
ov, err := mirrors.ReadMirrorsFile(op)
if err != nil {
msg.Die("Unable to read mirrors.yaml file: %s", err)
}
var nre mirrors.MirrorRepos
var found bool
for _, re := range ov.Repos {
if re.Original != k {
nre = append(nre, re)
} else {
found = true
}
}
if !found {
msg.Warn("%s was not found in mirrors", k)
} else {
msg.Info("%s was removed from mirrors", k)
ov.Repos = nre
err = ov.WriteFile(op)
if err != nil {
msg.Err("Error writing mirrors.yaml file: %s", err)
} else {
msg.Info("mirrors.yaml written with changes")
}
}
return nil
}
开发者ID:albrow,项目名称:glide,代码行数:47,代码来源:mirrors.go
示例20: ConcurrentUpdate
// ConcurrentUpdate takes a list of dependencies and updates in parallel.
func ConcurrentUpdate(deps []*cfg.Dependency, cwd string, i *Installer) error {
done := make(chan struct{}, concurrentWorkers)
in := make(chan *cfg.Dependency, concurrentWorkers)
var wg sync.WaitGroup
var lock sync.Mutex
var returnErr error
for ii := 0; ii < concurrentWorkers; ii++ {
go func(ch <-chan *cfg.Dependency) {
for {
select {
case dep := <-ch:
if err := VcsUpdate(dep, cwd, i); err != nil {
msg.Warn("Update failed for %s: %s\n", dep.Name, err)
// Capture the error while making sure the concurrent
// operations don't step on each other.
lock.Lock()
if returnErr == nil {
returnErr = err
} else {
returnErr = cli.NewMultiError(returnErr, err)
}
lock.Unlock()
}
wg.Done()
case <-done:
return
}
}
}(in)
}
for _, dep := range deps {
wg.Add(1)
in <- dep
}
wg.Wait()
// Close goroutines setting the version
for ii := 0; ii < concurrentWorkers; ii++ {
done <- struct{}{}
}
return returnErr
}
开发者ID:litixsoft,项目名称:lxb,代码行数:47,代码来源:installer.go
注:本文中的github.com/Masterminds/glide/msg.Warn函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论