diff options
| author | Nicolas Paul <n@nc0.fr> | 2023-05-31 23:55:49 +0200 |
|---|---|---|
| committer | Nicolas Paul <n@nc0.fr> | 2023-05-31 23:55:49 +0200 |
| commit | 553823a62a61b0155a352d5a1964f97ffdbfc6d6 (patch) | |
| tree | 5d4e6435c920c3d4aa1758d4c5d5084a9793b025 /pkg/types/index.go | |
| parent | eef84422175de47923ab40009a406cb9d70f6d1c (diff) | |
Fix race conditions
Signed-off-by: Nicolas Paul <n@nc0.fr>
Diffstat (limited to 'pkg/types/index.go')
| -rw-r--r-- | pkg/types/index.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/pkg/types/index.go b/pkg/types/index.go index 623555c..ebb6f52 100644 --- a/pkg/types/index.go +++ b/pkg/types/index.go @@ -10,7 +10,7 @@ import ( // Index is the global object representing the Starlark configuration. type Index struct { Domain string - Modules map[string]Module + Modules map[string]*Module // internal lock sync.Mutex } @@ -23,14 +23,14 @@ func (i *Index) SetDomain(d string) { } // AddModule adds a module to the index. -func (i *Index) AddModule(n string, m Module) { +func (i *Index) AddModule(n string, m *Module) { i.lock.Lock() defer i.lock.Unlock() i.Modules[n] = m } // GetModule returns a module from the index. -func (i *Index) GetModule(n string) Module { +func (i *Index) GetModule(n string) *Module { i.lock.Lock() defer i.lock.Unlock() return i.Modules[n] |
