mirror of
https://github.com/NVIDIA/nvidia-container-toolkit
synced 2024-11-25 21:39:10 +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
|
// format fixes the comments for the config to ensure that they start in column
|
||||||
// 1 and are not followed by a space.
|
// 1 and are not followed by a space.
|
||||||
func (t Toml) format(contents []byte) ([]byte, error) {
|
func (t Toml) format(contents []byte) ([]byte, error) {
|
||||||
r, err := regexp.Compile(`(\n*)\s*?#\s*(\S.*)`)
|
r := regexp.MustCompile(`(\n*)\s*?#\s*(\S.*)`)
|
||||||
if err != nil {
|
|
||||||
return nil, fmt.Errorf("unable to compile regexp: %v", err)
|
|
||||||
}
|
|
||||||
replaced := r.ReplaceAll(contents, []byte("$1#$2"))
|
replaced := r.ReplaceAll(contents, []byte("$1#$2"))
|
||||||
|
|
||||||
return replaced, nil
|
return replaced, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user