title: Golang Interface with functions receiving specified Interface args
body: <p>I'm trying to use interfaces in Go to achive two advantages:</p>
  <ol>
  <li>Protect myself of mixing up variables order</li>
  <li>Make package independent from each other, so one day I'll can easily replace one of them.</li>
  </ol>
  <p>In my particular case I can find workaroung, but I can't understand why the way I try cannot work, it seems simple and logically.</p>
  <p>Here is what I do.</p>
  <p>In one package (named handlers) I have an interface describing a function I need, just something receiving <code>Account</code>.</p>
  <pre class="lang-golang prettyprint-override"><code>package handlers
  
  type Accounter interface {
      AddAccount(a Account)
  }
  
  type Account interface {
      AccountID() int64
      UserID() int64
      OtherID() int64
  
  }
  </code></pre>
  <p>In other package of my programm (named accounter) I have function matching the interface, and definition of <code>Account</code> interface to avoid importing this interface from first package.</p>
  <pre class="lang-golang prettyprint-override"><code>package accounter
  
  type Account interface {
      AccountID() int64
      UserID() int64
      OtherID() int64
  }
  
  func (x *accounter) AddAccount(a Account) {
  ...
  }
  </code></pre>
  <p>But the <code>go vet</code> tells me that I can't do such thing:</p>
  <pre><code>configure_stats_loader.go:109:64: cannot use x (type *accounter.Accounter) as type handlers.Accounter in argument to handlers.AddAccHandler:
      *accounter.Accounter does not implement handlers.Accounter (wrong type for AddAccount method)
          have AddAccount(accounter.Account)
          want AddAccount(handlers.Account)
  </code></pre>
  <p>In this case I have to solutions:</p>
  <ol>
  <li>Import <code>Account</code> interface from one of the packages.</li>
  <li>Define function receving values in standard go types like <code>(UserID, AccoutID, OtherID int64)</code>.</li>
  </ol>
  <p>In first case I loose indepence in packages and in some future I'll cannot replace <code>Accounter</code> interface without rewriting some code (not a lot of code, but still), in second case, if I'll have a lot of similar methods and a lot of parameters in <code>Account</code>, I can accidentaly  mix up order of variables. For example accidentaly use <code>AccountID</code> as <code>UserID</code>.</p>
  <p>And now the question: Is there some way to have all advantages? Get protection from mixing up variables order and avoid imports from one package to another.</p>