Massive golint cleanup pass
diff --git a/action/doc.go b/action/doc.go index 992faf6..e6b1c43 100644 --- a/action/doc.go +++ b/action/doc.go
@@ -1,14 +1,13 @@ -/* Package action provides implementations for every Glide command. - -This is not a general-purpose library. It is the main flow controller for Glide. - -The main glide package acts as a Facade, with this package providing the -implementation. This package should know nothing of the command line flags or -runtime characteristics. However, this package is allowed to control the flow -of the application, including termination. So actions may call `msg.Die()` to -immediately stop execution of the program. - -In general, actions are not required to function as library functions, nor as -concurrency-safe functions. -*/ +// Package action provides implementations for every Glide command. +// +// This is not a general-purpose library. It is the main flow controller for Glide. +// +// The main glide package acts as a Facade, with this package providing the +// implementation. This package should know nothing of the command line flags or +// runtime characteristics. However, this package is allowed to control the flow +// of the application, including termination. So actions may call `msg.Die()` to +// immediately stop execution of the program. +// +// In general, actions are not required to function as library functions, nor as +// concurrency-safe functions. package action
diff --git a/action/ensure.go b/action/ensure.go index e06f44b..2a14d82 100644 --- a/action/ensure.go +++ b/action/ensure.go
@@ -36,6 +36,7 @@ return conf } +// EnsureCacheDir ensures the existance of the cache directory func EnsureCacheDir() { msg.Warn("ensure.go: ensureCacheDir is not implemented.") }
diff --git a/action/remove.go b/action/remove.go index e0978b0..02a321d 100644 --- a/action/remove.go +++ b/action/remove.go
@@ -7,6 +7,7 @@ "github.com/Masterminds/glide/repo" ) +// Remove removes a dependncy from the configuration. func Remove(packages []string, inst *repo.Installer) { base := gpath.Basepath() EnsureGopath()
diff --git a/cfg/lock.go b/cfg/lock.go index bbb959f..46f0753 100644 --- a/cfg/lock.go +++ b/cfg/lock.go
@@ -45,6 +45,7 @@ return ioutil.WriteFile(lockpath, o, 0666) } +// Locks is a slice of locked dependencies. type Locks []*Lock // Len returns the length of the Locks. This is needed for sorting with @@ -69,6 +70,7 @@ l[i], l[j] = l[j], l[i] } +// Lock represents an individual locked dependency. type Lock struct { Name string `yaml:"name"` Version string `yaml:"version"` @@ -79,6 +81,7 @@ Os []string `yaml:"os,omitempty"` } +// NewLockfile is used to create an instance of Lockfile. func NewLockfile(ds Dependencies, hash string) *Lockfile { lf := &Lockfile{ Hash: hash, @@ -103,6 +106,7 @@ return lf } +// LockfileFromMap takes a map of dependencies and generates a lock Lockfile instance. func LockfileFromMap(ds map[string]*Dependency, hash string) *Lockfile { lf := &Lockfile{ Hash: hash,
diff --git a/dependency/resolver.go b/dependency/resolver.go index 91f5060..19a10e7 100644 --- a/dependency/resolver.go +++ b/dependency/resolver.go
@@ -69,12 +69,14 @@ return false, nil } +// OnGopath is run when a package is missing from vendor/ but found in the GOPATH func (d *DefaultMissingPackageHandler) OnGopath(pkg string) (bool, error) { msg.Warn("Package %s is only on GOPATH.", pkg) d.Gopath = append(d.Gopath, pkg) return false, nil } +// InVendor is run when a package is found in the vendor/ folder func (d *DefaultMissingPackageHandler) InVendor(pkg string) error { msg.Info("Package %s found in vendor/ folder", pkg) return nil @@ -713,6 +715,7 @@ LocCgo ) +// PkgInfo represents metadata about a package found by the resolver. type PkgInfo struct { Name, Path string Vendored bool @@ -809,7 +812,8 @@ return fi.Mode()&os.ModeSymlink == os.ModeSymlink } -// Returns true if this is a directory that could have source code, false otherwise. +// IsSrcDir returns true if this is a directory that could have source code, +// false otherwise. // // Directories with _ or . prefixes are skipped, as are testdata and vendor. func IsSrcDir(fi os.FileInfo) bool {
diff --git a/gb/gb.go b/gb/gb.go index 5a07c62..b0a3c18 100644 --- a/gb/gb.go +++ b/gb/gb.go
@@ -10,7 +10,7 @@ "github.com/Masterminds/glide/util" ) -// Returns true if this dir has a GB-flavored manifest file. +// Has returns true if this dir has a GB-flavored manifest file. func Has(dir string) bool { path := filepath.Join(dir, "vendor/manifest") _, err := os.Stat(path)
diff --git a/gb/manifest.go b/gb/manifest.go index 8d57356..d342a1c 100644 --- a/gb/manifest.go +++ b/gb/manifest.go
@@ -5,11 +5,13 @@ // // gb's license is MIT-style. +// Manifest represents the GB manifest file type Manifest struct { Version int `json:"version"` Dependencies []Dependency `json:"dependencies"` } +// Dependency represents an individual dependency in the GB manifest file type Dependency struct { Importpath string `json:"importpath"` Repository string `json:"repository"`
diff --git a/godep/godep.go b/godep/godep.go index 6785a0d..4407a14 100644 --- a/godep/godep.go +++ b/godep/godep.go
@@ -1,7 +1,6 @@ -/* Package godep provides basic importing of Godep dependencies. - -This is not a complete implementation of Godep. -*/ +// Package godep provides basic importing of Godep dependencies. +// +// This is not a complete implementation of Godep. package godep import ( @@ -25,14 +24,14 @@ ImportPath string GoVersion string Packages []string `json:",omitempty"` // Arguments to save, if any. - Deps []GodepDependency + Deps []Dependency outerRoot string } -// GodepDependency is a modified version of Godep's Dependency struct. +// Dependency is a modified version of Godep's Dependency struct. // It drops all of the unexported fields. -type GodepDependency struct { +type Dependency struct { ImportPath string Comment string `json:",omitempty"` // Description of commit, if present. Rev string // VCS-specific commit ID.
diff --git a/gpm/gpm.go b/gpm/gpm.go index 41de69d..17a6f2f 100644 --- a/gpm/gpm.go +++ b/gpm/gpm.go
@@ -1,7 +1,6 @@ -/* Package gpm reads GPM's Godeps files. - -It is not a complete implementaton of GPM. -*/ +// Package gpm reads GPM's Godeps files. +// +// It is not a complete implementaton of GPM. package gpm import (
diff --git a/path/path.go b/path/path.go index 466cb6d..f79125d 100644 --- a/path/path.go +++ b/path/path.go
@@ -1,9 +1,8 @@ -/* Package path contains path and environment utilities for Glide. - -This includes tools to find and manipulate Go path variables, as well as -tools for copying from one path to another. -*/ -package action +// Package path contains path and environment utilities for Glide. +// +//This includes tools to find and manipulate Go path variables, as well as +//tools for copying from one path to another. +package path import ( "fmt" @@ -13,6 +12,7 @@ "strings" ) +// DefaultGlideFile is the default name for the glide.yaml file. const DefaultGlideFile = "glide.yaml" // VendorDir is the name of the directory that holds vendored dependencies. @@ -31,6 +31,7 @@ // only be set once, at startup, or not at all. var GlideFile = DefaultGlideFile +// LockFile is the default name for the lock file. const LockFile = "glide.lock" // Home returns the Glide home directory ($GLIDE_HOME or ~/.glide, typically). @@ -45,7 +46,7 @@ return h } -// VendorPath calculates the path to the vendor directory. +// Vendor calculates the path to the vendor directory. // // Based on working directory, VendorDir and GlideFile, this attempts to // guess the location of the vendor directory.
diff --git a/path/path_test.go b/path/path_test.go index f2e4447..0c8a221 100644 --- a/path/path_test.go +++ b/path/path_test.go
@@ -1,4 +1,4 @@ -package action +package path import ( "os"
diff --git a/repo/installer.go b/repo/installer.go index 93e2548..9c9f74b 100644 --- a/repo/installer.go +++ b/repo/installer.go
@@ -191,6 +191,7 @@ return err } +// List resolves the complete dependency tree and returns a list of dependencies. func (i *Installer) List(conf *cfg.Config) []*cfg.Dependency { base := "." vpath := i.VendorPath() @@ -313,6 +314,8 @@ Use *importCache } +// 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) (bool, error) { root := util.GetRootFromPackage(pkg) @@ -349,6 +352,9 @@ return true, nil } +// OnGopath will either copy a package, already found in the GOPATH, to the +// vendor/ directory or download it from the internet. This is dependent if +// useGopath on the installer is set to true to copy from the GOPATH. func (m *MissingPackageHandler) OnGopath(pkg string) (bool, error) { // If useGopath is false, we fall back to the strategy of fetching from // remote.
diff --git a/repo/repo.go b/repo/repo.go index 3270f5c..704e095 100644 --- a/repo/repo.go +++ b/repo/repo.go
@@ -1,8 +1,7 @@ -/* package Repo provides tools for working with VCS repositories. - -Glide manages repositories in the vendor directory by using the native VCS -systems of each repository upon which the code relies. -*/ +// Package repo provides tools for working with VCS repositories. +// +// Glide manages repositories in the vendor directory by using the native VCS +// systems of each repository upon which the code relies. package repo // concurrentWorkers is the number of workers to be used in concurrent operations.
diff --git a/repo/vcs.go b/repo/vcs.go index 96432ac..e9b5c85 100644 --- a/repo/vcs.go +++ b/repo/vcs.go
@@ -65,9 +65,8 @@ if err != nil { msg.Error("Unable to update vendored dependency %s.\n", dep.Name) return err - } else { - dep.UpdateAsVendored = true } + dep.UpdateAsVendored = true if err = VcsGet(dep, dest, home, cache, cacheGopath, useGopath); err != nil { msg.Warn("Unable to checkout %s\n", dep.Name) @@ -105,35 +104,34 @@ return err } else if repo.IsDirty() { return fmt.Errorf("%s contains uncommited changes. Skipping update", dep.Name) - } else { + } - // Check if the current version is a tag or commit id. If it is - // and that version is already checked out we can skip updating - // which is faster than going out to the Internet to perform - // an update. - if dep.Reference != "" { - version, err := repo.Version() - if err != nil { - return err - } - ib, err := isBranch(dep.Reference, repo) - if err != nil { - return err - } - - // If the current version equals the ref and it's not a - // branch it's a tag or commit id so we can skip - // performing an update. - if version == dep.Reference && !ib { - msg.Info("%s is already set to version %s. Skipping update.", dep.Name, dep.Reference) - return nil - } - } - - if err := repo.Update(); err != nil { - msg.Warn("Download failed.\n") + // Check if the current version is a tag or commit id. If it is + // and that version is already checked out we can skip updating + // which is faster than going out to the Internet to perform + // an update. + if dep.Reference != "" { + version, err := repo.Version() + if err != nil { return err } + ib, err := isBranch(dep.Reference, repo) + if err != nil { + return err + } + + // If the current version equals the ref and it's not a + // branch it's a tag or commit id so we can skip + // performing an update. + if version == dep.Reference && !ib { + msg.Info("%s is already set to version %s. Skipping update.", dep.Name, dep.Reference) + return nil + } + } + + if err := repo.Update(); err != nil { + msg.Warn("Download failed.\n") + return err } } } @@ -409,9 +407,9 @@ } return nil - } else { - msg.Warn("Cache key generation error: %s", err) } + + msg.Warn("Cache key generation error: %s", err) } // If unable to cache pull directly into the vendor/ directory.
diff --git a/repo/vendored_cleanup.go b/repo/vendored_cleanup.go index de464d6..6fa63e2 100644 --- a/repo/vendored_cleanup.go +++ b/repo/vendored_cleanup.go
@@ -9,7 +9,7 @@ gpath "github.com/Masterminds/glide/path" ) -// VendoredCleanUp cleans up vendored codebases after an update. +// VendoredCleanup cleans up vendored codebases after an update. // // This should _only_ be run for installations that do not want VCS repos inside // of the vendor/ directory.