diff --git a/azure/public.go b/azure/public.go index cf1a7b20..b5c1e357 100644 --- a/azure/public.go +++ b/azure/public.go @@ -83,7 +83,7 @@ func (storage *PublishedStorage) String() string { } // MkDir creates directory recursively under public path -func (storage *PublishedStorage) MkDir(path string) error { +func (storage *PublishedStorage) MkDir(_ string) error { // no op for Azure return nil } @@ -145,7 +145,7 @@ func (storage *PublishedStorage) putFile(path string, source io.Reader, sourceMD } // RemoveDirs removes directory structure under public path -func (storage *PublishedStorage) RemoveDirs(path string, progress aptly.Progress) error { +func (storage *PublishedStorage) RemoveDirs(path string, _ aptly.Progress) error { filelist, err := storage.Filelist(path) if err != nil { return err diff --git a/cmd/config_show.go b/cmd/config_show.go index 119fd37f..66adc8f0 100644 --- a/cmd/config_show.go +++ b/cmd/config_show.go @@ -7,7 +7,7 @@ import ( "github.com/smira/commander" ) -func aptlyConfigShow(cmd *commander.Command, args []string) error { +func aptlyConfigShow(_ *commander.Command, _ []string) error { config := context.Config() prettyJSON, err := json.MarshalIndent(config, "", " ") diff --git a/cmd/mirror_list.go b/cmd/mirror_list.go index 1a54f433..42b802cf 100644 --- a/cmd/mirror_list.go +++ b/cmd/mirror_list.go @@ -24,7 +24,7 @@ func aptlyMirrorList(cmd *commander.Command, args []string) error { return aptlyMirrorListTxt(cmd, args) } -func aptlyMirrorListTxt(cmd *commander.Command, args []string) error { +func aptlyMirrorListTxt(cmd *commander.Command, _ []string) error { var err error raw := cmd.Flag.Lookup("raw").Value.Get().(bool) @@ -65,7 +65,7 @@ func aptlyMirrorListTxt(cmd *commander.Command, args []string) error { return err } -func aptlyMirrorListJSON(cmd *commander.Command, args []string) error { +func aptlyMirrorListJSON(_ *commander.Command, _ []string) error { var err error repos := make([]*deb.RemoteRepo, context.NewCollectionFactory().RemoteRepoCollection().Len()) diff --git a/cmd/mirror_show.go b/cmd/mirror_show.go index 7491b355..03179161 100644 --- a/cmd/mirror_show.go +++ b/cmd/mirror_show.go @@ -27,7 +27,7 @@ func aptlyMirrorShow(cmd *commander.Command, args []string) error { return aptlyMirrorShowTxt(cmd, args) } -func aptlyMirrorShowTxt(cmd *commander.Command, args []string) error { +func aptlyMirrorShowTxt(_ *commander.Command, args []string) error { var err error name := args[0] @@ -93,7 +93,7 @@ func aptlyMirrorShowTxt(cmd *commander.Command, args []string) error { return err } -func aptlyMirrorShowJSON(cmd *commander.Command, args []string) error { +func aptlyMirrorShowJSON(_ *commander.Command, args []string) error { var err error name := args[0] diff --git a/cmd/publish_list.go b/cmd/publish_list.go index a4e0281f..f4bbb2af 100644 --- a/cmd/publish_list.go +++ b/cmd/publish_list.go @@ -25,7 +25,7 @@ func aptlyPublishList(cmd *commander.Command, args []string) error { return aptlyPublishListTxt(cmd, args) } -func aptlyPublishListTxt(cmd *commander.Command, args []string) error { +func aptlyPublishListTxt(cmd *commander.Command, _ []string) error { var err error raw := cmd.Flag.Lookup("raw").Value.Get().(bool) @@ -77,7 +77,7 @@ func aptlyPublishListTxt(cmd *commander.Command, args []string) error { return err } -func aptlyPublishListJSON(cmd *commander.Command, args []string) error { +func aptlyPublishListJSON(_ *commander.Command, _ []string) error { var err error repos := make([]*deb.PublishedRepo, 0, context.NewCollectionFactory().PublishedRepoCollection().Len()) diff --git a/cmd/publish_show.go b/cmd/publish_show.go index 3b9ec4e3..d943df3f 100644 --- a/cmd/publish_show.go +++ b/cmd/publish_show.go @@ -24,7 +24,7 @@ func aptlyPublishShow(cmd *commander.Command, args []string) error { return aptlyPublishShowTxt(cmd, args) } -func aptlyPublishShowTxt(cmd *commander.Command, args []string) error { +func aptlyPublishShowTxt(_ *commander.Command, args []string) error { var err error distribution := args[0] @@ -76,7 +76,7 @@ func aptlyPublishShowTxt(cmd *commander.Command, args []string) error { return err } -func aptlyPublishShowJSON(cmd *commander.Command, args []string) error { +func aptlyPublishShowJSON(_ *commander.Command, args []string) error { var err error distribution := args[0] diff --git a/cmd/repo_list.go b/cmd/repo_list.go index 40dec6d4..9c4b0d47 100644 --- a/cmd/repo_list.go +++ b/cmd/repo_list.go @@ -24,7 +24,7 @@ func aptlyRepoList(cmd *commander.Command, args []string) error { return aptlyRepoListTxt(cmd, args) } -func aptlyRepoListTxt(cmd *commander.Command, args []string) error { +func aptlyRepoListTxt(cmd *commander.Command, _ []string) error { var err error raw := cmd.Flag.Lookup("raw").Value.Get().(bool) @@ -71,7 +71,7 @@ func aptlyRepoListTxt(cmd *commander.Command, args []string) error { return err } -func aptlyRepoListJSON(cmd *commander.Command, args []string) error { +func aptlyRepoListJSON(_ *commander.Command, _ []string) error { var err error repos := make([]*deb.LocalRepo, context.NewCollectionFactory().LocalRepoCollection().Len()) diff --git a/cmd/repo_show.go b/cmd/repo_show.go index 6a0be42d..a61a5f1f 100644 --- a/cmd/repo_show.go +++ b/cmd/repo_show.go @@ -25,7 +25,7 @@ func aptlyRepoShow(cmd *commander.Command, args []string) error { return aptlyRepoShowTxt(cmd, args) } -func aptlyRepoShowTxt(cmd *commander.Command, args []string) error { +func aptlyRepoShowTxt(_ *commander.Command, args []string) error { var err error name := args[0] @@ -58,7 +58,7 @@ func aptlyRepoShowTxt(cmd *commander.Command, args []string) error { return err } -func aptlyRepoShowJSON(cmd *commander.Command, args []string) error { +func aptlyRepoShowJSON(_ *commander.Command, args []string) error { var err error name := args[0] diff --git a/cmd/snapshot_list.go b/cmd/snapshot_list.go index b7836630..7435b187 100644 --- a/cmd/snapshot_list.go +++ b/cmd/snapshot_list.go @@ -23,7 +23,7 @@ func aptlySnapshotList(cmd *commander.Command, args []string) error { return aptlySnapshotListTxt(cmd, args) } -func aptlySnapshotListTxt(cmd *commander.Command, args []string) error { +func aptlySnapshotListTxt(cmd *commander.Command, _ []string) error { var err error raw := cmd.Flag.Lookup("raw").Value.Get().(bool) @@ -59,7 +59,7 @@ func aptlySnapshotListTxt(cmd *commander.Command, args []string) error { return err } -func aptlySnapshotListJSON(cmd *commander.Command, args []string) error { +func aptlySnapshotListJSON(cmd *commander.Command, _ []string) error { var err error sortMethodString := cmd.Flag.Lookup("sort").Value.Get().(string) diff --git a/cmd/snapshot_show.go b/cmd/snapshot_show.go index 98f15a9f..e03a49e5 100644 --- a/cmd/snapshot_show.go +++ b/cmd/snapshot_show.go @@ -25,7 +25,7 @@ func aptlySnapshotShow(cmd *commander.Command, args []string) error { return aptlySnapshotShowTxt(cmd, args) } -func aptlySnapshotShowTxt(cmd *commander.Command, args []string) error { +func aptlySnapshotShowTxt(_ *commander.Command, args []string) error { var err error name := args[0] collectionFactory := context.NewCollectionFactory() @@ -85,7 +85,7 @@ func aptlySnapshotShowTxt(cmd *commander.Command, args []string) error { return err } -func aptlySnapshotShowJSON(cmd *commander.Command, args []string) error { +func aptlySnapshotShowJSON(_ *commander.Command, args []string) error { var err error name := args[0] diff --git a/cmd/task_run.go b/cmd/task_run.go index 8e18d94c..ff0e1dd6 100644 --- a/cmd/task_run.go +++ b/cmd/task_run.go @@ -62,11 +62,10 @@ func aptlyTaskRun(cmd *commander.Command, args []string) error { text, _ = reader.ReadString('\n') if text == "\n" { break - } else { - text = strings.TrimSpace(text) + "," - parsedArgs, _ := shellwords.Parse(text) - cmdArgs = append(cmdArgs, parsedArgs...) } + text = strings.TrimSpace(text) + "," + parsedArgs, _ := shellwords.Parse(text) + cmdArgs = append(cmdArgs, parsedArgs...) } if len(cmdArgs) == 0 { diff --git a/console/progress.go b/console/progress.go index 6f3ba53b..16191857 100644 --- a/console/progress.go +++ b/console/progress.go @@ -74,7 +74,7 @@ func (p *Progress) Flush() { } // InitBar starts progressbar for count bytes or count items -func (p *Progress) InitBar(count int64, isBytes bool, barType aptly.BarType) { +func (p *Progress) InitBar(count int64, isBytes bool, _ aptly.BarType) { if p.bar != nil { panic("bar already initialized") } diff --git a/context/context.go b/context/context.go index a4fef877..5c4e9d5f 100644 --- a/context/context.go +++ b/context/context.go @@ -457,7 +457,7 @@ func (context *AptlyContext) pgpProvider() string { return provider } -func (context *AptlyContext) getGPGFinder(provider string) pgp.GPGFinder { +func (context *AptlyContext) getGPGFinder() pgp.GPGFinder { switch context.pgpProvider() { case "gpg1": return pgp.GPG1Finder() @@ -480,7 +480,7 @@ func (context *AptlyContext) GetSigner() pgp.Signer { return &pgp.GoSigner{} } - return pgp.NewGpgSigner(context.getGPGFinder(provider)) + return pgp.NewGpgSigner(context.getGPGFinder()) } // GetVerifier returns Verifier with respect to provider @@ -493,7 +493,7 @@ func (context *AptlyContext) GetVerifier() pgp.Verifier { return &pgp.GoVerifier{} } - return pgp.NewGpgVerifier(context.getGPGFinder(provider)) + return pgp.NewGpgVerifier(context.getGPGFinder()) } // UpdateFlags sets internal copy of flags in the context diff --git a/deb/changes.go b/deb/changes.go index 6637034e..22c1fd86 100644 --- a/deb/changes.go +++ b/deb/changes.go @@ -220,12 +220,12 @@ func (c *Changes) GetField(field string) string { } // MatchesDependency implements PackageLike interface -func (c *Changes) MatchesDependency(d Dependency) bool { +func (c *Changes) MatchesDependency(_ Dependency) bool { return false } // MatchesArchitecture implements PackageLike interface -func (c *Changes) MatchesArchitecture(arch string) bool { +func (c *Changes) MatchesArchitecture(_ string) bool { return false } diff --git a/deb/package_collection.go b/deb/package_collection.go index 2da7fe67..c7e6a300 100644 --- a/deb/package_collection.go +++ b/deb/package_collection.go @@ -317,7 +317,7 @@ func (collection *PackageCollection) Scan(q PackageQuery) (result *PackageList) } // Search is not implemented -func (collection *PackageCollection) Search(dep Dependency, allMatches bool) (searchResults []*Package) { +func (collection *PackageCollection) Search(_ Dependency, _ bool) (searchResults []*Package) { panic("Not implemented") } diff --git a/deb/query.go b/deb/query.go index 19a1cdc9..1de9e95b 100644 --- a/deb/query.go +++ b/deb/query.go @@ -138,7 +138,7 @@ func (q *NotQuery) Matches(pkg PackageLike) bool { } // Fast is false -func (q *NotQuery) Fast(list PackageCatalog) bool { +func (q *NotQuery) Fast(_ PackageCatalog) bool { return false } @@ -197,7 +197,7 @@ func (q *FieldQuery) Query(list PackageCatalog) (result *PackageList) { } // Fast depends on the query -func (q *FieldQuery) Fast(list PackageCatalog) bool { +func (q *FieldQuery) Fast(_ PackageCatalog) bool { return false } @@ -265,7 +265,7 @@ func (q *PkgQuery) Matches(pkg PackageLike) bool { } // Fast is always true for package query -func (q *PkgQuery) Fast(list PackageCatalog) bool { +func (q *PkgQuery) Fast(_ PackageCatalog) bool { return true } @@ -280,12 +280,12 @@ func (q *PkgQuery) String() string { } // Matches on specific properties -func (q *MatchAllQuery) Matches(pkg PackageLike) bool { +func (q *MatchAllQuery) Matches(_ PackageLike) bool { return true } // Fast is always true for match all query -func (q *MatchAllQuery) Fast(list PackageCatalog) bool { +func (q *MatchAllQuery) Fast(_ PackageCatalog) bool { return true } diff --git a/deb/remote.go b/deb/remote.go index 6d30e999..72deb7af 100644 --- a/deb/remote.go +++ b/deb/remote.go @@ -428,7 +428,7 @@ ok: } // DownloadPackageIndexes downloads & parses package index files -func (repo *RemoteRepo) DownloadPackageIndexes(progress aptly.Progress, d aptly.Downloader, verifier pgp.Verifier, collectionFactory *CollectionFactory, +func (repo *RemoteRepo) DownloadPackageIndexes(progress aptly.Progress, d aptly.Downloader, verifier pgp.Verifier, _ *CollectionFactory, ignoreMismatch bool) error { if repo.packageList != nil { panic("packageList != nil") diff --git a/http/download.go b/http/download.go index a6e65896..7f8e0315 100644 --- a/http/download.go +++ b/http/download.go @@ -68,7 +68,7 @@ func NewDownloader(downLimit int64, maxTries int, progress aptly.Progress) aptly return downloader } -func (downloader *downloaderImpl) checkRedirect(req *http.Request, via []*http.Request) error { +func (downloader *downloaderImpl) checkRedirect(req *http.Request, _ []*http.Request) error { if downloader.progress != nil { downloader.progress.Printf("Following redirect to %s...\n", req.URL) } diff --git a/http/fake.go b/http/fake.go index 2cbb72d6..40a1093d 100644 --- a/http/fake.go +++ b/http/fake.go @@ -61,7 +61,7 @@ func (f *FakeDownloader) Empty() bool { } // GetLength returns content length of given url -func (f *FakeDownloader) GetLength(ctx context.Context, url string) (int64, error) { +func (f *FakeDownloader) GetLength(_ context.Context, url string) (int64, error) { expectation, err := f.getExpectedRequest(url) if err != nil { return -1, err @@ -89,7 +89,7 @@ func (f *FakeDownloader) getExpectedRequest(url string) (*expectedRequest, error } // DownloadWithChecksum performs fake download by matching against first expectation in the queue or any expectation, with cheksum verification -func (f *FakeDownloader) DownloadWithChecksum(ctx context.Context, url string, filename string, expected *utils.ChecksumInfo, ignoreMismatch bool) error { +func (f *FakeDownloader) DownloadWithChecksum(_ context.Context, url string, filename string, expected *utils.ChecksumInfo, ignoreMismatch bool) error { expectation, err := f.getExpectedRequest(url) if err != nil { return err diff --git a/http/grab.go b/http/grab.go index 2d07521c..ecd0f368 100644 --- a/http/grab.go +++ b/http/grab.go @@ -114,7 +114,7 @@ func (d *GrabDownloader) maybeSetupChecksum(req *grab.Request, expected *utils.C return nil } -func (d *GrabDownloader) download(ctx context.Context, url string, destination string, expected *utils.ChecksumInfo, ignoreMismatch bool) error { +func (d *GrabDownloader) download(_ context.Context, url string, destination string, expected *utils.ChecksumInfo, ignoreMismatch bool) error { // TODO clean up dest dir on permanent failure d.log("Download %s -> %s\n", url, destination) @@ -155,7 +155,7 @@ func (d *GrabDownloader) GetProgress() aptly.Progress { return d.progress } -func (d *GrabDownloader) GetLength(ctx context.Context, url string) (int64, error) { +func (d *GrabDownloader) GetLength(_ context.Context, url string) (int64, error) { resp, err := http.Head(url) if err != nil { return -1, err diff --git a/main.go b/main.go index 2503571a..337575a4 100644 --- a/main.go +++ b/main.go @@ -1,9 +1,7 @@ package main import ( - "math/rand" "os" - "time" "github.com/aptly-dev/aptly/aptly" "github.com/aptly-dev/aptly/cmd" @@ -22,7 +20,5 @@ func main() { aptly.Version = Version - rand.Seed(time.Now().UnixNano()) - os.Exit(cmd.Run(cmd.RootCommand(), os.Args[1:], true)) } diff --git a/main_test.go b/main_test.go index 35208ed3..81ef138d 100644 --- a/main_test.go +++ b/main_test.go @@ -6,7 +6,6 @@ package main import ( "flag" "fmt" - "math/rand" "os" "strings" "testing" @@ -53,8 +52,6 @@ func TestRunMain(t *testing.T) { aptly.Version = Version - rand.Seed(time.Now().UnixNano()) - args := filterOutTestArgs(os.Args[1:]) root := cmd.RootCommand() root.UsageLine = "aptly" diff --git a/s3/public.go b/s3/public.go index 0b606128..67edca09 100644 --- a/s3/public.go +++ b/s3/public.go @@ -131,7 +131,7 @@ func (storage *PublishedStorage) String() string { } // MkDir creates directory recursively under public path -func (storage *PublishedStorage) MkDir(path string) error { +func (storage *PublishedStorage) MkDir(_ string) error { // no op for S3 return nil } @@ -232,7 +232,7 @@ func (storage *PublishedStorage) Remove(path string) error { } // RemoveDirs removes directory structure under public path -func (storage *PublishedStorage) RemoveDirs(path string, progress aptly.Progress) error { +func (storage *PublishedStorage) RemoveDirs(path string, _ aptly.Progress) error { const page = 1000 filelist, _, err := storage.internalFilelist(path, false) diff --git a/swift/public.go b/swift/public.go index 0ca4796c..4f8c7b8a 100644 --- a/swift/public.go +++ b/swift/public.go @@ -113,7 +113,7 @@ func (storage *PublishedStorage) String() string { } // MkDir creates directory recursively under public path -func (storage *PublishedStorage) MkDir(path string) error { +func (storage *PublishedStorage) MkDir(_ string) error { // no op for Swift return nil } @@ -155,7 +155,7 @@ func (storage *PublishedStorage) Remove(path string) error { } // RemoveDirs removes directory structure under public path -func (storage *PublishedStorage) RemoveDirs(path string, progress aptly.Progress) error { +func (storage *PublishedStorage) RemoveDirs(path string, _ aptly.Progress) error { path = filepath.Join(storage.prefix, path) opts := swift.ObjectsOpts{ Prefix: path, diff --git a/swift/public_test.go b/swift/public_test.go index 31b633e8..ed8ff608 100644 --- a/swift/public_test.go +++ b/swift/public_test.go @@ -6,7 +6,6 @@ import ( "math/rand" "os" "path/filepath" - "time" . "gopkg.in/check.v1" @@ -27,8 +26,6 @@ var _ = Suite(&PublishedStorageSuite{}) func (s *PublishedStorageSuite) SetUpTest(c *C) { var err error - rand.Seed(int64(time.Now().Nanosecond())) - s.TestAddress = fmt.Sprintf("localhost:%d", rand.Intn(10000)+20000) s.AuthURL = "http://" + s.TestAddress + "/v1.0" diff --git a/task/output.go b/task/output.go index cd20ff73..f4c5e8f7 100644 --- a/task/output.go +++ b/task/output.go @@ -63,12 +63,12 @@ func (t *Output) Flush() { } // InitBar is needed for progress compatibility -func (t *Output) InitBar(count int64, isBytes bool, barType aptly.BarType) { +func (t *Output) InitBar(_ int64, _ bool, _ aptly.BarType) { // Not implemented } // InitBar publish output specific -func (t *PublishOutput) InitBar(count int64, isBytes bool, barType aptly.BarType) { +func (t *PublishOutput) InitBar(count int64, _ bool, barType aptly.BarType) { t.barType = &barType if barType == aptly.BarPublishGeneratePackageFiles { t.TotalNumberOfPackages = count @@ -88,12 +88,12 @@ func (t *PublishOutput) ShutdownBar() { } // AddBar is needed for progress compatibility -func (t *Output) AddBar(count int) { +func (t *Output) AddBar(_ int) { // Not implemented } // AddBar publish output specific -func (t *PublishOutput) AddBar(count int) { +func (t *PublishOutput) AddBar(_ int) { if t.barType != nil && *t.barType == aptly.BarPublishGeneratePackageFiles { t.RemainingNumberOfPackages-- t.Store(t) @@ -101,7 +101,7 @@ func (t *PublishOutput) AddBar(count int) { } // SetBar sets current position for progress bar -func (t *Output) SetBar(count int) { +func (t *Output) SetBar(_ int) { // Not implemented } @@ -123,5 +123,5 @@ func (t *Output) ColoredPrintf(msg string, a ...interface{}) { // PrintfStdErr does printf but in safe manner to output func (t *Output) PrintfStdErr(msg string, a ...interface{}) { - t.WriteString(msg) + t.WriteString(fmt.Sprintf(msg, a...)) } diff --git a/utils/logging.go b/utils/logging.go index d09079fa..592e8f30 100644 --- a/utils/logging.go +++ b/utils/logging.go @@ -58,7 +58,7 @@ func GetLogLevelOrDebug(levelStr string) zerolog.Level { type timestampHook struct{} -func (h *timestampHook) Run(e *zerolog.Event, l zerolog.Level, msg string) { +func (h *timestampHook) Run(e *zerolog.Event, _ zerolog.Level, _ string) { t := time.Now() ts := t.Format(time.RFC3339) e.Str("time", ts)