File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
Expand file tree Collapse file tree 1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -101,9 +101,9 @@ func (t *Tools) GetLocation(command string) (string, error) {
101101
102102// writeMap() writes installed map to the json file "installed.json"
103103func (t * Tools ) writeMap () error {
104- t .mutex .RLock ()
104+ t .mutex .Lock ()
105105 b , err := json .Marshal (t .installed )
106- t .mutex .RUnlock ()
106+ defer t .mutex .Unlock ()
107107 if err != nil {
108108 return err
109109 }
@@ -113,13 +113,13 @@ func (t *Tools) writeMap() error {
113113
114114// readMap() reads the installed map from json file "installed.json"
115115func (t * Tools ) readMap () error {
116+ t .mutex .Lock ()
117+ defer t .mutex .Unlock ()
116118 filePath := path .Join (dir (), "installed.json" )
117119 b , err := ioutil .ReadFile (filePath )
118120 if err != nil {
119121 return err
120122 }
121- t .mutex .Lock ()
122- defer t .mutex .Unlock ()
123123 return json .Unmarshal (b , & t .installed )
124124}
125125
You can’t perform that action at this time.
0 commit comments