Skip to content

Latest commit

 

History

History

R001

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

R001

The R001 analyzer reports a complex key argument for a Set() call. It is preferred to explicitly use a string literal as the key argument.

Flagged Code

keys := []string{"example1", "example2"}
values := []string{"value1", "value2"}

for idx, key := range keys {
    d.Set(key, values[idx])
}

Passing Code

d.Set("example1", "value1")
d.Set("example2", "value2")

Ignoring Reports

Singular reports can be ignored by adding the a //lintignore:R001 Go code comment at the end of the offending line or on the line immediately proceding, e.g.

keys := []string{"example1", "example2"}
values := []string{"value1", "value2"}

for idx, key := range keys {
    //lintignore:R001
    d.Set(key, values[idx])
}