Skip to content

Commit

Permalink
Merge pull request #378 from ezradiniz/fix/data-race
Browse files Browse the repository at this point in the history
fix: data race in VimBuffer
  • Loading branch information
cassiobotaro authored Apr 4, 2021
2 parents 75c0ef7 + a1b7649 commit b3e8d9c
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ type Object struct {
Version string
}

// VimBuffer ...
var VimBuffer bytes.Buffer

//go:embed vim_template/vimrc
var vimrc string

Expand Down Expand Up @@ -91,9 +88,6 @@ func ListThemes() (list []string) {

// Generate file from configurations
func Generate(obj *Object) (buffer string) {
// Clean VimBuffer, not append old result
VimBuffer.Reset()

config := Config{}
switch obj.Editor {
case "nvim", "neovim":
Expand Down Expand Up @@ -126,9 +120,10 @@ func Generate(obj *Object) (buffer string) {
}
obj.BufferBundle = mBundle

var vimBuffer bytes.Buffer
t := template.Must(template.New("vimrc").Parse(vimrc))
t.Execute(&VimBuffer, obj)
t.Execute(&vimBuffer, obj)

buffer = VimBuffer.String()
buffer = vimBuffer.String()
return
}

0 comments on commit b3e8d9c

Please sign in to comment.