I have such code block where I just increment counters:
switch fileInfo.RequestType {
case lib.WRITE:
WriteCounter += 1
case lib.READ:
ReadCounter += 1
}
It seems to me that this snippet doesn't look like a idiomatic golang code. Can it be done more short and "elegant"?
More idiomatic:
switch fileInfo.RequestType {
case lib.Write:
writeCounter++
case lib.Read:
readCounter++
}
I'm not really sure what elegant here mean. Maybe putting the case
statement to be inline?
switch fileInfo.RequestType {
case lib.WRITE: WriteCounter += 1
case lib.READ: ReadCounter += 1
}
Writing style like above are valid, but it doesn't follow the gofmt
standard.