title: Multiple constructors in Go / optional parameters?
body: <p>I was wondering if there was a way to implement multiple constructors (with the same function name) in Go, just like you can do in Java. Another option could be to only have one constructor with an optional parameter, but I am not sure how to do that exactly.</p>
  
  <p><a href="https://stackoverflow.com/questions/20150628/optional-parameters-with-defaults-in-go-struct-constructors">This seems similar to what I was trying to do</a></p>
  
  <pre><code>type Query struct {
      TagsQuery string
      PageQuery string
  }
  
  // First Constructor
  func NewQuery(TagsQuery string) Query {
      return Query{
          TagsQuery: TagsQuery,
          PageQuery: "0", // default to first page
      }
  }
  
  // Second Constructor
  func NewQuery(TagsQuery string, PageQuery string) Query {
      return Query{
          TagsQuery: TagsQuery,
          PageQuery: PageQuery,
      }
  }
  </code></pre>
  
  <p>The first constructor takes one argument <code>TagsQuery</code> and defaults <code>PageQuery</code> to <code>0</code>. The second constructor takes two arguments: <code>TagsQuery</code> and <code>PageQuery</code>.</p>