mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-22 08:18:32 +00:00
Use MustCompile for static regexp
Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
parent
8a9f367067
commit
dd2f218226
@ -154,10 +154,7 @@ func (t Toml) contents() ([]byte, error) {
|
||||
// format fixes the comments for the config to ensure that they start in column
|
||||
// 1 and are not followed by a space.
|
||||
func (t Toml) format(contents []byte) ([]byte, error) {
|
||||
r, err := regexp.Compile(`(\n*)\s*?#\s*(\S.*)`)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("unable to compile regexp: %v", err)
|
||||
}
|
||||
r := regexp.MustCompile(`(\n*)\s*?#\s*(\S.*)`)
|
||||
replaced := r.ReplaceAll(contents, []byte("$1#$2"))
|
||||
|
||||
return replaced, nil
|
||||
|
Loading…
Reference in New Issue
Block a user