File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 99 "io/ioutil"
1010 "os"
1111 "strings"
12+ "sync"
1213 "unicode"
1314 "unicode/utf8"
1415)
@@ -37,9 +38,10 @@ var keywords = map[string]tkType{
3738}
3839
3940type Netrc struct {
40- tokens []* token
41- machines []* Machine
42- macros Macros
41+ tokens []* token
42+ machines []* Machine
43+ macros Macros
44+ updateLock sync.Mutex
4345}
4446
4547// FindMachine returns the Machine in n named by name. If a machine named by
@@ -80,7 +82,9 @@ func (n *Netrc) MarshalText() (text []byte, err error) {
8082}
8183
8284func (n * Netrc ) NewMachine (name , login , password , account string ) * Machine {
83- // TODO(bgentry): not safe for concurrency
85+ n .updateLock .Lock ()
86+ defer n .updateLock .Unlock ()
87+
8488 m := & Machine {
8589 Name : name ,
8690 Login : login ,
You can’t perform that action at this time.
0 commit comments