From a7ccd4bbdb2ce0de01c4a105cc30292e3574a454 Mon Sep 17 00:00:00 2001 From: Leonel Quinteros Date: Sun, 19 Jun 2016 19:47:28 -0300 Subject: [PATCH] Add sync to PO parse --- po.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/po.go b/po.go index 99304ca..d1a3557 100644 --- a/po.go +++ b/po.go @@ -6,10 +6,15 @@ import ( "os" "strconv" "strings" + "sync" ) type Po struct { + // Storage translations map[string]string + + // Sync Mutex + sync.RWMutex } // ParseFile tries to read the file by its provided path (f) and parse its content as a .po file. @@ -36,6 +41,9 @@ func (po *Po) ParseFile(f string) { // Parse loads the translations specified in the provided string (str) func (po *Po) Parse(str string) { + po.Lock() + defer po.Unlock() + if po.translations == nil { po.translations = make(map[string]string) }