title: How to lock concurrent access to all struct fields internally?
body: <p>How to lock concurrent access to all struct fields internally? Let's say I have a struct:</p>
  
  <pre><code> type Data struct {
      ID string
      Size int
      //... and more fields
   }
  </code></pre>
  
  <p>That will be used in another struct: </p>
  
  <pre><code>type Project struct {
      mu sync.Mutex
      MetaData Data
      //... and more fields
  }
  </code></pre>
  
  <p>How could I modify/get MetaData struct and use mutex for that while not exposing its mutex to the outer packages? I know I could use Get/Set methods, but what if I needed to modify one field of Data struct (it wouldn't be very good/clean if every field had a get/set method with the same shared mutex)? Could you recommend a way/pattern to have a struct-wise mutex that would be locked/unlocked internally?</p>