Skip to content

Commit f7de06d

Browse files
committed
run modernize command on src
1 parent 718c75e commit f7de06d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+172
-181
lines changed

cmd/health-monitor_stop.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ func getPid(blobfuse2Pid string) (string, error) {
7878
if err != nil {
7979
return "", err
8080
}
81-
processes := strings.Split(string(out), "\n")
82-
for _, process := range processes {
81+
processes := strings.SplitSeq(string(out), "\n")
82+
for process := range processes {
8383
if strings.Contains(process, "bfusemon") && strings.Contains(process, fmt.Sprintf("--pid=%s", blobfuse2Pid)) {
8484
re := regexp.MustCompile(`[-]?\d[\d,]*[\.]?[\d{2}]*`)
8585
pids := re.FindAllString(process, 1)

cmd/mount.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import (
4646
"runtime"
4747
"runtime/debug"
4848
"runtime/pprof"
49+
"slices"
4950
"strconv"
5051
"strings"
5152
"syscall"
@@ -450,11 +451,8 @@ var mountCmd = &cobra.Command{
450451
common.EnableMonitoring = options.MonitorOpt.EnableMon
451452

452453
// check if blobfuse stats monitor is added in the disable list
453-
for _, mon := range options.MonitorOpt.DisableList {
454-
if mon == common.BfuseStats {
455-
common.BfsDisabled = true
456-
break
457-
}
454+
if slices.Contains(options.MonitorOpt.DisableList, common.BfuseStats) {
455+
common.BfsDisabled = true
458456
}
459457

460458
config.Set("mount-path", options.MountPath)

cmd/mountgen1.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ var gen1Cmd = &cobra.Command{
150150

151151
// code to generate json file for rustfuse
152152
func generateAdlsGenOneJson() error {
153-
rustFuseMap := make(map[string]interface{})
153+
rustFuseMap := make(map[string]any)
154154
if strings.ToLower(azStorageOpt.AuthMode) == "spn" {
155155
// adlsgen1fuse will be reading secret from env variable (ADL_CLIENT_SECRET) hence no reason to include this.
156156
// rustFuseMap["clientsecret"] = azStorageOpt.ClientSecret

cmd/root.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"io"
4141
"net/http"
4242
"os"
43+
"slices"
4344
"strings"
4445
"time"
4546

@@ -124,8 +125,8 @@ func getRemoteVersion(req string) (string, error) {
124125
}
125126

126127
// beginDetectNewVersion : Get latest release version and compare if user needs an upgrade or not
127-
func beginDetectNewVersion() chan interface{} {
128-
completed := make(chan interface{})
128+
func beginDetectNewVersion() chan any {
129+
completed := make(chan any)
129130
stderr := os.Stderr
130131
go func() {
131132
defer close(completed)
@@ -206,10 +207,8 @@ func VersionCheck() error {
206207
func ignoreCommand(cmdArgs []string) bool {
207208
ignoreCmds := []string{"completion", "help"}
208209
if len(cmdArgs) > 0 {
209-
for _, c := range ignoreCmds {
210-
if c == cmdArgs[0] {
211-
return true
212-
}
210+
if slices.Contains(ignoreCmds, cmdArgs[0]) {
211+
return true
213212
}
214213
}
215214
return false
@@ -246,8 +245,8 @@ func parseArgs(cmdArgs []string) []string {
246245
lfuseArgs := make([]string, 0)
247246

248247
// Check if ',' exists in arguments or not. If so we assume it might be coming from /etc/fstab
249-
opts := strings.Split(cmdArgs[i], ",")
250-
for _, o := range opts {
248+
opts := strings.SplitSeq(cmdArgs[i], ",")
249+
for o := range opts {
251250
// If we got comma separated list then all blobfuse specific options needs to be extracted out
252251
// as those shall not be part of -o list which for us means libfuse options
253252
if strings.HasPrefix(o, "--") {

common/config/config_parser.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func (handler ConfigChangeEventHandlerFunc) OnConfigChange() {
7171
handler()
7272
}
7373

74-
type KeysTree map[string]interface{}
74+
type KeysTree map[string]any
7575

7676
type options struct {
7777
path string
@@ -226,12 +226,12 @@ func BindPFlag(key string, flag *pflag.Flag) {
226226
// name: value
227227
//
228228
// the key parameter should take on the value "auth.key"
229-
func UnmarshalKey(key string, obj interface{}) error {
229+
func UnmarshalKey(key string, obj any) error {
230230
err := viper.UnmarshalKey(key, obj, func(decodeConfig *mapstructure.DecoderConfig) { decodeConfig.TagName = STRUCT_TAG })
231231
if err != nil {
232232
return fmt.Errorf("config error: unmarshalling [%v]", err)
233233
}
234-
userOptions.envTree.MergeWithKey(key, obj, func(val interface{}) (interface{}, bool) {
234+
userOptions.envTree.MergeWithKey(key, obj, func(val any) (any, bool) {
235235
envVar := val.(string)
236236
res, ok := os.LookupEnv(envVar)
237237
if ok {
@@ -240,7 +240,7 @@ func UnmarshalKey(key string, obj interface{}) error {
240240
return "", false
241241
}
242242
})
243-
userOptions.flagTree.MergeWithKey(key, obj, func(val interface{}) (interface{}, bool) {
243+
userOptions.flagTree.MergeWithKey(key, obj, func(val any) (any, bool) {
244244
flag := val.(*pflag.Flag)
245245
if flag.Changed {
246246
return flag.Value.String(), true
@@ -253,12 +253,12 @@ func UnmarshalKey(key string, obj interface{}) error {
253253

254254
// Unmarshal populates the passed object and all the exported fields.
255255
// use lower case attribute names to ignore a particular field
256-
func Unmarshal(obj interface{}) error {
256+
func Unmarshal(obj any) error {
257257
err := viper.Unmarshal(obj, func(decodeConfig *mapstructure.DecoderConfig) { decodeConfig.TagName = STRUCT_TAG })
258258
if err != nil {
259259
return fmt.Errorf("config error: unmarshalling [%v]", err)
260260
}
261-
userOptions.envTree.Merge(obj, func(val interface{}) (interface{}, bool) {
261+
userOptions.envTree.Merge(obj, func(val any) (any, bool) {
262262
envVar := val.(string)
263263
res, ok := os.LookupEnv(envVar)
264264
if ok {
@@ -267,7 +267,7 @@ func Unmarshal(obj interface{}) error {
267267
return "", false
268268
}
269269
})
270-
userOptions.flagTree.Merge(obj, func(val interface{}) (interface{}, bool) {
270+
userOptions.flagTree.Merge(obj, func(val any) (any, bool) {
271271
flag := val.(*pflag.Flag)
272272
if flag.Changed {
273273
return flag.Value.String(), true

common/config/keys_tree.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const STRUCT_TAG = "config"
4444

4545
type TreeNode struct {
4646
children map[string]*TreeNode
47-
value interface{}
47+
value any
4848
name string
4949
}
5050

@@ -70,7 +70,7 @@ func NewTreeNode(name string) *TreeNode {
7070
// Insert function is used to insert a new object into the tree
7171
// The key is specified as a dot separated hierarchical value
7272
// For eg. root.child1.child2
73-
func (tree *Tree) Insert(key string, value interface{}) {
73+
func (tree *Tree) Insert(key string, value any) {
7474
subKeys := strings.Split(key, ".")
7575
curNode := tree.head
7676
for _, idx := range subKeys {
@@ -118,7 +118,7 @@ func (tree *Tree) GetSubTree(key string) *TreeNode {
118118
}
119119

120120
// parseValue is a utility function that accepts a val and returns the parsed value of that type.
121-
func parseValue(val string, toType reflect.Kind) interface{} {
121+
func parseValue(val string, toType reflect.Kind) any {
122122
switch toType {
123123
case reflect.Bool:
124124
parsed, err := strconv.ParseBool(val)
@@ -220,7 +220,7 @@ func parseValue(val string, toType reflect.Kind) interface{} {
220220
// MergeWithKey is used to merge the contained tree with the object (obj) that is passed in as parameter.
221221
// getValue parameter is a function that accepts the value stored in a TreeNode and performs any business logic and returns the value that has to be placed in the obj parameter
222222
// it must also return true|false based on which the value will be set in the obj parameter.
223-
func (tree *Tree) MergeWithKey(key string, obj interface{}, getValue func(val interface{}) (res interface{}, ok bool)) {
223+
func (tree *Tree) MergeWithKey(key string, obj any, getValue func(val any) (res any, ok bool)) {
224224
subTree := tree.GetSubTree(key)
225225
if subTree == nil {
226226
return
@@ -257,7 +257,7 @@ func (tree *Tree) MergeWithKey(key string, obj interface{}, getValue func(val in
257257
}
258258

259259
// Merge performs the same function as MergeWithKey but at the root level
260-
func (tree *Tree) Merge(obj interface{}, getValue func(val interface{}) (res interface{}, ok bool)) {
260+
func (tree *Tree) Merge(obj any, getValue func(val any) (res any, ok bool)) {
261261
subTree := tree.head
262262
if subTree == nil {
263263
return
@@ -334,7 +334,7 @@ func isPrimitiveType(kind reflect.Kind) bool {
334334
}
335335

336336
// assignToField is utility function to set the val to the passed field based on it's state
337-
func assignToField(field reflect.Value, val interface{}) {
337+
func assignToField(field reflect.Value, val any) {
338338
if field.CanSet() {
339339
if reflect.TypeOf(val).Kind() == reflect.String {
340340
parseVal := parseValue(val.(string), field.Kind())

common/config/keys_tree_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func TestKeysTree(t *testing.T) {
5757
type parseVal struct {
5858
val string
5959
toType reflect.Kind
60-
result interface{}
60+
result any
6161
}
6262

6363
func (suite *keysTreeTestSuite) TestParseValue() {

common/log/base_logger.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,37 +89,37 @@ func (l *BaseLogger) GetLogLevel() common.LogLevel {
8989
return l.fileConfig.LogLevel
9090
}
9191

92-
func (l *BaseLogger) Debug(format string, args ...interface{}) {
92+
func (l *BaseLogger) Debug(format string, args ...any) {
9393
if l.fileConfig.LogLevel >= common.ELogLevel.LOG_DEBUG() {
9494
l.logEvent(common.ELogLevel.LOG_DEBUG().String(), format, args...)
9595
}
9696
}
9797

98-
func (l *BaseLogger) Trace(format string, args ...interface{}) {
98+
func (l *BaseLogger) Trace(format string, args ...any) {
9999
if l.fileConfig.LogLevel >= common.ELogLevel.LOG_TRACE() {
100100
l.logEvent(common.ELogLevel.LOG_TRACE().String(), format, args...)
101101
}
102102
}
103103

104-
func (l *BaseLogger) Info(format string, args ...interface{}) {
104+
func (l *BaseLogger) Info(format string, args ...any) {
105105
if l.fileConfig.LogLevel >= common.ELogLevel.LOG_INFO() {
106106
l.logEvent(common.ELogLevel.LOG_INFO().String(), format, args...)
107107
}
108108
}
109109

110-
func (l *BaseLogger) Warn(format string, args ...interface{}) {
110+
func (l *BaseLogger) Warn(format string, args ...any) {
111111
if l.fileConfig.LogLevel >= common.ELogLevel.LOG_WARNING() {
112112
l.logEvent(common.ELogLevel.LOG_WARNING().String(), format, args...)
113113
}
114114
}
115115

116-
func (l *BaseLogger) Err(format string, args ...interface{}) {
116+
func (l *BaseLogger) Err(format string, args ...any) {
117117
if l.fileConfig.LogLevel >= common.ELogLevel.LOG_ERR() {
118118
l.logEvent(common.ELogLevel.LOG_ERR().String(), format, args...)
119119
}
120120
}
121121

122-
func (l *BaseLogger) Crit(format string, args ...interface{}) {
122+
func (l *BaseLogger) Crit(format string, args ...any) {
123123
if l.fileConfig.LogLevel >= common.ELogLevel.LOG_CRIT() {
124124
l.logEvent(common.ELogLevel.LOG_CRIT().String(), format, args...)
125125
}
@@ -215,7 +215,7 @@ func (l *BaseLogger) Destroy() error {
215215
}
216216

217217
// logEvent : Enqueue the log to the channel
218-
func (l *BaseLogger) logEvent(lvl string, format string, args ...interface{}) {
218+
func (l *BaseLogger) logEvent(lvl string, format string, args ...any) {
219219
// Only log if the log level matches the log request
220220
_, fn, ln, _ := runtime.Caller(3)
221221
msg := fmt.Sprintf(format, args...)

common/log/logger.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,12 @@ type Logger interface {
5555

5656
GetType() string
5757
GetLogLevel() common.LogLevel
58-
Debug(format string, args ...interface{})
59-
Trace(format string, args ...interface{})
60-
Info(format string, args ...interface{})
61-
Warn(format string, args ...interface{})
62-
Err(format string, args ...interface{})
63-
Crit(format string, args ...interface{})
58+
Debug(format string, args ...any)
59+
Trace(format string, args ...any)
60+
Info(format string, args ...any)
61+
Warn(format string, args ...any)
62+
Err(format string, args ...any)
63+
Crit(format string, args ...any)
6464
LogRotate() error
6565
}
6666

@@ -191,32 +191,32 @@ func Destroy() error {
191191
// ------------------ Public methods for logging events ------------------
192192

193193
// Debug : Debug message logging
194-
func Debug(msg string, args ...interface{}) {
194+
func Debug(msg string, args ...any) {
195195
logObj.Debug(msg, args...)
196196
}
197197

198198
// Trace : Trace message logging
199-
func Trace(msg string, args ...interface{}) {
199+
func Trace(msg string, args ...any) {
200200
logObj.Trace(msg, args...)
201201
}
202202

203203
// Info : Info message logging
204-
func Info(msg string, args ...interface{}) {
204+
func Info(msg string, args ...any) {
205205
logObj.Info(msg, args...)
206206
}
207207

208208
// Warn : Warning message logging
209-
func Warn(msg string, args ...interface{}) {
209+
func Warn(msg string, args ...any) {
210210
logObj.Warn(msg, args...)
211211
}
212212

213213
// Err : Error message logging
214-
func Err(msg string, args ...interface{}) {
214+
func Err(msg string, args ...any) {
215215
logObj.Err(msg, args...)
216216
}
217217

218218
// Crit : Critical message logging
219-
func Crit(msg string, args ...interface{}) {
219+
func Crit(msg string, args ...any) {
220220
logObj.Crit(msg, args...)
221221
}
222222

common/log/logger_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ func fastTestCrit(lts *LoggerTestSuite) {
6161

6262
func simpleTest(lts *LoggerTestSuite) {
6363
Crit("Running Simple Test")
64-
for l := 0; l < 3; l++ {
64+
for l := range 3 {
6565
switch l {
6666
case 0:
6767
SetLogLevel(common.ELogLevel.LOG_DEBUG())

0 commit comments

Comments
 (0)