should omit nil check; len() for map[string]string is defined as zero
156// WithWriteMetadata returns Option that sets c.writerOpts.Metadata.
157func WithWriteMetadata(meta map[string]string) Option {
158 return func(c *client) error {
159 if meta != nil && len(meta) != 0 {160 if c.writerOpts == nil {
161 c.writerOpts = new(blob.WriterOptions)
162 }
Description
The length of a nil
slice evaluates to zero. Hence, there is no need to check
whether a slice is nil
before calculating its length.
Bad practice
if x != nil && len(x) != 0 {
x[0] = 1
}
Recommended
if len(x) != 0 {
x[0] = 1
}