diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 1bd1994c..f623dc21 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -61,7 +61,7 @@ jobs: uses: actions/checkout@v2 - name: fmt - run: diff -au <(gofmt -s -d .) <(printf "") + run: diff -au <(gofumpt -d .) <(printf "") - name: Test 386 run: GOOS=linux GOARCH=386 go test -short ./... diff --git a/Makefile b/Makefile index 8b18373f..f80b361f 100644 --- a/Makefile +++ b/Makefile @@ -19,7 +19,8 @@ checks: getdeps: @mkdir -p ${GOPATH}/bin @echo "Installing golangci-lint" && curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.40.1 - @which stringer 1>/dev/null || (echo "Installing stringer" && go install -v golang.org/x/tools/cmd/stringer@v0.1.5) + @echo "Installing gofumpt" && go install mvdan.cc/gofumpt@latest + @echo "Installing stringer" && go install -v golang.org/x/tools/cmd/stringer@latest crosscompile: @(env bash $(PWD)/buildscripts/cross-compile.sh) diff --git a/cmd/admin-bucket-remote-add.go b/cmd/admin-bucket-remote-add.go index f7a31f7c..ce3025b8 100644 --- a/cmd/admin-bucket-remote-add.go +++ b/cmd/admin-bucket-remote-add.go @@ -65,6 +65,7 @@ var adminBucketRemoteAddFlags = []cli.Flag{ Usage: "disable proxying in active-active replication. If unset, default behavior is to proxy", }, } + var adminBucketRemoteAddCmd = cli.Command{ Name: "add", Usage: "add a new remote target", diff --git a/cmd/admin-bucket-remote-bandwidth.go b/cmd/admin-bucket-remote-bandwidth.go index 3821e737..f6247adc 100644 --- a/cmd/admin-bucket-remote-bandwidth.go +++ b/cmd/admin-bucket-remote-bandwidth.go @@ -132,6 +132,7 @@ func printTable(report madmin.Report, bits bool, iec bool) { } } } + func checkAdminBwInfoSyntax(ctx *cli.Context) { u := ctx.String("unit") if u != "bi" && diff --git a/cmd/admin-bucket-remote-edit.go b/cmd/admin-bucket-remote-edit.go index 35b9d2e5..daaddca1 100644 --- a/cmd/admin-bucket-remote-edit.go +++ b/cmd/admin-bucket-remote-edit.go @@ -59,6 +59,7 @@ var adminBucketRemoteEditFlags = []cli.Flag{ Usage: "bucket path lookup supported by the server. Valid options are '[on,off,auto]'", }, } + var adminBucketRemoteEditCmd = cli.Command{ Name: "edit", Usage: "edit remote target", diff --git a/cmd/admin-bucket-remote-ls.go b/cmd/admin-bucket-remote-ls.go index f1c75e33..560d463d 100644 --- a/cmd/admin-bucket-remote-ls.go +++ b/cmd/admin-bucket-remote-ls.go @@ -100,7 +100,6 @@ func mainAdminBucketRemoteList(ctx *cli.Context) error { } func printRemotes(ctx *cli.Context, urlStr string, targets []madmin.BucketTarget) { - maxURLLen := 10 maxTgtLen := 6 maxSrcLen := 6 diff --git a/cmd/admin-bucket-remote-rm.go b/cmd/admin-bucket-remote-rm.go index 3646caf8..469ee1a2 100644 --- a/cmd/admin-bucket-remote-rm.go +++ b/cmd/admin-bucket-remote-rm.go @@ -30,6 +30,7 @@ var adminBucketRemoteRmFlags = []cli.Flag{ Usage: "ARN to be removed", }, } + var adminBucketRemoteRmCmd = cli.Command{ Name: "rm", Usage: "remove configured remote target", @@ -55,7 +56,6 @@ EXAMPLES: // checkAdminBucketRemoteRemoveSyntax - validate all the passed arguments func checkAdminBucketRemoteRemoveSyntax(ctx *cli.Context) { - if len(ctx.Args()) != 1 { cli.ShowCommandHelpAndExit(ctx, ctx.Command.Name, 1) // last argument is exit code } diff --git a/cmd/admin-config-export.go b/cmd/admin-config-export.go index 41d5a1df..3c95c413 100644 --- a/cmd/admin-config-export.go +++ b/cmd/admin-config-export.go @@ -73,7 +73,6 @@ func checkAdminConfigExportSyntax(ctx *cli.Context) { } func mainAdminConfigExport(ctx *cli.Context) error { - checkAdminConfigExportSyntax(ctx) // Export the alias parameter from cli diff --git a/cmd/admin-config-get.go b/cmd/admin-config-get.go index d4ae6ed4..8931c6ef 100644 --- a/cmd/admin-config-get.go +++ b/cmd/admin-config-get.go @@ -86,7 +86,6 @@ func checkAdminConfigGetSyntax(ctx *cli.Context) { } func mainAdminConfigGet(ctx *cli.Context) error { - checkAdminConfigGetSyntax(ctx) // Get the alias parameter from cli diff --git a/cmd/admin-config-history.go b/cmd/admin-config-history.go index 93ea5e3b..0cdba6f4 100644 --- a/cmd/admin-config-history.go +++ b/cmd/admin-config-history.go @@ -114,7 +114,6 @@ func checkAdminConfigHistorySyntax(ctx *cli.Context) { } func mainAdminConfigHistory(ctx *cli.Context) error { - checkAdminConfigHistorySyntax(ctx) console.SetColor("ConfigHistoryMessageRestoreID", color.New(color.Bold)) diff --git a/cmd/admin-config-import.go b/cmd/admin-config-import.go index f400156b..62da570a 100644 --- a/cmd/admin-config-import.go +++ b/cmd/admin-config-import.go @@ -83,7 +83,6 @@ func checkAdminConfigImportSyntax(ctx *cli.Context) { } func mainAdminConfigImport(ctx *cli.Context) error { - checkAdminConfigImportSyntax(ctx) // Set color preference of command outputs diff --git a/cmd/admin-config-reset.go b/cmd/admin-config-reset.go index 7a7e7b3b..71d4aa9e 100644 --- a/cmd/admin-config-reset.go +++ b/cmd/admin-config-reset.go @@ -72,7 +72,6 @@ func (u configResetMessage) String() (msg string) { if u.restart { msg += console.Colorize("ResetConfigSuccess", fmt.Sprintf("Please restart your server with `%s`.\n", suggestion)) - } return } @@ -95,7 +94,6 @@ func checkAdminConfigResetSyntax(ctx *cli.Context) { // main config set function func mainAdminConfigReset(ctx *cli.Context) error { - // Check command arguments checkAdminConfigResetSyntax(ctx) diff --git a/cmd/admin-config-restore.go b/cmd/admin-config-restore.go index be27d40f..3ca1bf48 100644 --- a/cmd/admin-config-restore.go +++ b/cmd/admin-config-restore.go @@ -82,7 +82,6 @@ func checkAdminConfigRestoreSyntax(ctx *cli.Context) { } func mainAdminConfigRestore(ctx *cli.Context) error { - checkAdminConfigRestoreSyntax(ctx) console.SetColor("ConfigRestoreMessage", color.New(color.FgGreen)) diff --git a/cmd/admin-config-set.go b/cmd/admin-config-set.go index 2afa8b07..f0cae993 100644 --- a/cmd/admin-config-set.go +++ b/cmd/admin-config-set.go @@ -94,7 +94,6 @@ func checkAdminConfigSetSyntax(ctx *cli.Context) { // main config set function func mainAdminConfigSet(ctx *cli.Context) error { - // Check command arguments checkAdminConfigSetSyntax(ctx) diff --git a/cmd/admin-console.go b/cmd/admin-console.go index 1553ba5f..330d2096 100644 --- a/cmd/admin-console.go +++ b/cmd/admin-console.go @@ -94,8 +94,8 @@ func (l logMessage) JSON() string { fatalIf(probe.NewError(err), "Unable to marshal into JSON.") return string(logJSON) - } + func getLogTime(lt string) string { tm, err := time.Parse(time.RFC3339Nano, lt) if err != nil { @@ -107,7 +107,7 @@ func getLogTime(lt string) string { // String - return colorized loginfo as string. func (l logMessage) String() string { var hostStr string - var b = &strings.Builder{} + b := &strings.Builder{} if l.NodeName != "" { hostStr = fmt.Sprintf("%s ", colorizedNodeName(l.NodeName)) } diff --git a/cmd/admin-heal-result-item.go b/cmd/admin-heal-result-item.go index 31e1f8e2..ae18211d 100644 --- a/cmd/admin-heal-result-item.go +++ b/cmd/admin-heal-result-item.go @@ -53,7 +53,6 @@ func (h hri) getObjectHCCChange() (b, a col, err error) { err, surplusShardsAfterHeal, parityShards) } return - } // getReplicatedFileHCCChange - fetches health color code for metadata diff --git a/cmd/admin-heal.go b/cmd/admin-heal.go index e645667d..83ee79be 100644 --- a/cmd/admin-heal.go +++ b/cmd/admin-heal.go @@ -356,7 +356,7 @@ func (s verboseBackgroundHealStatusMessage) String() string { setsStatus := generateSetsStatus(allDisks) serversStatus := generateServersStatus(allDisks) - var poolsInfo = make(map[int]poolInfo) + poolsInfo := make(map[int]poolInfo) for _, pool := range pools { tolerance := computePoolTolerance(pool, parity, setsStatus, serversStatus) endpoints := computePoolEndpoints(pool, serversStatus) @@ -365,7 +365,7 @@ func (s verboseBackgroundHealStatusMessage) String() string { distributed := len(serversStatus) > 1 - var plural = "" + plural := "" if distributed { plural = "s" } @@ -376,7 +376,7 @@ func (s verboseBackgroundHealStatusMessage) String() string { fmt.Fprintf(&msg, "Pool %s:\n", humanize.Ordinal(pool+1)) // Sort servers in this pool by name - var orderedEndpoints = make([]string, len(poolsInfo[pool].endpoints)) + orderedEndpoints := make([]string, len(poolsInfo[pool].endpoints)) copy(orderedEndpoints, poolsInfo[pool].endpoints) sort.Strings(orderedEndpoints) @@ -586,7 +586,6 @@ func transformScanArg(scanArg string) madmin.HealScanMode { // mainAdminHeal - the entry function of heal command func mainAdminHeal(ctx *cli.Context) error { - // Check for command syntax checkAdminHealSyntax(ctx) diff --git a/cmd/admin-main.go b/cmd/admin-main.go index 0bb2475e..6131caa6 100644 --- a/cmd/admin-main.go +++ b/cmd/admin-main.go @@ -19,9 +19,7 @@ package cmd import "github.com/minio/cli" -var ( - adminFlags = []cli.Flag{} -) +var adminFlags = []cli.Flag{} const ( // dot represents a list item, for eg. server status - online (green) or offline (red) diff --git a/cmd/admin-policy-set.go b/cmd/admin-policy-set.go index 355e678f..f29ca47f 100644 --- a/cmd/admin-policy-set.go +++ b/cmd/admin-policy-set.go @@ -55,9 +55,7 @@ EXAMPLES: `, } -var ( - errBadUserGroupArg = errors.New("Last argument must be of the form user=xx or group=xx") -) +var errBadUserGroupArg = errors.New("Last argument must be of the form user=xx or group=xx") func checkAdminPolicySetSyntax(ctx *cli.Context) { if len(ctx.Args()) != 3 { diff --git a/cmd/admin-prometheus-generate.go b/cmd/admin-prometheus-generate.go index 2fdbd346..587c11f9 100644 --- a/cmd/admin-prometheus-generate.go +++ b/cmd/admin-prometheus-generate.go @@ -189,7 +189,6 @@ func generatePrometheusConfig(ctx *cli.Context) error { // mainAdminPrometheus is the handle for "mc admin prometheus generate" sub-command. func mainAdminPrometheusGenerate(ctx *cli.Context) error { - console.SetColor("yaml", color.New(color.FgGreen)) checkAdminPrometheusSyntax(ctx) diff --git a/cmd/admin-service-restart.go b/cmd/admin-service-restart.go index 7f4d9cfb..71810a6b 100644 --- a/cmd/admin-service-restart.go +++ b/cmd/admin-service-restart.go @@ -101,7 +101,6 @@ func checkAdminServiceRestartSyntax(ctx *cli.Context) { } func mainAdminServiceRestart(ctx *cli.Context) error { - // Validate serivce restart syntax. checkAdminServiceRestartSyntax(ctx) diff --git a/cmd/admin-service-stop.go b/cmd/admin-service-stop.go index 9062985b..8f097aaa 100644 --- a/cmd/admin-service-stop.go +++ b/cmd/admin-service-stop.go @@ -74,7 +74,6 @@ func checkAdminServiceStopSyntax(ctx *cli.Context) { } func mainAdminServiceStop(ctx *cli.Context) error { - // Validate serivce stop syntax. checkAdminServiceStopSyntax(ctx) diff --git a/cmd/admin-subnet-health.go b/cmd/admin-subnet-health.go index 36dce978..3f91c40c 100644 --- a/cmd/admin-subnet-health.go +++ b/cmd/admin-subnet-health.go @@ -114,9 +114,9 @@ func checkAdminHealthSyntax(ctx *cli.Context) { } } -//compress and tar MinIO health output +// compress and tar MinIO health output func tarGZ(healthInfo interface{}, version string, filename string, showMessages bool) error { - f, err := os.OpenFile(filename, os.O_CREATE|os.O_RDWR, 0666) + f, err := os.OpenFile(filename, os.O_CREATE|os.O_RDWR, 0o666) if err != nil { return err } @@ -665,5 +665,7 @@ func (f HealthDataTypeFlag) ApplyWithError(set *flag.FlagSet) error { return nil } -var liteOptions = HealthDataTypeSlice(madmin.HealthDataTypesLite) -var fullOptions = HealthDataTypeSlice(madmin.HealthDataTypesList) +var ( + liteOptions = HealthDataTypeSlice(madmin.HealthDataTypesLite) + fullOptions = HealthDataTypeSlice(madmin.HealthDataTypesList) +) diff --git a/cmd/admin-tier-info.go b/cmd/admin-tier-info.go index dd96cd85..d1992ad1 100644 --- a/cmd/admin-tier-info.go +++ b/cmd/admin-tier-info.go @@ -103,6 +103,7 @@ func (t tierInfos) NumRows() int { func (t tierInfos) NumCols() int { return len(tierInfoRowNames) } + func (t tierInfos) EmptyMessage() string { return "No remote tiers configured." } diff --git a/cmd/admin-tier-ls.go b/cmd/admin-tier-ls.go index 7b240005..2a0dfbc5 100644 --- a/cmd/admin-tier-ls.go +++ b/cmd/admin-tier-ls.go @@ -115,6 +115,7 @@ func (t tierLS) NumRows() int { func (t tierLS) NumCols() int { return len(tierLSRowNames) } + func (t tierLS) EmptyMessage() string { return "No remote tier has been configured" } diff --git a/cmd/admin-top-locks.go b/cmd/admin-top-locks.go index 9fff8c32..56c5ba99 100644 --- a/cmd/admin-top-locks.go +++ b/cmd/admin-top-locks.go @@ -117,7 +117,6 @@ func checkAdminTopLocksSyntax(ctx *cli.Context) { } func mainAdminTopLocks(ctx *cli.Context) error { - checkAdminTopLocksSyntax(ctx) // Get the alias parameter from cli diff --git a/cmd/admin-trace.go b/cmd/admin-trace.go index 3e9ae0ac..90aa852d 100644 --- a/cmd/admin-trace.go +++ b/cmd/admin-trace.go @@ -113,9 +113,7 @@ EXAMPLES: const timeFormat = "2006-01-02T15:04:05:000" -var ( - colors = []color.Attribute{color.FgCyan, color.FgWhite, color.FgYellow, color.FgGreen} -) +var colors = []color.Attribute{color.FgCyan, color.FgWhite, color.FgYellow, color.FgGreen} func checkAdminTraceSyntax(ctx *cli.Context) { if len(ctx.Args()) != 1 { @@ -205,7 +203,6 @@ func matchTrace(ctx *cli.Context, traceInfo madmin.ServiceTraceInfo) bool { // Calculate tracing options for command line flags func tracingOpts(ctx *cli.Context) (opts madmin.ServiceTraceOpts, e error) { - if t := ctx.String("response-threshold"); t != "" { d, e := time.ParseDuration(t) if e != nil { @@ -423,7 +420,7 @@ func (s shortTraceMsg) JSON() string { func (s shortTraceMsg) String() string { var hostStr string - var b = &strings.Builder{} + b := &strings.Builder{} if s.Host != "" { hostStr = colorizedNodeName(s.Host) @@ -542,7 +539,7 @@ func (t traceMessage) JSON() string { func (t traceMessage) String() string { var nodeNameStr string - var b = &strings.Builder{} + b := &strings.Builder{} trc := t.Trace if trc.NodeName != "" { diff --git a/cmd/alias-list.go b/cmd/alias-list.go index d001fa6f..dddaf3b0 100644 --- a/cmd/alias-list.go +++ b/cmd/alias-list.go @@ -88,7 +88,7 @@ func mainAliasList(ctx *cli.Context, deprecated bool) error { // Prints all the aliases func printAliases(aliases ...aliasMessage) { - var maxAlias = 0 + maxAlias := 0 for _, alias := range aliases { if len(alias.Alias) > maxAlias { maxAlias = len(alias.Alias) diff --git a/cmd/alias-main.go b/cmd/alias-main.go index d84d8429..c158b385 100644 --- a/cmd/alias-main.go +++ b/cmd/alias-main.go @@ -35,9 +35,7 @@ import ( // ---- // -var ( - aliasFlags = []cli.Flag{} -) +var aliasFlags = []cli.Flag{} var aliasSubcommands = []cli.Command{ aliasSetCmd, diff --git a/cmd/anonymous-main.go b/cmd/anonymous-main.go index 685e2dd9..9dd46328 100644 --- a/cmd/anonymous-main.go +++ b/cmd/anonymous-main.go @@ -32,14 +32,12 @@ import ( "github.com/minio/pkg/console" ) -var ( - anonymousFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "recursive, r", - Usage: "list recursively", - }, - } -) +var anonymousFlags = []cli.Flag{ + cli.BoolFlag{ + Name: "recursive, r", + Usage: "list recursively", + }, +} // Manage anonymous access to buckets and objects. var anonymousCmd = cli.Command{ diff --git a/cmd/auto-complete.go b/cmd/auto-complete.go index b93b6bcb..fdf75db1 100644 --- a/cmd/auto-complete.go +++ b/cmd/auto-complete.go @@ -84,7 +84,6 @@ func completeAdminConfigKeys(aliasPath string, keyPrefix string) (prediction []s // then recursively scans it. This is needed to satisfy posener/complete // (look at posener/complete.PredictFiles) func completeS3Path(s3Path string) (prediction []string) { - // Convert alias/bucket/incompl to alias/bucket/ to list its contents parentDirPath := filepath.Dir(s3Path) + "/" clnt, err := newClient(parentDirPath) @@ -220,10 +219,12 @@ func (al aliasComplete) Predict(a complete.Args) (prediction []string) { return } -var adminConfigCompleter = adminConfigComplete{} -var s3Completer = s3Complete{} -var aliasCompleter = aliasComplete{} -var fsCompleter = fsComplete{} +var ( + adminConfigCompleter = adminConfigComplete{} + s3Completer = s3Complete{} + aliasCompleter = aliasComplete{} + fsCompleter = fsComplete{} +) // The list of all commands supported by mc with their mapping // with their bash completer function @@ -391,7 +392,7 @@ var completeCmds = map[string]complete.Predictor{ // flagsToCompleteFlags transforms a cli.Flag to complete.Flags // understood by posener/complete library. func flagsToCompleteFlags(flags []cli.Flag) complete.Flags { - var complFlags = make(complete.Flags) + complFlags := make(complete.Flags) for _, f := range flags { for _, s := range strings.Split(f.GetName(), ",") { var flagName string @@ -429,7 +430,7 @@ func cmdToCompleteCmd(cmd cli.Command, parentPath string) complete.Command { func mainComplete() error { // Recursively register all commands and subcommands // along with global and local flags - var complCmds = make(complete.Commands) + complCmds := make(complete.Commands) for _, cmd := range appCmds { if cmd.Hidden { continue diff --git a/cmd/auto-complete_test.go b/cmd/auto-complete_test.go index 09bcbc4f..092cbf4c 100644 --- a/cmd/auto-complete_test.go +++ b/cmd/auto-complete_test.go @@ -25,7 +25,6 @@ import ( ) func TestAutoCompletionCompletness(t *testing.T) { - var checkCompletion func(cmd cli.Command, cmdPath string) error checkCompletion = func(cmd cli.Command, cmdPath string) error { diff --git a/cmd/cat-main.go b/cmd/cat-main.go index 711e0591..06922b8f 100644 --- a/cmd/cat-main.go +++ b/cmd/cat-main.go @@ -34,18 +34,16 @@ import ( "github.com/minio/mc/pkg/probe" ) -var ( - catFlags = []cli.Flag{ - cli.StringFlag{ - Name: "rewind", - Usage: "display an earlier object version", - }, - cli.StringFlag{ - Name: "version-id, vid", - Usage: "display a specific version of an object", - }, - } -) +var catFlags = []cli.Flag{ + cli.StringFlag{ + Name: "rewind", + Usage: "display an earlier object version", + }, + cli.StringFlag{ + Name: "version-id, vid", + Usage: "display a specific version of an object", + }, +} // Display contents of a file. var catCmd = cli.Command{ @@ -174,7 +172,7 @@ func catURL(ctx context.Context, sourceURL, sourceVersion string, timeRef time.T case "-": reader = os.Stdin default: - var versionID = sourceVersion + versionID := sourceVersion var err *probe.Error // Try to stat the object, the purpose is to: // 1. extract the size of S3 object so we can check if the size of the diff --git a/cmd/certs.go b/cmd/certs.go index 8638c050..e91a3260 100644 --- a/cmd/certs.go +++ b/cmd/certs.go @@ -50,7 +50,7 @@ func createCertsDir() *probe.Error { if err != nil { return err.Trace() } - if e := os.MkdirAll(p, 0700); e != nil { + if e := os.MkdirAll(p, 0o700); e != nil { return probe.NewError(e) } return nil @@ -90,7 +90,7 @@ func createCAsDir() *probe.Error { if err != nil { return err.Trace() } - if e := os.MkdirAll(p, 0700); e != nil { + if e := os.MkdirAll(p, 0o700); e != nil { return probe.NewError(e) } return nil diff --git a/cmd/client-errors.go b/cmd/client-errors.go index e2bb3f9d..4022180a 100644 --- a/cmd/client-errors.go +++ b/cmd/client-errors.go @@ -170,8 +170,7 @@ func (e ObjectMissing) Error() string { } // ObjectIsDeleteMarker - object is a delete marker as latest -type ObjectIsDeleteMarker struct { -} +type ObjectIsDeleteMarker struct{} func (e ObjectIsDeleteMarker) Error() string { return "Object is marked as deleted" diff --git a/cmd/client-fs.go b/cmd/client-fs.go index 58c46789..8cda28d9 100644 --- a/cmd/client-fs.go +++ b/cmd/client-fs.go @@ -59,12 +59,11 @@ const ( metadataKeyS3Cmd = "X-Amz-Meta-S3cmd-Attrs" ) -var ( // GOOS specific ignore list. - ignoreFiles = map[string][]string{ - "darwin": {"*.DS_Store"}, - "default": {"lost+found"}, - } -) +// GOOS specific ignore list. +var ignoreFiles = map[string][]string{ + "darwin": {"*.DS_Store"}, + "default": {"lost+found"}, +} // fsNew - instantiate a new fs func fsNew(path string) (Client, *probe.Error) { @@ -274,7 +273,7 @@ func (f *fsClient) put(ctx context.Context, reader io.Reader, size int64, progre if objectDir != "" { // Create any missing top level directories. - if e := os.MkdirAll(objectDir, 0777); e != nil { + if e := os.MkdirAll(objectDir, 0o777); e != nil { err := f.toClientError(e, f.PathURL.Path) return 0, err.Trace(f.PathURL.Path) } @@ -294,7 +293,7 @@ func (f *fsClient) put(ctx context.Context, reader io.Reader, size int64, progre // should remove any partial download if any. defer os.Remove(objectPartPath) - tmpFile, e := os.OpenFile(objectPartPath, os.O_CREATE|os.O_WRONLY, 0666) + tmpFile, e := os.OpenFile(objectPartPath, os.O_CREATE|os.O_WRONLY, 0o666) if e != nil { err := f.toClientError(e, f.PathURL.Path) return 0, err.Trace(f.PathURL.Path) @@ -921,7 +920,7 @@ func (f *fsClient) MakeBucket(ctx context.Context, region string, ignoreExisting // to call os.Mkdir() when ignoredExisting is disabled and os.MkdirAll() // otherwise. // NOTE: withLock=true has no meaning here. - e := os.MkdirAll(f.PathURL.Path, 0777) + e := os.MkdirAll(f.PathURL.Path, 0o777) if e != nil { return probe.NewError(e) } @@ -1009,11 +1008,11 @@ func (f *fsClient) GetAccess(ctx context.Context) (access string, policyJSON str } // Mask with os.ModePerm to get only inode permissions switch st.Mode() & os.ModePerm { - case os.FileMode(0777): + case os.FileMode(0o777): return "readwrite", "", nil - case os.FileMode(0555): + case os.FileMode(0o555): return "readonly", "", nil - case os.FileMode(0333): + case os.FileMode(0o333): return "writeonly", "", nil } return "none", "", nil @@ -1036,13 +1035,13 @@ func (f *fsClient) SetAccess(ctx context.Context, access string, isJSON bool) *p var mode os.FileMode switch access { case "readonly": - mode = os.FileMode(0555) + mode = os.FileMode(0o555) case "writeonly": - mode = os.FileMode(0333) + mode = os.FileMode(0o333) case "readwrite": - mode = os.FileMode(0777) + mode = os.FileMode(0o777) case "none": - mode = os.FileMode(0755) + mode = os.FileMode(0o755) } e := os.Chmod(f.PathURL.Path, mode) if e != nil { @@ -1205,7 +1204,6 @@ func (f *fsClient) RemoveReplication(ctx context.Context) *probe.Error { API: "RemoveReplication", APIType: "filesystem", }) - } // GetReplicationMetrics - Get replication metrics for a given bucket, not implemented. diff --git a/cmd/client-fs_linux.go b/cmd/client-fs_linux.go index 178e30c3..f5de5a48 100644 --- a/cmd/client-fs_linux.go +++ b/cmd/client-fs_linux.go @@ -23,11 +23,10 @@ package cmd import ( "encoding/hex" "strings" + "unicode/utf8" "github.com/pkg/xattr" "github.com/rjeczalik/notify" - - "unicode/utf8" ) var ( diff --git a/cmd/client-fs_test.go b/cmd/client-fs_test.go index 07d86912..6cda90cf 100644 --- a/cmd/client-fs_test.go +++ b/cmd/client-fs_test.go @@ -286,7 +286,8 @@ func (s *TestSuite) TestGet(c *C) { n, err := fsClient.Put(context.Background(), reader, int64(len(data)), nil, PutOptions{ metadata: map[string]string{ "Content-Type": "application/octet-stream", - }}) + }, + }) c.Assert(err, IsNil) c.Assert(n, Equals, int64(len(data))) @@ -296,7 +297,6 @@ func (s *TestSuite) TestGet(c *C) { _, e = io.Copy(&results, reader) c.Assert(e, IsNil) c.Assert([]byte(data), DeepEquals, results.Bytes()) - } // Test get range in a file. diff --git a/cmd/client-s3.go b/cmd/client-s3.go index 836f8fa6..9da495d1 100644 --- a/cmd/client-s3.go +++ b/cmd/client-s3.go @@ -440,11 +440,13 @@ func (c *S3Client) ListNotificationConfigs(ctx context.Context, arn string) ([]N continue } prefix, suffix := getFilters(config.Config) - configs = append(configs, NotificationConfig{ID: config.ID, + configs = append(configs, NotificationConfig{ + ID: config.ID, Arn: config.Topic, Events: prettyEventNames(config.Events), Prefix: prefix, - Suffix: suffix}) + Suffix: suffix, + }) } for _, config := range mb.QueueConfigs { @@ -452,11 +454,13 @@ func (c *S3Client) ListNotificationConfigs(ctx context.Context, arn string) ([]N continue } prefix, suffix := getFilters(config.Config) - configs = append(configs, NotificationConfig{ID: config.ID, + configs = append(configs, NotificationConfig{ + ID: config.ID, Arn: config.Queue, Events: prettyEventNames(config.Events), Prefix: prefix, - Suffix: suffix}) + Suffix: suffix, + }) } for _, config := range mb.LambdaConfigs { @@ -464,11 +468,13 @@ func (c *S3Client) ListNotificationConfigs(ctx context.Context, arn string) ([]N continue } prefix, suffix := getFilters(config.Config) - configs = append(configs, NotificationConfig{ID: config.ID, + configs = append(configs, NotificationConfig{ + ID: config.ID, Arn: config.Lambda, Events: prettyEventNames(config.Events), Prefix: prefix, - Suffix: suffix}) + Suffix: suffix, + }) } return configs, nil @@ -646,7 +652,7 @@ func (c *S3Client) Select(ctx context.Context, expression string, sse encrypt.Se } func (c *S3Client) notificationToEventsInfo(ninfo notification.Info) []EventInfo { - var eventsInfo = make([]EventInfo, len(ninfo.Records)) + eventsInfo := make([]EventInfo, len(ninfo.Records)) for i, record := range ninfo.Records { bucketName := record.S3.Bucket.Name var key string @@ -1115,7 +1121,8 @@ func (c *S3Client) Remove(ctx context.Context, isIncomplete, isRemoveBucket, isB Err: probe.NewError(errors.New( "use `mc rm` command to delete prefixes, or point your" + " bucket directly, `mc rb //`"), - )} + ), + } return } } @@ -1405,7 +1412,7 @@ func (c *S3Client) SetAccess(ctx context.Context, bucketPolicy string, isJSON bo if e != nil { return probe.NewError(e) } - var p = policy.BucketAccessPolicy{Version: "2012-10-17"} + p := policy.BucketAccessPolicy{Version: "2012-10-17"} if policyStr != "" { if e = json.Unmarshal([]byte(policyStr), &p); e != nil { return probe.NewError(e) @@ -1458,7 +1465,7 @@ func (c *S3Client) statIncompleteUpload(ctx context.Context, bucket, object stri objectMetadata.URL = c.targetURL.Clone() objectMetadata.Time = objectMultipartInfo.Initiated objectMetadata.Size = objectMultipartInfo.Size - objectMetadata.Type = os.FileMode(0664) + objectMetadata.Type = os.FileMode(0o664) objectMetadata.Metadata = map[string]string{} return objectMetadata, nil } @@ -1816,7 +1823,6 @@ func (c *S3Client) versionedList(ctx context.Context, contentCh chan *ClientCont noVersioning: c.unversionedList(ctx, contentCh, opts) - } // unversionedList is the non versioned S3 listing @@ -2042,7 +2048,7 @@ func (c *S3Client) objectInfo2ClientContent(bucket string, entry minio.ObjectInf content.Time = time.Now() } } else { - content.Type = os.FileMode(0664) + content.Type = os.FileMode(0o664) } return content @@ -2058,7 +2064,8 @@ func (c *S3Client) bucketStat(ctx context.Context, bucket string) (*ClientConten return nil, probe.NewError(BucketDoesNotExist{Bucket: bucket}) } return &ClientContent{ - URL: c.targetURL.Clone(), BucketName: bucket, Time: time.Unix(0, 0), Type: os.ModeDir}, nil + URL: c.targetURL.Clone(), BucketName: bucket, Time: time.Unix(0, 0), Type: os.ModeDir, + }, nil } func (c *S3Client) listInRoutine(ctx context.Context, contentCh chan *ClientContent, opts ListOptions) { diff --git a/cmd/client.go b/cmd/client.go index e45f0ed2..9800a85e 100644 --- a/cmd/client.go +++ b/cmd/client.go @@ -96,7 +96,6 @@ type CopyOptions struct { type Client interface { // Common operations Stat(ctx context.Context, opts StatOptions) (content *ClientContent, err *probe.Error) - List(ctx context.Context, opts ListOptions) <-chan *ClientContent // Bucket operations @@ -120,7 +119,6 @@ type Client interface { // I/O operations with metadata. Get(ctx context.Context, opts GetOptions) (reader io.ReadCloser, err *probe.Error) - Put(ctx context.Context, reader io.Reader, size int64, progress io.Reader, opts PutOptions) (n int64, err *probe.Error) // Object Locking related API @@ -140,7 +138,6 @@ type Client interface { Remove(ctx context.Context, isIncomplete, isRemoveBucket, isBypass bool, contentCh <-chan *ClientContent) (errorCh <-chan RemoveResult) // GetURL returns back internal url GetURL() ClientURL - AddUserAgent(app, version string) // Tagging operations diff --git a/cmd/common-methods.go b/cmd/common-methods.go index 6df66e17..483d7e67 100644 --- a/cmd/common-methods.go +++ b/cmd/common-methods.go @@ -245,7 +245,7 @@ func getSourceStream(ctx context.Context, alias, urlStr, versionID string, fetch st.Size = oinfo.Size st.ETag = oinfo.ETag st.Expires = oinfo.Expires - st.Type = os.FileMode(0664) + st.Type = os.FileMode(0o664) st.Metadata = map[string]string{} for k := range oinfo.Metadata { st.Metadata[k] = oinfo.Metadata.Get(k) @@ -347,7 +347,6 @@ func putTargetStreamWithURL(urlStr string, reader io.Reader, size int64, opts Pu // copySourceToTargetURL copies to targetURL from source. func copySourceToTargetURL(ctx context.Context, alias, urlStr, source, sourceVersionID, mode, until, legalHold string, size int64, progress io.Reader, opts CopyOptions) *probe.Error { - targetClnt, err := newClientFromAlias(alias, urlStr) if err != nil { return err.Trace(alias, urlStr) @@ -423,7 +422,7 @@ func uploadSourceToTargetURL(ctx context.Context, urls URLs, progress io.Reader, tgtSSE := getSSE(targetPath, encKeyDB[targetAlias]) var err *probe.Error - var metadata = map[string]string{} + metadata := map[string]string{} var mode, until, legalHold string // add object retention fields in metadata for target, if target wants diff --git a/cmd/common-methods_test.go b/cmd/common-methods_test.go index 460d90f7..3bfb8993 100644 --- a/cmd/common-methods_test.go +++ b/cmd/common-methods_test.go @@ -30,9 +30,9 @@ func TestGetDecodedKey(t *testing.T) { err error status bool }{ - //success scenario the key contains non printable (tab) character as key + // success scenario the key contains non printable (tab) character as key {"s3/documents/=MzJieXRlc2xvbmdzZWNyZWFiY2RlZmcJZ2l2ZW5uMjE=", "s3/documents/=32byteslongsecreabcdefg givenn21", nil, true}, - //success scenario the key contains non printable (tab character) as key + // success scenario the key contains non printable (tab character) as key {"s3/documents/=MzJieXRlc2xvbmdzZWNyZWFiY2RlZmcJZ2l2ZW5uMjE=,play/documents/=MzJieXRlc2xvbmdzZWNyZXRrZQltdXN0YmVnaXZlbjE=", "s3/documents/=32byteslongsecreabcdefg givenn21,play/documents/=32byteslongsecretke mustbegiven1", nil, true}, // success scenario using a normal string {"s3/documents/=32byteslongsecretkeymustbegiven1", "s3/documents/=32byteslongsecretkeymustbegiven1", nil, true}, diff --git a/cmd/config-migrate.go b/cmd/config-migrate.go index a7a88c4d..fd747f32 100644 --- a/cmd/config-migrate.go +++ b/cmd/config-migrate.go @@ -234,7 +234,6 @@ func migrateConfigV3ToV4() { fatalIf(probe.NewError(e), "Unable to save config version `4`.") console.Infof("Successfully migrated %s from version `3` to version `4`.\n", mustGetMcConfigPath()) - } // Migrate config version `4` to `5`. Rename hostConfigV4.Signature -> hostConfigV5.API. diff --git a/cmd/config-old.go b/cmd/config-old.go index d6e7717b..7d1db82d 100644 --- a/cmd/config-old.go +++ b/cmd/config-old.go @@ -250,6 +250,7 @@ type hostConfigV8 struct { SecretKey string `json:"secretKey"` API string `json:"api"` } + type configV8 struct { Version string `json:"version"` Hosts map[string]hostConfigV8 `json:"hosts"` diff --git a/cmd/config-validate.go b/cmd/config-validate.go index 5244c0d8..ec2c35d8 100644 --- a/cmd/config-validate.go +++ b/cmd/config-validate.go @@ -34,7 +34,7 @@ func validateConfigVersion(config *configV10) (bool, string) { // Verifies the config file of the MinIO Client func validateConfigFile(config *configV10) (bool, []string) { ok, err := validateConfigVersion(config) - var validationSuccessful = true + validationSuccessful := true var errors []string if !ok { validationSuccessful = false @@ -52,7 +52,7 @@ func validateConfigFile(config *configV10) (bool, []string) { } func validateConfigHost(host aliasConfigV10) (bool, []string) { - var validationSuccessful = true + validationSuccessful := true var hostErrors []string if !isValidAPI(strings.ToLower(host.API)) { validationSuccessful = false diff --git a/cmd/config.go b/cmd/config.go index 4cddf71e..3eb7a0c0 100644 --- a/cmd/config.go +++ b/cmd/config.go @@ -82,7 +82,7 @@ func createMcConfigDir() *probe.Error { if err != nil { return err.Trace() } - if e := os.MkdirAll(p, 0700); e != nil { + if e := os.MkdirAll(p, 0o700); e != nil { return probe.NewError(e) } return nil diff --git a/cmd/cp-main.go b/cmd/cp-main.go index 9e3b2e02..2d9b91fb 100644 --- a/cmd/cp-main.go +++ b/cmd/cp-main.go @@ -105,9 +105,11 @@ var ( } ) -var rmFlag = "retention-mode" -var rdFlag = "retention-duration" -var lhFlag = "legal-hold" +var ( + rmFlag = "retention-mode" + rdFlag = "retention-duration" + lhFlag = "legal-hold" +) // ErrInvalidMetadata reflects invalid metadata format var ErrInvalidMetadata = errors.New("specified metadata should be of form key1=value1;key2=value2;... and so on") @@ -328,7 +330,7 @@ func doPrepareCopyURLs(ctx context.Context, session *sessionV8, cancelCopy conte break } - var jsoniter = jsoniter.ConfigCompatibleWithStandardLibrary + jsoniter := jsoniter.ConfigCompatibleWithStandardLibrary jsonData, e := jsoniter.Marshal(cpURLs) if e != nil { session.Delete() @@ -363,7 +365,7 @@ func doCopySession(ctx context.Context, cancelCopy context.CancelFunc, cli *cli. var isCopied func(string) bool var totalObjects, totalBytes int64 - var cpURLsCh = make(chan URLs, 10000) + cpURLsCh := make(chan URLs, 10000) // Store a progress bar or an accounter var pg ProgressReader @@ -401,7 +403,7 @@ func doCopySession(ctx context.Context, cancelCopy context.CancelFunc, cli *cli. pg.SetTotal(totalBytes) go func() { - var jsoniter = jsoniter.ConfigCompatibleWithStandardLibrary + jsoniter := jsoniter.ConfigCompatibleWithStandardLibrary // Prepare URL scanner from session data file. urlScanner := bufio.NewScanner(session.NewDataReader()) for { @@ -457,8 +459,8 @@ func doCopySession(ctx context.Context, cancelCopy context.CancelFunc, cli *cli. }() } - var quitCh = make(chan struct{}) - var statusCh = make(chan URLs) + quitCh := make(chan struct{}) + statusCh := make(chan URLs) parallel := newParallelManager(statusCh) diff --git a/cmd/cp-main_contrib.go b/cmd/cp-main_contrib.go index bac22b70..8a1b4ecb 100644 --- a/cmd/cp-main_contrib.go +++ b/cmd/cp-main_contrib.go @@ -64,7 +64,7 @@ func getMetaDataEntry(metadataString string) (map[string]string, *probe.Error) { for ; ; p++ { ch, _, err := r.ReadRune() if err != nil { - //eof + // eof if ps == QSTRING || ps == DQSTRING || pt == KEY { return nil, probe.NewError(ErrInvalidMetadata) } diff --git a/cmd/cp-main_test.go b/cmd/cp-main_test.go index 6d132a54..b6c923f3 100644 --- a/cmd/cp-main_test.go +++ b/cmd/cp-main_test.go @@ -39,17 +39,17 @@ func TestParseMetaData(t *testing.T) { {"key1:value1;key2:value2", nil, ErrInvalidMetadata, false}, // using no delimiter {"key1:value1:key2:value2", nil, ErrInvalidMetadata, false}, - //success: use value in quotes + // success: use value in quotes {"Content-Disposition='form-data; name=\"description\"'", map[string]string{"Content-Disposition": "form-data; name=\"description\""}, nil, true}, - //success: use value in double quotes + // success: use value in double quotes {"Content-Disposition=\"form-data; name='description'\"", map[string]string{"Content-Disposition": "form-data; name='description'"}, nil, true}, - //fail: unterminated quote + // fail: unterminated quote {"Content-Disposition='form-data; name=\"description\"", nil, ErrInvalidMetadata, false}, - //fail: unterminated double quote + // fail: unterminated double quote {"Content-Disposition=\"form-data; name='description'", nil, ErrInvalidMetadata, false}, - //success: use value and key in quotes + // success: use value and key in quotes {"\"Content-Disposition\"='form-data; name=\"description\"'", map[string]string{"Content-Disposition": "form-data; name=\"description\""}, nil, true}, - //success: use value and key in quotes + // success: use value and key in quotes {"\"Content=Disposition;Other key part=this is also key data\"='form-data; name=\"description\"'", map[string]string{"Content=Disposition;Other key part=this is also key data": "form-data; name=\"description\""}, nil, true}, } diff --git a/cmd/cp-url-syntax.go b/cmd/cp-url-syntax.go index 08c7a0be..484e9683 100644 --- a/cmd/cp-url-syntax.go +++ b/cmd/cp-url-syntax.go @@ -197,7 +197,6 @@ func checkCopySyntaxTypeC(ctx context.Context, srcURLs []string, tgtURL string, } } } - } // checkCopySyntaxTypeD verifies if the source is a valid list of files and target is a valid folder. diff --git a/cmd/diff-main.go b/cmd/diff-main.go index 5ea01e72..923ff6c5 100644 --- a/cmd/diff-main.go +++ b/cmd/diff-main.go @@ -103,7 +103,6 @@ func (d diffMessage) String() string { "Unhandled difference between `"+d.FirstURL+"` and `"+d.SecondURL+"`.") } return msg - } // JSON jsonified diff message diff --git a/cmd/difference.go b/cmd/difference.go index 2ca4f968..4e46a76c 100644 --- a/cmd/difference.go +++ b/cmd/difference.go @@ -176,9 +176,7 @@ func differenceInternal(ctx context.Context, sourceClnt, targetClnt Client, sour srcCtnt, srcOk := <-srcCh tgtCtnt, tgtOk := <-tgtCh - var ( - srcEOF, tgtEOF bool - ) + var srcEOF, tgtEOF bool for { srcEOF = !srcOk diff --git a/cmd/event-add.go b/cmd/event-add.go index 512a742d..38be734e 100644 --- a/cmd/event-add.go +++ b/cmd/event-add.go @@ -28,27 +28,25 @@ import ( "github.com/minio/pkg/console" ) -var ( - eventAddFlags = []cli.Flag{ - cli.StringFlag{ - Name: "event", - Value: "put,delete,get", - Usage: "filter specific type of event. Defaults to all event", - }, - cli.StringFlag{ - Name: "prefix", - Usage: "filter event associated to the specified prefix", - }, - cli.StringFlag{ - Name: "suffix", - Usage: "filter event associated to the specified suffix", - }, - cli.BoolFlag{ - Name: "ignore-existing, p", - Usage: "ignore if event already exists", - }, - } -) +var eventAddFlags = []cli.Flag{ + cli.StringFlag{ + Name: "event", + Value: "put,delete,get", + Usage: "filter specific type of event. Defaults to all event", + }, + cli.StringFlag{ + Name: "prefix", + Usage: "filter event associated to the specified prefix", + }, + cli.StringFlag{ + Name: "suffix", + Usage: "filter event associated to the specified suffix", + }, + cli.BoolFlag{ + Name: "ignore-existing, p", + Usage: "ignore if event already exists", + }, +} var eventAddCmd = cli.Command{ Name: "add", diff --git a/cmd/event-list.go b/cmd/event-list.go index 60a97871..2ce83ec7 100644 --- a/cmd/event-list.go +++ b/cmd/event-list.go @@ -28,9 +28,7 @@ import ( "github.com/minio/pkg/console" ) -var ( - eventListFlags = []cli.Flag{} -) +var eventListFlags = []cli.Flag{} var eventListCmd = cli.Command{ Name: "list", @@ -135,7 +133,8 @@ func mainEventList(cliCtx *cli.Context) error { Prefix: config.Prefix, Suffix: config.Suffix, Arn: config.Arn, - ID: config.ID}) + ID: config.ID, + }) } return nil diff --git a/cmd/event-main.go b/cmd/event-main.go index bf019c0a..546e460e 100644 --- a/cmd/event-main.go +++ b/cmd/event-main.go @@ -19,9 +19,7 @@ package cmd import "github.com/minio/cli" -var ( - eventFlags = []cli.Flag{} -) +var eventFlags = []cli.Flag{} var eventSubcommands = []cli.Command{ eventAddCmd, diff --git a/cmd/event-remove.go b/cmd/event-remove.go index 5900f659..1a4b1483 100644 --- a/cmd/event-remove.go +++ b/cmd/event-remove.go @@ -28,27 +28,25 @@ import ( "github.com/minio/pkg/console" ) -var ( - eventRemoveFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "force", - Usage: "force removing all bucket notifications", - }, - cli.StringFlag{ - Name: "event", - Value: "put,delete,get", - Usage: "filter specific type of event. Defaults to all event", - }, - cli.StringFlag{ - Name: "prefix", - Usage: "filter event associated to the specified prefix", - }, - cli.StringFlag{ - Name: "suffix", - Usage: "filter event associated to the specified suffix", - }, - } -) +var eventRemoveFlags = []cli.Flag{ + cli.BoolFlag{ + Name: "force", + Usage: "force removing all bucket notifications", + }, + cli.StringFlag{ + Name: "event", + Value: "put,delete,get", + Usage: "filter specific type of event. Defaults to all event", + }, + cli.StringFlag{ + Name: "prefix", + Usage: "filter event associated to the specified prefix", + }, + cli.StringFlag{ + Name: "suffix", + Usage: "filter event associated to the specified suffix", + }, +} var eventRemoveCmd = cli.Command{ Name: "remove", diff --git a/cmd/find_test.go b/cmd/find_test.go index eaf2ea54..9aaa7800 100644 --- a/cmd/find_test.go +++ b/cmd/find_test.go @@ -31,7 +31,7 @@ import ( func TestMatchFind(t *testing.T) { // List of various contexts used in each tests, // tests are run in the same order as this list. - var listFindContexts = []*findContext{ + listFindContexts := []*findContext{ { clnt: &S3Client{ targetURL: &ClientURL{}, @@ -93,7 +93,7 @@ func TestMatchFind(t *testing.T) { }, } - var testCases = []struct { + testCases := []struct { content contentMessage expectedMatch bool }{ @@ -178,7 +178,7 @@ func TestMatchFind(t *testing.T) { // Tests suffix strings trimmed off correctly at maxdepth. func TestSuffixTrimmingAtMaxDepth(t *testing.T) { - var testCases = []struct { + testCases := []struct { startPrefix string path string separator string @@ -268,7 +268,7 @@ func TestFindMatch(t *testing.T) { match bool } - var basicTests = []testFind{ + basicTests := []testFind{ // Name match tests - success cases. {"*.jpg", "carter.jpg", "name", true}, {"console", "pkg/console/console.go", "name", true}, @@ -285,8 +285,10 @@ func TestFindMatch(t *testing.T) { {"*test/*", "bob/likes/test/cake", "name", false}, {"*/test/*", "bob/likes/cake/test", "name", false}, {"*.jpg", ".jpg/elves/are/evil", "name", false}, - {"wq3YgNiB2ILYg9iE2IXYnNud3I/hoI7igIvigIzigI3igI7igI/igKrigKvigKzigK3igK7igaDi", - "An/Even/Bigger/String/wq3YgNiB2ILYg9iE2IXYnNud3I/hoI7igIvigIzigI3igI7igI/igKrigKvigKzigK3igK7igaDi", "name", false}, + { + "wq3YgNiB2ILYg9iE2IXYnNud3I/hoI7igIvigIzigI3igI7igI/igKrigKvigKzigK3igK7igaDi", + "An/Even/Bigger/String/wq3YgNiB2ILYg9iE2IXYnNud3I/hoI7igIvigIzigI3igI7igI/igKrigKvigKzigK3igK7igaDi", "name", false, + }, {"𝕿𝖍𝖊", "well/this/isAN/odd/font/THE", "name", false}, {"𝕿𝖍𝖊", "well/this/isAN/odd/font/The", "name", false}, {"𝕿𝖍𝖊", "well/this/isAN/odd/font/𝓣𝓱𝓮", "name", false}, diff --git a/cmd/head-main.go b/cmd/head-main.go index 76287dfc..581d1f32 100644 --- a/cmd/head-main.go +++ b/cmd/head-main.go @@ -33,23 +33,21 @@ import ( "github.com/minio/mc/pkg/probe" ) -var ( - headFlags = []cli.Flag{ - cli.Int64Flag{ - Name: "n,lines", - Usage: "print the first 'n' lines", - Value: 10, - }, - cli.StringFlag{ - Name: "rewind", - Usage: "select an object version at specified time", - }, - cli.StringFlag{ - Name: "version-id, vid", - Usage: "select an object version to display", - }, - } -) +var headFlags = []cli.Flag{ + cli.Int64Flag{ + Name: "n,lines", + Usage: "print the first 'n' lines", + Value: 10, + }, + cli.StringFlag{ + Name: "rewind", + Usage: "select an object version at specified time", + }, + cli.StringFlag{ + Name: "version-id, vid", + Usage: "select an object version to display", + }, +} // Display contents of a file. var headCmd = cli.Command{ diff --git a/cmd/ilm-import.go b/cmd/ilm-import.go index 1bf0bade..369332e2 100644 --- a/cmd/ilm-import.go +++ b/cmd/ilm-import.go @@ -71,7 +71,7 @@ func (i ilmImportMessage) JSON() string { // readILMConfig read from stdin, returns XML. func readILMConfig() (*lifecycle.Configuration, *probe.Error) { // User is expected to enter the lifecycleConfiguration instance contents in JSON format - var cfg = lifecycle.NewConfiguration() + cfg := lifecycle.NewConfiguration() // Consume json from STDIN dec := json.NewDecoder(os.Stdin) diff --git a/cmd/ilm-ls.go b/cmd/ilm-ls.go index f5a689b5..3d830b9b 100644 --- a/cmd/ilm-ls.go +++ b/cmd/ilm-ls.go @@ -151,7 +151,7 @@ func (i ilmListMessage) JSON() string { // validateILMListFlagSet - Only one of these flags needs to be set for display: --json, --expiry, --transition func validateILMListFlagSet(ctx *cli.Context) bool { - var flags = [...]bool{ctx.Bool("expiry"), ctx.Bool("transition"), ctx.Bool("json")} + flags := [...]bool{ctx.Bool("expiry"), ctx.Bool("transition"), ctx.Bool("json")} found := false for _, flag := range flags { if found && flag { diff --git a/cmd/ilm-restore.go b/cmd/ilm-restore.go index de6fc41c..a849fe6b 100644 --- a/cmd/ilm-restore.go +++ b/cmd/ilm-restore.go @@ -311,10 +311,10 @@ func mainILMRestore(cliCtx *cli.Context) (cErr error) { fatalIf(errDummy().Trace(), "Unable to restore the given URL") } - var restoreReqStatus = make(chan *probe.Error) - var restoreStatus = make(chan *probe.Error) + restoreReqStatus := make(chan *probe.Error) + restoreStatus := make(chan *probe.Error) - var done = make(chan struct{}) + done := make(chan struct{}) go func() { showRestoreStatus(restoreReqStatus, restoreStatus, done) diff --git a/cmd/ilm/tabular_info.go b/cmd/ilm/tabular_info.go index 7f409b50..bba7f471 100644 --- a/cmd/ilm/tabular_info.go +++ b/cmd/ilm/tabular_info.go @@ -104,8 +104,8 @@ type showDetails struct { // table with information. Table is constructed row-by-row. Headers are first, then the rest of the rows. func PopulateILMDataForDisplay(ilmCfg *lifecycle.Configuration, rowCheck *map[string]int, alignedHdrLabels *[]string, cellDataNoTags *[][]string, cellDataWithTags *[][]string, tagRows *map[string][]string, - showAll, showExpiry, showTransition bool) { - + showAll, showExpiry, showTransition bool, +) { // We need the different column headers and their respective column index // where they appear in a map data-structure format. // [Column Label] -> [Column Number] @@ -412,7 +412,6 @@ func showExpiryDetails(rule lifecycle.Rule, showOpts showDetails) bool { expirySet := !rule.Expiration.IsNull() return (expirySet && (showOpts.allAvailable || showOpts.expiry)) - } func showExpTick(showOpts showDetails) bool { diff --git a/cmd/legalhold-clear.go b/cmd/legalhold-clear.go index 25c7e6be..160ae30f 100644 --- a/cmd/legalhold-clear.go +++ b/cmd/legalhold-clear.go @@ -27,26 +27,24 @@ import ( "github.com/minio/pkg/console" ) -var ( - lhClearFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "recursive, r", - Usage: "clear legal hold recursively", - }, - cli.StringFlag{ - Name: "version-id, vid", - Usage: "clear legal hold of a specific object version", - }, - cli.StringFlag{ - Name: "rewind", - Usage: "clear legal hold on an object version at specified time", - }, - cli.BoolFlag{ - Name: "versions", - Usage: "clear legal hold on multiple versions of object(s)", - }, - } -) +var lhClearFlags = []cli.Flag{ + cli.BoolFlag{ + Name: "recursive, r", + Usage: "clear legal hold recursively", + }, + cli.StringFlag{ + Name: "version-id, vid", + Usage: "clear legal hold of a specific object version", + }, + cli.StringFlag{ + Name: "rewind", + Usage: "clear legal hold on an object version at specified time", + }, + cli.BoolFlag{ + Name: "versions", + Usage: "clear legal hold on multiple versions of object(s)", + }, +} var legalHoldClearCmd = cli.Command{ Name: "clear", diff --git a/cmd/legalhold-info.go b/cmd/legalhold-info.go index 0a2707d9..9bc9ae83 100644 --- a/cmd/legalhold-info.go +++ b/cmd/legalhold-info.go @@ -32,26 +32,25 @@ import ( "github.com/minio/pkg/console" ) -var ( - lhInfoFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "recursive, r", - Usage: "show legal hold status recursively", - }, - cli.StringFlag{ - Name: "version-id, vid", - Usage: "show legal hold status of a specific object version", - }, - cli.StringFlag{ - Name: "rewind", - Usage: "show legal hold status of an object version at specified time", - }, - cli.BoolFlag{ - Name: "versions", - Usage: "show legal hold status of multiple versions of object(s)", - }, - } -) +var lhInfoFlags = []cli.Flag{ + cli.BoolFlag{ + Name: "recursive, r", + Usage: "show legal hold status recursively", + }, + cli.StringFlag{ + Name: "version-id, vid", + Usage: "show legal hold status of a specific object version", + }, + cli.StringFlag{ + Name: "rewind", + Usage: "show legal hold status of an object version at specified time", + }, + cli.BoolFlag{ + Name: "versions", + Usage: "show legal hold status of multiple versions of object(s)", + }, +} + var legalHoldInfoCmd = cli.Command{ Name: "info", Usage: "show legal hold info for object(s)", diff --git a/cmd/legalhold-main.go b/cmd/legalhold-main.go index 9ef84305..e07fac18 100644 --- a/cmd/legalhold-main.go +++ b/cmd/legalhold-main.go @@ -80,8 +80,10 @@ func (l legalHoldCmdMessage) JSON() string { return string(msgBytes) } -var errBucketLockConfigNotFound = errors.New("bucket lock config not found") -var errBucketLockNotSupported = errors.New("bucket lock not supported") +var ( + errBucketLockConfigNotFound = errors.New("bucket lock config not found") + errBucketLockNotSupported = errors.New("bucket lock not supported") +) func isBucketLockEnabled(ctx context.Context, aliasedURL string) (bool, *probe.Error) { st, err := getBucketLockStatus(ctx, aliasedURL) diff --git a/cmd/legalhold-set.go b/cmd/legalhold-set.go index f791a736..cc906e02 100644 --- a/cmd/legalhold-set.go +++ b/cmd/legalhold-set.go @@ -30,26 +30,25 @@ import ( "github.com/minio/pkg/console" ) -var ( - lhSetFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "recursive, r", - Usage: "apply legal hold recursively", - }, - cli.StringFlag{ - Name: "version-id, vid", - Usage: "apply legal hold to a specific object version", - }, - cli.StringFlag{ - Name: "rewind", - Usage: "apply legal hold on an object version at specified time", - }, - cli.BoolFlag{ - Name: "versions", - Usage: "apply legal hold on multiple versions of an object", - }, - } -) +var lhSetFlags = []cli.Flag{ + cli.BoolFlag{ + Name: "recursive, r", + Usage: "apply legal hold recursively", + }, + cli.StringFlag{ + Name: "version-id, vid", + Usage: "apply legal hold to a specific object version", + }, + cli.StringFlag{ + Name: "rewind", + Usage: "apply legal hold on an object version at specified time", + }, + cli.BoolFlag{ + Name: "versions", + Usage: "apply legal hold on multiple versions of an object", + }, +} + var legalHoldSetCmd = cli.Command{ Name: "set", Usage: "set legal hold for object(s)", @@ -84,7 +83,6 @@ EXAMPLES: // setLegalHold - Set legalhold for all objects within a given prefix. func setLegalHold(ctx context.Context, urlStr, versionID string, timeRef time.Time, withOlderVersions, recursive bool, lhold minio.LegalHoldStatus) error { - clnt, err := newClient(urlStr) if err != nil { fatalIf(err.Trace(), "Unable to parse the provided url.") diff --git a/cmd/ls.go b/cmd/ls.go index 266102ef..d3abec2d 100644 --- a/cmd/ls.go +++ b/cmd/ls.go @@ -196,7 +196,6 @@ func printObjectVersions(clntURL ClientURL, ctntVersions []*ClientContent, print // doList - list all entities inside a folder. func doList(ctx context.Context, clnt Client, isRecursive, isIncomplete, isSummary bool, timeRef time.Time, withOlderVersions bool) error { - var ( lastPath string perObjectVersions []*ClientContent diff --git a/cmd/main.go b/cmd/main.go index 1d74ed46..5e70a394 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -45,15 +45,13 @@ import ( completeinstall "github.com/posener/complete/cmd/install" ) -var ( - // global flags for mc. - mcFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "autocompletion", - Usage: "install auto-completion for your shell", - }, - } -) +// global flags for mc. +var mcFlags = []cli.Flag{ + cli.BoolFlag{ + Name: "autocompletion", + Usage: "install auto-completion for your shell", + }, +} // Help template for mc var mcHelpTemplate = `NAME: @@ -96,7 +94,6 @@ func init() { // Main starts mc application func Main(args []string) { - if len(args) > 1 { switch args[1] { case "mc", filepath.Base(args[0]): @@ -153,7 +150,7 @@ func onUsageError(ctx *cli.Context, err error, subcommand bool) error { // Calculate the maximum width of the flag name field // for a good looking printing - var help = make([]subCommandHelp, len(ctx.Command.Flags)) + help := make([]subCommandHelp, len(ctx.Command.Flags)) maxWidth := 0 for i, f := range ctx.Command.Flags { s := strings.Split(f.String(), "\t") @@ -187,7 +184,7 @@ func commandNotFound(ctx *cli.Context, cmds []cli.Command) { return } msg := fmt.Sprintf("`%s` is not a recognized command. Get help using `--help` flag.", command) - var commandsTree = trie.NewTrie() + commandsTree := trie.NewTrie() for _, cmd := range cmds { commandsTree.Insert(cmd.Name) } @@ -300,7 +297,6 @@ func initMC() { // Load all authority certificates present in CAs dir loadRootCAs() - } func installAutoCompletion() { diff --git a/cmd/mb-main.go b/cmd/mb-main.go index 8467eb33..1a70deb9 100644 --- a/cmd/mb-main.go +++ b/cmd/mb-main.go @@ -27,23 +27,21 @@ import ( "github.com/minio/pkg/console" ) -var ( - mbFlags = []cli.Flag{ - cli.StringFlag{ - Name: "region", - Value: "us-east-1", - Usage: "specify bucket region; defaults to 'us-east-1'", - }, - cli.BoolFlag{ - Name: "ignore-existing, p", - Usage: "ignore if bucket/directory already exists", - }, - cli.BoolFlag{ - Name: "with-lock, l", - Usage: "enable object lock", - }, - } -) +var mbFlags = []cli.Flag{ + cli.StringFlag{ + Name: "region", + Value: "us-east-1", + Usage: "specify bucket region; defaults to 'us-east-1'", + }, + cli.BoolFlag{ + Name: "ignore-existing, p", + Usage: "ignore if bucket/directory already exists", + }, + cli.BoolFlag{ + Name: "with-lock, l", + Usage: "enable object lock", + }, +} // make a bucket. var mbCmd = cli.Command{ @@ -115,7 +113,6 @@ func checkMakeBucketSyntax(cliCtx *cli.Context) { // mainMakeBucket is entry point for mb command. func mainMakeBucket(cli *cli.Context) error { - // check 'mb' cli arguments. checkMakeBucketSyntax(cli) diff --git a/cmd/mirror-main.go b/cmd/mirror-main.go index 670407a7..bba7a41e 100644 --- a/cmd/mirror-main.go +++ b/cmd/mirror-main.go @@ -313,7 +313,7 @@ func (mj *mirrorJob) doDeleteBucket(ctx context.Context, sURLs URLs) URLs { return sURLs.WithError(pErr) } - var contentCh = make(chan *ClientContent, 1) + contentCh := make(chan *ClientContent, 1) contentCh <- &ClientContent{URL: clnt.GetURL()} close(contentCh) @@ -407,7 +407,6 @@ func convertSizeToTag(size int64) string { // doMirror - Mirror an object to multiple destination. URLs status contains a copy of sURLs and error if any. func (mj *mirrorJob) doMirror(ctx context.Context, sURLs URLs) URLs { - if sURLs.Error != nil { // Erroneous sURLs passed. return sURLs.WithError(sURLs.Error.Trace()) } @@ -553,7 +552,7 @@ func (mj *mirrorJob) watchMirrorEvents(ctx context.Context, events []EventInfo) // build target path, it is the relative of the eventPath with the sourceUrl // joined to the targetURL. sourceSuffix := strings.TrimPrefix(eventPath, sourceURLFull) - //Skip the object, if it matches the Exclude options provided + // Skip the object, if it matches the Exclude options provided if matchExcludeOptions(mj.opts.excludeOptions, sourceSuffix) { continue } @@ -736,7 +735,6 @@ func (mj *mirrorJob) startMirror(ctx context.Context, cancelMirror context.Cance // when using a struct for copying, we could save a lot of passing of variables func (mj *mirrorJob) mirror(ctx context.Context, cancelMirror context.CancelFunc) bool { - var wg sync.WaitGroup // Starts watcher loop for watching for new events. @@ -1010,7 +1008,6 @@ func mainMirror(cliCtx *cli.Context) error { if e := http.ListenAndServe(prometheusAddress, nil); e != nil { fatalIf(probe.NewError(e), "Unable to setup monitoring endpoint.") } - }() } diff --git a/cmd/mirror-url.go b/cmd/mirror-url.go index 96c9fab6..30500186 100644 --- a/cmd/mirror-url.go +++ b/cmd/mirror-url.go @@ -76,7 +76,7 @@ func checkMirrorSyntax(ctx context.Context, cliCtx *cli.Context, encKeyDB map[st } if srcClient.Type == fileSystem && !filepath.IsAbs(srcURL) { - var origSrcURL = srcURL + origSrcURL := srcURL var e error // Changing relative path to absolute path, if it is a local directory. // Save original in case of error diff --git a/cmd/parallel-manager.go b/cmd/parallel-manager.go index df6a2dc7..88568f21 100644 --- a/cmd/parallel-manager.go +++ b/cmd/parallel-manager.go @@ -248,7 +248,6 @@ func availableMemory() (available uint64) { if available != 9223372036854771712 { // This means cgroup memory limit is configured. return - } // no-limit set proceed to set the limits based on virtual memory. } // for all other platforms limits are based on virtual memory. diff --git a/cmd/pipe-main.go b/cmd/pipe-main.go index fc9a8f25..f9b80df1 100644 --- a/cmd/pipe-main.go +++ b/cmd/pipe-main.go @@ -25,26 +25,24 @@ import ( "github.com/minio/mc/pkg/probe" ) -var ( - pipeFlags = []cli.Flag{ - cli.StringFlag{ - Name: "encrypt", - Usage: "encrypt objects (using server-side encryption with server managed keys)", - }, - cli.StringFlag{ - Name: "storage-class, sc", - Usage: "set storage class for new object(s) on target", - }, - cli.StringFlag{ - Name: "attr", - Usage: "add custom metadata for the object", - }, - cli.StringFlag{ - Name: "tags", - Usage: "apply one or more tags to the uploaded objects", - }, - } -) +var pipeFlags = []cli.Flag{ + cli.StringFlag{ + Name: "encrypt", + Usage: "encrypt objects (using server-side encryption with server managed keys)", + }, + cli.StringFlag{ + Name: "storage-class, sc", + Usage: "set storage class for new object(s) on target", + }, + cli.StringFlag{ + Name: "attr", + Usage: "add custom metadata for the object", + }, + cli.StringFlag{ + Name: "tags", + Usage: "apply one or more tags to the uploaded objects", + }, +} // Display contents of a file. var pipeCmd = cli.Command{ @@ -135,7 +133,7 @@ func mainPipe(ctx *cli.Context) error { // validate pipe input arguments. checkPipeSyntax(ctx) - var meta = map[string]string{} + meta := map[string]string{} if attr := ctx.String("attr"); attr != "" { meta, err = getMetaDataEntry(attr) fatalIf(err.Trace(attr), "Unable to parse --attr value") diff --git a/cmd/pipechan.go b/cmd/pipechan.go index 224d1ad5..fd48cdd9 100644 --- a/cmd/pipechan.go +++ b/cmd/pipechan.go @@ -36,7 +36,6 @@ import "github.com/rjeczalik/notify" // PipeChan builds a new dynamically sized channel func PipeChan(capacity int) (inputCh chan notify.EventInfo, outputCh chan notify.EventInfo) { - // A set of channels which store all elements received from input channels := make(chan chan notify.EventInfo, 1000) diff --git a/cmd/pipechan_test.go b/cmd/pipechan_test.go index 3eaff455..cdd32dd2 100644 --- a/cmd/pipechan_test.go +++ b/cmd/pipechan_test.go @@ -26,7 +26,6 @@ import ( ) func testPipeChan(inputCh, outputCh chan notify.EventInfo, totalMsgs int) error { - var wg sync.WaitGroup msgCtnt := notify.EventInfo(nil) diff --git a/cmd/policy-main.go b/cmd/policy-main.go index ecfc31f9..4374f2ec 100644 --- a/cmd/policy-main.go +++ b/cmd/policy-main.go @@ -29,14 +29,12 @@ import ( "github.com/minio/pkg/console" ) -var ( - policyFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "recursive, r", - Usage: "list recursively", - }, - } -) +var policyFlags = []cli.Flag{ + cli.BoolFlag{ + Name: "recursive, r", + Usage: "list recursively", + }, +} // Manage anonymous access to buckets and objects. var policyCmd = cli.Command{ diff --git a/cmd/pretty-record.go b/cmd/pretty-record.go index f09b3191..cc3e5e78 100644 --- a/cmd/pretty-record.go +++ b/cmd/pretty-record.go @@ -55,7 +55,6 @@ func newPrettyRecord(indent int, rows ...Row) PrettyRecord { // buildRecord - creates a string which represents a record table given // some fields contents. func (t PrettyRecord) buildRecord(contents ...string) (line string) { - // totalRows is the minimum of the number of fields config // and the number of contents elements. totalRows := len(contents) diff --git a/cmd/pretty-table_test.go b/cmd/pretty-table_test.go index f7f21f8a..8fbff16c 100644 --- a/cmd/pretty-table_test.go +++ b/cmd/pretty-table_test.go @@ -21,7 +21,6 @@ import "testing" // TestPrettyTable - testing the behavior of the pretty table module func TestPrettyTable(t *testing.T) { - testCases := []struct { sep string tf []Field diff --git a/cmd/progress-bar.go b/cmd/progress-bar.go index 1bf85471..e9254e69 100644 --- a/cmd/progress-bar.go +++ b/cmd/progress-bar.go @@ -173,7 +173,7 @@ func cursorAnimate() <-chan string { // cursors = "←↖↑↗→↘↓↙" // cursors = "◴◷◶◵" // cursors = "◰◳◲◱" - //cursors = "⣾⣽⣻⢿⡿⣟⣯⣷" + // cursors = "⣾⣽⣻⢿⡿⣟⣯⣷" case "darwin": cursors = "◐◓◑◒" default: diff --git a/cmd/rb-main.go b/cmd/rb-main.go index 9b846cba..8d9da866 100644 --- a/cmd/rb-main.go +++ b/cmd/rb-main.go @@ -32,18 +32,16 @@ import ( "github.com/minio/pkg/console" ) -var ( - rbFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "force", - Usage: "force a recursive remove operation on all object versions", - }, - cli.BoolFlag{ - Name: "dangerous", - Usage: "allow site-wide removal of objects", - }, - } -) +var rbFlags = []cli.Flag{ + cli.BoolFlag{ + Name: "force", + Usage: "force a recursive remove operation on all object versions", + }, + cli.BoolFlag{ + Name: "dangerous", + Usage: "allow site-wide removal of objects", + }, +} // remove a bucket. var rbCmd = cli.Command{ @@ -219,7 +217,7 @@ func deleteBucket(ctx context.Context, url string, isForce bool) *probe.Error { // is not qualified by bucket func isS3NamespaceRemoval(ctx context.Context, url string) bool { // clean path for aliases like s3/. - //Note: UNC path using / works properly in go 1.9.2 even though it breaks the UNC specification. + // Note: UNC path using / works properly in go 1.9.2 even though it breaks the UNC specification. url = filepath.ToSlash(filepath.Clean(url)) // namespace removal applies only for non FS. So filter out if passed url represents a directory _, path := url2Alias(url) diff --git a/cmd/replicate-import.go b/cmd/replicate-import.go index cc056e41..e0dde7a0 100644 --- a/cmd/replicate-import.go +++ b/cmd/replicate-import.go @@ -82,7 +82,7 @@ func (r replicateImportMessage) String() string { // readReplicationConfig read from stdin, returns XML. func readReplicationConfig() (*replication.Config, *probe.Error) { // User is expected to enter the replication configuration in JSON format - var cfg = replication.Config{} + cfg := replication.Config{} // Consume json from STDIN dec := json.NewDecoder(os.Stdin) diff --git a/cmd/replicate-ls.go b/cmd/replicate-ls.go index ee510672..9534b8cf 100644 --- a/cmd/replicate-ls.go +++ b/cmd/replicate-ls.go @@ -66,6 +66,7 @@ func checkReplicateListSyntax(ctx *cli.Context) { cli.ShowCommandHelpAndExit(ctx, "ls", 1) // last argument is exit code } } + func printReplicateListHeader() { if globalJSON { return diff --git a/cmd/replicate-reset.go b/cmd/replicate-reset.go index e373bd02..1b9e36d0 100644 --- a/cmd/replicate-reset.go +++ b/cmd/replicate-reset.go @@ -99,7 +99,6 @@ func (r replicateResetMessage) String() string { return console.Colorize("replicateResetMessage", fmt.Sprintf("Replication reset started for %s with ID %s", r.URL, r.ResyncTargetsInfo.Targets[0].ResetID)) } return console.Colorize("replicateResetMessage", fmt.Sprintf("Replication reset started for %s", r.URL)) - } func mainReplicateReset(cliCtx *cli.Context) error { diff --git a/cmd/replicate-status.go b/cmd/replicate-status.go index 0ed802b6..ab0b0a62 100644 --- a/cmd/replicate-status.go +++ b/cmd/replicate-status.go @@ -79,8 +79,8 @@ func (s replicateStatusMessage) String() string { var contents [][]string var rows string - var arntheme = []string{"Headers"} - var theme = []string{"Pending", "Failed", "Replicated", "Replica"} + arntheme := []string{"Headers"} + theme := []string{"Pending", "Failed", "Replicated", "Replica"} contents = append(contents, []string{"Pending", humanize.IBytes(s.ReplicationStatus.PendingSize), humanize.Comma(int64(s.ReplicationStatus.PendingCount))}) contents = append(contents, []string{"Failed", humanize.IBytes(s.ReplicationStatus.FailedSize), humanize.Comma(int64(s.ReplicationStatus.FailedCount))}) contents = append(contents, []string{"Replicated", humanize.IBytes(s.ReplicationStatus.ReplicatedSize), ""}) diff --git a/cmd/retention-clear.go b/cmd/retention-clear.go index 6c6a9706..49446b32 100644 --- a/cmd/retention-clear.go +++ b/cmd/retention-clear.go @@ -27,30 +27,28 @@ import ( "github.com/minio/pkg/console" ) -var ( - retentionClearFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "recursive, r", - Usage: "clear retention recursively", - }, - cli.StringFlag{ - Name: "version-id, vid", - Usage: "clear retention of a specific object version", - }, - cli.StringFlag{ - Name: "rewind", - Usage: "roll back object(s) to current version at specified time", - }, - cli.BoolFlag{ - Name: "versions", - Usage: "clear retention of object(s) and all its versions", - }, - cli.BoolFlag{ - Name: "default", - Usage: "set default bucket locking", - }, - } -) +var retentionClearFlags = []cli.Flag{ + cli.BoolFlag{ + Name: "recursive, r", + Usage: "clear retention recursively", + }, + cli.StringFlag{ + Name: "version-id, vid", + Usage: "clear retention of a specific object version", + }, + cli.StringFlag{ + Name: "rewind", + Usage: "roll back object(s) to current version at specified time", + }, + cli.BoolFlag{ + Name: "versions", + Usage: "clear retention of object(s) and all its versions", + }, + cli.BoolFlag{ + Name: "default", + Usage: "set default bucket locking", + }, +} var retentionClearCmd = cli.Command{ Name: "clear", diff --git a/cmd/retention-common.go b/cmd/retention-common.go index ddbe5b9e..28199878 100644 --- a/cmd/retention-common.go +++ b/cmd/retention-common.go @@ -208,7 +208,6 @@ func applyRetention(ctx context.Context, op lockOpType, target, versionID string timeStr, err := getRetainUntilDate(validity, unit) if err != nil { return err.ToGoError() - } var e error until, e = time.Parse(time.RFC3339, timeStr) diff --git a/cmd/retention-info.go b/cmd/retention-info.go index 2062a47b..ecc7140c 100644 --- a/cmd/retention-info.go +++ b/cmd/retention-info.go @@ -31,30 +31,28 @@ import ( "github.com/minio/pkg/console" ) -var ( - retentionInfoFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "recursive, r", - Usage: "show retention info recursively", - }, - cli.StringFlag{ - Name: "version-id, vid", - Usage: "show retention info of specific object version", - }, - cli.StringFlag{ - Name: "rewind", - Usage: "roll back object(s) to current version at specified time", - }, - cli.BoolFlag{ - Name: "versions", - Usage: "show retention info on object(s) and all its versions", - }, - cli.BoolFlag{ - Name: "default", - Usage: "show bucket default retention mode", - }, - } -) +var retentionInfoFlags = []cli.Flag{ + cli.BoolFlag{ + Name: "recursive, r", + Usage: "show retention info recursively", + }, + cli.StringFlag{ + Name: "version-id, vid", + Usage: "show retention info of specific object version", + }, + cli.StringFlag{ + Name: "rewind", + Usage: "roll back object(s) to current version at specified time", + }, + cli.BoolFlag{ + Name: "versions", + Usage: "show retention info on object(s) and all its versions", + }, + cli.BoolFlag{ + Name: "default", + Usage: "show bucket default retention mode", + }, +} var retentionInfoCmd = cli.Command{ Name: "info", @@ -88,7 +86,8 @@ EXAMPLES: 5. Show default lock retention configuration for a bucket $ {{.HelpName}} myminio/mybucket/ --default -`} +`, +} func parseInfoRetentionArgs(cliCtx *cli.Context) (target, versionID string, recursive bool, timeRef time.Time, withVersions, defaultMode bool) { args := cliCtx.Args() diff --git a/cmd/retention-set.go b/cmd/retention-set.go index 9a65f7bb..53a9d13c 100644 --- a/cmd/retention-set.go +++ b/cmd/retention-set.go @@ -29,34 +29,32 @@ import ( "github.com/minio/pkg/console" ) -var ( - retentionSetFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "recursive, r", - Usage: "apply retention recursively", - }, - cli.BoolFlag{ - Name: "bypass", - Usage: "bypass governance", - }, - cli.StringFlag{ - Name: "version-id, vid", - Usage: "apply retention to a specific object version", - }, - cli.StringFlag{ - Name: "rewind", - Usage: "roll back object(s) to current version at specified time", - }, - cli.BoolFlag{ - Name: "versions", - Usage: "apply retention object(s) and all its versions", - }, - cli.BoolFlag{ - Name: "default", - Usage: "set bucket default retention mode", - }, - } -) +var retentionSetFlags = []cli.Flag{ + cli.BoolFlag{ + Name: "recursive, r", + Usage: "apply retention recursively", + }, + cli.BoolFlag{ + Name: "bypass", + Usage: "bypass governance", + }, + cli.StringFlag{ + Name: "version-id, vid", + Usage: "apply retention to a specific object version", + }, + cli.StringFlag{ + Name: "rewind", + Usage: "roll back object(s) to current version at specified time", + }, + cli.BoolFlag{ + Name: "versions", + Usage: "apply retention object(s) and all its versions", + }, + cli.BoolFlag{ + Name: "default", + Usage: "set bucket default retention mode", + }, +} var retentionSetCmd = cli.Command{ Name: "set", @@ -92,7 +90,8 @@ EXAMPLES: 5. Set default lock retention configuration for a bucket $ {{.HelpName}} --default governance 30d myminio/mybucket/ -`} +`, +} func parseSetRetentionArgs(cliCtx *cli.Context) (target, versionID string, recursive bool, timeRef time.Time, withVersions bool, mode minio.RetentionMode, validity uint64, unit minio.ValidityUnit, bypass, bucketMode bool) { args := cliCtx.Args() diff --git a/cmd/rm-main.go b/cmd/rm-main.go index 1c5ecef3..f3633c6e 100644 --- a/cmd/rm-main.go +++ b/cmd/rm-main.go @@ -252,7 +252,6 @@ func checkRmSyntax(ctx context.Context, cliCtx *cli.Context, encKeyDB map[string fatalIf(errDummy().Trace(), "This operation results in site-wide removal of objects. If you are really sure, retry this command with ‘--dangerous’ and ‘--force’ flags.") } - } // Remove a single object or a single version in a versioned bucket diff --git a/cmd/session-v8.go b/cmd/session-v8.go index e3139699..50b1882a 100644 --- a/cmd/session-v8.go +++ b/cmd/session-v8.go @@ -262,7 +262,7 @@ func (s *sessionV8) isModified(sessionFile string) (bool, *probe.Error) { return false, probe.NewError(e).Trace(s.SessionID) } - var currentHeader = &sessionV8Header{} + currentHeader := &sessionV8Header{} currentQS, e := quick.LoadConfig(sessionFile, nil, currentHeader) if e != nil { // If session does not exist for the first, return modified to diff --git a/cmd/session.go b/cmd/session.go index 0f07d251..95598cc2 100644 --- a/cmd/session.go +++ b/cmd/session.go @@ -46,7 +46,7 @@ func createSessionDir() *probe.Error { return err.Trace() } - if e := os.MkdirAll(sessionDir, 0700); e != nil { + if e := os.MkdirAll(sessionDir, 0o700); e != nil { return probe.NewError(e) } return nil diff --git a/cmd/share-download-main.go b/cmd/share-download-main.go index 171c55a5..2a25bd04 100644 --- a/cmd/share-download-main.go +++ b/cmd/share-download-main.go @@ -26,19 +26,17 @@ import ( "github.com/minio/mc/pkg/probe" ) -var ( - shareDownloadFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "recursive, r", - Usage: "share all objects recursively", - }, - cli.StringFlag{ - Name: "version-id, vid", - Usage: "share a particular object version", - }, - shareFlagExpire, - } -) +var shareDownloadFlags = []cli.Flag{ + cli.BoolFlag{ + Name: "recursive, r", + Usage: "share all objects recursively", + }, + cli.StringFlag{ + Name: "version-id, vid", + Usage: "share a particular object version", + }, + shareFlagExpire, +} // Share documents via URL. var shareDownload = cli.Command{ diff --git a/cmd/share-list-main.go b/cmd/share-list-main.go index be01d5cc..d2007548 100644 --- a/cmd/share-list-main.go +++ b/cmd/share-list-main.go @@ -25,9 +25,7 @@ import ( "github.com/minio/mc/pkg/probe" ) -var ( - shareListFlags = []cli.Flag{} -) +var shareListFlags = []cli.Flag{} // Share documents via URL. var shareList = cli.Command{ @@ -105,7 +103,6 @@ func doShareList(cmd string) *probe.Error { // main entry point for share list. func mainShareList(ctx *cli.Context) error { - // validate command-line args. checkShareListSyntax(ctx) diff --git a/cmd/share-main.go b/cmd/share-main.go index 2c64aab3..489d17b7 100644 --- a/cmd/share-main.go +++ b/cmd/share-main.go @@ -26,9 +26,7 @@ import ( "github.com/minio/pkg/console" ) -var ( - shareFlags = []cli.Flag{} -) +var shareFlags = []cli.Flag{} var shareSubcommands = []cli.Command{ shareDownload, diff --git a/cmd/share-upload-main.go b/cmd/share-upload-main.go index 37b990c9..9799751d 100644 --- a/cmd/share-upload-main.go +++ b/cmd/share-upload-main.go @@ -27,16 +27,14 @@ import ( "github.com/minio/mc/pkg/probe" ) -var ( - shareUploadFlags = []cli.Flag{ - cli.BoolFlag{ - Name: "recursive, r", - Usage: "recursively upload any object matching the prefix", - }, - shareFlagExpire, - shareFlagContentType, - } -) +var shareUploadFlags = []cli.Flag{ + cli.BoolFlag{ + Name: "recursive, r", + Usage: "recursively upload any object matching the prefix", + }, + shareFlagExpire, + shareFlagContentType, +} // Share documents via URL. var shareUpload = cli.Command{ diff --git a/cmd/share.go b/cmd/share.go index 7acf4181..a0a2acd8 100644 --- a/cmd/share.go +++ b/cmd/share.go @@ -131,7 +131,7 @@ func isShareDirExists() bool { // Create config share dir. func createShareDir() *probe.Error { - if e := os.MkdirAll(mustGetShareDir(), 0700); e != nil { + if e := os.MkdirAll(mustGetShareDir(), 0o700); e != nil { return probe.NewError(e) } return nil diff --git a/cmd/sql-main.go b/cmd/sql-main.go index b79953b2..3357f62c 100644 --- a/cmd/sql-main.go +++ b/cmd/sql-main.go @@ -38,43 +38,41 @@ import ( "github.com/minio/pkg/mimedb" ) -var ( - sqlFlags = []cli.Flag{ - cli.StringFlag{ - Name: "query, e", - Usage: "sql query expression", - Value: "select * from s3object", - }, - cli.BoolFlag{ - Name: "recursive, r", - Usage: "sql query recursively", - }, - cli.StringFlag{ - Name: "csv-input", - Usage: "csv input serialization option", - }, - cli.StringFlag{ - Name: "json-input", - Usage: "json input serialization option", - }, - cli.StringFlag{ - Name: "compression", - Usage: "input compression type", - }, - cli.StringFlag{ - Name: "csv-output", - Usage: "csv output serialization option", - }, - cli.StringFlag{ - Name: "csv-output-header", - Usage: "optional csv output header ", - }, - cli.StringFlag{ - Name: "json-output", - Usage: "json output serialization option", - }, - } -) +var sqlFlags = []cli.Flag{ + cli.StringFlag{ + Name: "query, e", + Usage: "sql query expression", + Value: "select * from s3object", + }, + cli.BoolFlag{ + Name: "recursive, r", + Usage: "sql query recursively", + }, + cli.StringFlag{ + Name: "csv-input", + Usage: "csv input serialization option", + }, + cli.StringFlag{ + Name: "json-input", + Usage: "json input serialization option", + }, + cli.StringFlag{ + Name: "compression", + Usage: "input compression type", + }, + cli.StringFlag{ + Name: "csv-output", + Usage: "csv output serialization option", + }, + cli.StringFlag{ + Name: "csv-output-header", + Usage: "optional csv output header ", + }, + cli.StringFlag{ + Name: "json-output", + Usage: "json output serialization option", + }, +} // Display contents of a file. var sqlCmd = cli.Command{ @@ -174,7 +172,7 @@ func parseKVArgs(is string) (map[string]string, *probe.Error) { e++ } } - var vEnd = len(is) + vEnd := len(is) if e != -1 { vEnd = s + e } diff --git a/cmd/sql-main_test.go b/cmd/sql-main_test.go index 2a66852a..424d4a5a 100644 --- a/cmd/sql-main_test.go +++ b/cmd/sql-main_test.go @@ -61,55 +61,64 @@ var testParseSerializationCases = []struct { parsedOpts map[string]string errMsg string }{ - {"rd=\n,fd=;,qc=\"", + { + "rd=\n,fd=;,qc=\"", append(validCSVCommonKeys, validCSVInputKeys...), validCSVInputAbbrKeys, map[string]string{"recorddelimiter": "\n", "fielddelimiter": ";", "quotechar": "\""}, "", }, - {"rd=\n,fd=;,qc=\"", + { + "rd=\n,fd=;,qc=\"", validCSVInputKeys, validCSVInputAbbrKeys, map[string]string{}, "Options should be key-value pairs in the form key=value,... where valid key(s) are ", }, - {"nokey=\n,fd=;,qc=\"", + { + "nokey=\n,fd=;,qc=\"", validCSVInputKeys, validCSVInputAbbrKeys, map[string]string{}, "Options should be key-value pairs in the form key=value,... where valid key(s) are ", }, - {"rd=\n\n,fd=|,qc=\",qc='", + { + "rd=\n\n,fd=|,qc=\",qc='", validCSVInputKeys, validCSVInputAbbrKeys, map[string]string{}, "More than one key=value found for ", }, - {"recordDelimiter=\n\n,FieldDelimiter=|,QuoteChAR=\"", + { + "recordDelimiter=\n\n,FieldDelimiter=|,QuoteChAR=\"", append(validCSVCommonKeys, validCSVInputKeys...), validCSVInputAbbrKeys, map[string]string{"recorddelimiter": "\n\n", "fielddelimiter": "|", "quotechar": "\""}, "", }, - {"recordDelimiter=\n\n,FieldDelimiter=|,QuoteChAR=\",fh=use,qrd=;", + { + "recordDelimiter=\n\n,FieldDelimiter=|,QuoteChAR=\",fh=use,qrd=;", append(validCSVCommonKeys, validCSVInputKeys...), validCSVInputAbbrKeys, map[string]string{"recorddelimiter": "\n\n", "fielddelimiter": "|", "quotechar": "\"", "quotedrecorddelimiter": ";", "fileheader": "use"}, "", }, - {"recordDelimiter=\n\n,FieldDelimiter=|,QuoteChar=\",qf=;,qec='", + { + "recordDelimiter=\n\n,FieldDelimiter=|,QuoteChar=\",qf=;,qec='", append(validCSVCommonKeys, validCSVOutputKeys...), validCSVOutputAbbrKeys, map[string]string{}, "Options should be key-value pairs in the form key=value,... where valid key(s) are ", }, - {"FieldDelimiter=|,QuoteChar=\",qf=;,qec='", + { + "FieldDelimiter=|,QuoteChar=\",qf=;,qec='", append(validCSVCommonKeys, validCSVOutputKeys...), validCSVOutputAbbrKeys, map[string]string{"fielddelimiter": "|", "quotechar": "\"", "quotefields": ";", "quoteescchar": "'"}, "", }, - {"type=lines", + { + "type=lines", validJSONInputKeys, nil, map[string]string{"type": "lines"}, @@ -118,7 +127,6 @@ var testParseSerializationCases = []struct { } func TestParseSerializationOpts(t *testing.T) { - for i, test := range testParseSerializationCases { optsMap, err := parseSerializationOpts(test.inp, test.validKeys, test.validAbbrKeys) gerr := err.ToGoError() diff --git a/cmd/stat-main.go b/cmd/stat-main.go index 5e9f2d83..389a4fbd 100644 --- a/cmd/stat-main.go +++ b/cmd/stat-main.go @@ -183,5 +183,4 @@ func mainStat(cliCtx *cli.Context) error { } return cErr - } diff --git a/cmd/stat.go b/cmd/stat.go index a30429e7..608d05b0 100644 --- a/cmd/stat.go +++ b/cmd/stat.go @@ -80,8 +80,8 @@ func (stat statMessage) String() (msg string) { msgBuilder.WriteString(fmt.Sprintf("%-10s: %s (lifecycle-rule-id: %s) ", "Expiration", stat.Expiration.Local().Format(printDate), stat.ExpirationRuleID) + "\n") } - var maxKeyMetadata = 0 - var maxKeyEncrypted = 0 + maxKeyMetadata := 0 + maxKeyEncrypted := 0 for k := range stat.Metadata { // Skip encryption headers, we print them later. if !strings.HasPrefix(strings.ToLower(k), serverEncryptionKeyPrefix) { @@ -330,7 +330,6 @@ func (v bucketInfoMessage) JSON() string { fatalIf(probe.NewError(enc.Encode(v)), "Unable to marshal into JSON.") return buf.String() - } func (v bucketInfoMessage) String() string { diff --git a/cmd/stat_test.go b/cmd/stat_test.go index b7fafe6e..17bc9472 100644 --- a/cmd/stat_test.go +++ b/cmd/stat_test.go @@ -33,8 +33,8 @@ func TestParseStat(t *testing.T) { }{ {ClientContent{URL: *newClientURL("https://play.min.io/abc"), Size: 0, Time: localTime, Type: os.ModeDir, ETag: "blahblah", Metadata: map[string]string{"cusom-key": "custom-value"}, Expires: time.Now()}, "play"}, {ClientContent{URL: *newClientURL("https://play.min.io/testbucket"), Size: 500, Time: localTime, Type: os.ModeDir, ETag: "blahblah", Metadata: map[string]string{"cusom-key": "custom-value"}, Expires: time.Unix(0, 0).UTC()}, "play"}, - {ClientContent{URL: *newClientURL("https://s3.amazonaws.com/yrdy"), Size: 0, Time: localTime, Type: 0644, ETag: "abcdefasaas", Metadata: map[string]string{}}, "s3"}, - {ClientContent{URL: *newClientURL("https://play.min.io/yrdy"), Size: 10000, Time: localTime, Type: 0644, ETag: "blahblah", Metadata: map[string]string{"cusom-key": "custom-value"}}, "play"}, + {ClientContent{URL: *newClientURL("https://s3.amazonaws.com/yrdy"), Size: 0, Time: localTime, Type: 0o644, ETag: "abcdefasaas", Metadata: map[string]string{}}, "s3"}, + {ClientContent{URL: *newClientURL("https://play.min.io/yrdy"), Size: 10000, Time: localTime, Type: 0o644, ETag: "blahblah", Metadata: map[string]string{"cusom-key": "custom-value"}}, "play"}, } for _, testCase := range testCases { testCase := testCase diff --git a/cmd/status.go b/cmd/status.go index 59c4b398..90f4cd2a 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -31,19 +31,15 @@ type Status interface { AddCounts(int64) SetCounts(int64) GetCounts() int64 - Add(int64) Status Get() int64 Start() Finish() - PrintMsg(msg message) - Update() Total() int64 SetTotal(int64) Status SetCaption(string) - Read(p []byte) (n int, err error) errorIf(err *probe.Error, msg string) diff --git a/cmd/subnet-utils.go b/cmd/subnet-utils.go index 8f48ca31..02eee2ef 100644 --- a/cmd/subnet-utils.go +++ b/cmd/subnet-utils.go @@ -20,6 +20,8 @@ package cmd import ( "bufio" "bytes" + "encoding/base64" + "encoding/json" "errors" "fmt" "io" @@ -30,9 +32,6 @@ import ( "strings" "time" - "encoding/base64" - "encoding/json" - "github.com/minio/cli" "github.com/minio/madmin-go" "github.com/minio/mc/pkg/probe" diff --git a/cmd/tag-set.go b/cmd/tag-set.go index 87753f1f..0954af24 100644 --- a/cmd/tag-set.go +++ b/cmd/tag-set.go @@ -137,7 +137,6 @@ func setTags(ctx context.Context, clnt Client, versionID, tags string, verbose b Name: clnt.GetURL().String(), VersionID: versionID, }) - } func mainSetTag(cliCtx *cli.Context) error { diff --git a/cmd/tree-main.go b/cmd/tree-main.go index b1287050..ff7b5f42 100644 --- a/cmd/tree-main.go +++ b/cmd/tree-main.go @@ -140,7 +140,6 @@ func parseTreeSyntax(ctx context.Context, cliCtx *cli.Context) (args []string, d // doTree - list all entities inside a folder in a tree format. func doTree(ctx context.Context, url string, timeRef time.Time, level int, leaf bool, branchString string, depth int, includeFiles bool) error { - targetAlias, targetURL, _ := mustExpandAlias(url) if !strings.HasSuffix(targetURL, "/") { targetURL += "/" diff --git a/cmd/undo-main.go b/cmd/undo-main.go index 88e1f643..92dcd85a 100644 --- a/cmd/undo-main.go +++ b/cmd/undo-main.go @@ -31,27 +31,25 @@ import ( "github.com/minio/pkg/console" ) -var ( - undoFlags = []cli.Flag{ - cli.IntFlag{ - Name: "last", - Usage: "undo N last changes", - Value: 1, - }, - cli.BoolFlag{ - Name: "recursive, r", - Usage: "undo last S3 PUT/DELETE operations recursively", - }, - cli.BoolFlag{ - Name: "force", - Usage: "force recursive operation", - }, - cli.BoolFlag{ - Name: "dry-run", - Usage: "fake an undo operation", - }, - } -) +var undoFlags = []cli.Flag{ + cli.IntFlag{ + Name: "last", + Usage: "undo N last changes", + Value: 1, + }, + cli.BoolFlag{ + Name: "recursive, r", + Usage: "undo last S3 PUT/DELETE operations recursively", + }, + cli.BoolFlag{ + Name: "force", + Usage: "force recursive operation", + }, + cli.BoolFlag{ + Name: "dry-run", + Usage: "fake an undo operation", + }, +} var undoCmd = cli.Command{ Name: "undo", diff --git a/cmd/update-main.go b/cmd/update-main.go index 636d1c46..48bb42a2 100644 --- a/cmd/update-main.go +++ b/cmd/update-main.go @@ -85,10 +85,8 @@ const ( envMinisignPubKey = "MC_UPDATE_MINISIGN_PUBKEY" ) -var ( - // For windows our files have .exe additionally. - mcReleaseWindowsInfoURL = mcReleaseURL + "mc.exe.sha256sum" -) +// For windows our files have .exe additionally. +var mcReleaseWindowsInfoURL = mcReleaseURL + "mc.exe.sha256sum" // mcVersionToReleaseTime - parses a standard official release // mc --version string. @@ -208,7 +206,6 @@ func IsSourceBuild() bool { // Any change here should be discussed by opening an issue at // https://github.com/minio/mc/issues. func getUserAgent() string { - userAgentParts := []string{} // Helper function to concisely append a pair of strings to a // the user-agent slice. diff --git a/cmd/utils_test.go b/cmd/utils_test.go index b32b0adb..01feef36 100644 --- a/cmd/utils_test.go +++ b/cmd/utils_test.go @@ -121,7 +121,8 @@ func TestParseAttribute(t *testing.T) { // When "atime:" is passed. {"atime:", map[string]string{"atime": ""}, nil, true}, // Passing a valid value - {"atime:1/gid:1/gname:a/md:/mode:3/mtime:1/uid:1/uname:a", + { + "atime:1/gid:1/gname:a/md:/mode:3/mtime:1/uid:1/uname:a", map[string]string{ "atime": "1", "gid": "1", @@ -131,7 +132,9 @@ func TestParseAttribute(t *testing.T) { "mtime": "1", "uid": "1", "uname": "a", - }, nil, true}, + }, + nil, true, + }, } for idx, testCase := range metaDataCases { diff --git a/cmd/watch-main.go b/cmd/watch-main.go index 17a204af..4b90da79 100644 --- a/cmd/watch-main.go +++ b/cmd/watch-main.go @@ -32,27 +32,25 @@ import ( "github.com/minio/pkg/console" ) -var ( - watchFlags = []cli.Flag{ - cli.StringFlag{ - Name: "events", - Value: "put,delete,get", - Usage: "filter specific types of events; defaults to all events by default", - }, - cli.StringFlag{ - Name: "prefix", - Usage: "filter events for a prefix", - }, - cli.StringFlag{ - Name: "suffix", - Usage: "filter events for a suffix", - }, - cli.BoolFlag{ - Name: "recursive", - Usage: "recursively watch for events", - }, - } -) +var watchFlags = []cli.Flag{ + cli.StringFlag{ + Name: "events", + Value: "put,delete,get", + Usage: "filter specific types of events; defaults to all events by default", + }, + cli.StringFlag{ + Name: "prefix", + Usage: "filter events for a prefix", + }, + cli.StringFlag{ + Name: "suffix", + Usage: "filter events for a suffix", + }, + cli.BoolFlag{ + Name: "recursive", + Usage: "recursively watch for events", + }, +} var watchCmd = cli.Command{ Name: "watch", diff --git a/pkg/disk/stat_other.go b/pkg/disk/stat_other.go index 4df8b1a0..ef54d795 100644 --- a/pkg/disk/stat_other.go +++ b/pkg/disk/stat_other.go @@ -30,7 +30,6 @@ import ( // GetFileSystemAttrs return the file system attribute as string; containing mode, // uid, gid, uname, Gname, atime, mtime, ctime and md5 func GetFileSystemAttrs(file string) (string, error) { - st := syscall.Stat_t{} err := syscall.Stat(file, &st) if err != nil { diff --git a/pkg/httptracer/httptracer.go b/pkg/httptracer/httptracer.go index ae8fa942..f09e71c1 100644 --- a/pkg/httptracer/httptracer.go +++ b/pkg/httptracer/httptracer.go @@ -71,6 +71,8 @@ func (t RoundTripTrace) RoundTrip(req *http.Request) (res *http.Response, err er // Takes first argument a custom tracer which implements Response, Request() conforming to HTTPTracer interface. // Another argument can be a default transport or a custom http.RoundTripper implementation func GetNewTraceTransport(trace HTTPTracer, transport http.RoundTripper) RoundTripTrace { - return RoundTripTrace{Trace: trace, - Transport: transport} + return RoundTripTrace{ + Trace: trace, + Transport: transport, + } }