title: extension methods in golang?
body: <p>I am a .NET guy. Very much new to the Go language.</p>
  
  <p>In .NET we have extension methods. Is there anything equivalent in Go?</p>
  
  <p>In .NET I will do like <code>bsonTrans["trans.ticket"]</code></p>
  
  <p>in that bsonTrans => bson document</p>
  
  <pre><code>    "trans.ticket" =&gt; key in json
  
       trans is outer level and
  
       ticket is inner level
  </code></pre>
  
  <p>I am using native mongodb driver. In that I add my extension functions to perform these operations.</p>
  
  <p>Like wise up to the nth level I did it .NET.</p>
  
  <p>I would like to apply the same logic in Go.</p>
  
  <p><strong>Example</strong></p>
  
  <pre><code> b := []byte(trans)
  var config map[string]interface{}
  err := json.Unmarshal(b, &amp;config)
  
  fmt.Println(config["data"].(map[string] interface{})["issued"])
  </code></pre>
  
  <p>For instance in that example, can i do something like:</p>
  
  <p><strong>config["data.issued"]</strong> which should give the value in return ?</p>
  
  <p>Please help me in figuring this out...</p>
  
  <p><strong>Actual json :-</strong></p>
  
  <p>(The actual json is too big, however I am providing a sample of it with less fields.)</p>
  
  <pre><code>{
   "_id" : 2001,
      "address" : {
          "line1" : "",
          "line2" : "",
          "line3" : ""
         },
      "tickets" : [ 
          {
              "seq" : 2,
              "add" : [
                {
                "seq" : "",
                "amnt" : 50
                },
  
                {
                "seq" : "",
                "amnt" : 50
                {
                "seq" : "",
                "amnt" : 50
                }
                }
  
                }
               ]
  }
  </code></pre>
  
  <p><strong>Reason for not using struct</strong> is my json has too many nested structures and I have more than 10 schemas with different structures.</p>
  
  <p>So I left out structs.</p>
  
  <p>I admit that I am not sure that omitting structs is the best way.</p>