<p dir="auto">by <strong>nicerobot</strong>:</p>
<pre class="notranslate">A somewhat common and useful flag technique is:

./6.out -vvvv

where the same flag is specified multiple times. Such a mechanism seems impossible with
flag.go. It would be useful to provide an array version for flags. Maybe flag.Array,
flag.ArrayInt, flag.ArrayString, flag.ArrayVar, ...

Of course, the above example is a simplistic case and there are plenty of common
examples for allowing more complex duplicate flags to be specified. See rsync and find
for two very common uses.</pre>
<p dir="auto">I need to gobind multiple packages for an app.</p>
<p dir="auto">I considered running gomobile for each package and import multiple .so files, but that will fail due to various reasons:</p>
<ul dir="auto">
<li>gobind framework for java assumes a single 'gojni.so' file</li>
<li>duplicate code for go runtime in multiple .so files; conflicting symbols, storage, ...</li>
</ul>
<p dir="auto">Option 1:</p>
<blockquote>
<p dir="auto">gomobile bind -target=android -o=myapp.aar pkg1 pkg2 pkg3</p>
</blockquote>
<p dir="auto">The command will generate separate java classes for those packages, and gather all asset files under one asset directory. Conflicting package names and asset file names are error.</p>
<ul dir="auto">
<li>Problem of proposal 1<br>
I was about to implement fix for <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="55138912" data-permission-text="Title is private" data-url="https://github.com/golang/go/issues/9660" data-hovercard-type="issue" data-hovercard-url="/golang/go/issues/9660/hovercard" href="https://github.com/golang/go/issues/9660">#9660</a> and I don't know how it works with multiple packages.</li>
</ul>
<p dir="auto">Option 1.a</p>
<blockquote>
<p dir="auto">gomobile bind -target=android -o=myapp.aar -pkg=com.example.foo,org.example.bar,net.example.baz pkg pkg2 pkg3</p>
</blockquote>
<p dir="auto">Option 1.b</p>
<blockquote>
<p dir="auto">gomobile bind -target=android -o=myapp.aar pkg1:com.example.foo pkg2:org.example.bar pkg3 ...</p>
</blockquote>
<p dir="auto">Option 2:</p>
<blockquote>
<p dir="auto">gomobile bind -target=android -o=myapp.aar -list=something.json</p>
</blockquote>
<p dir="auto">Make gomobile take an input file of a certain format that lists all packages for gobind.</p>
<pre class="notranslate">   /* something.json */
   {
        Name: "pkg1",
        Android: "com.example.foo",
        IOS: "MyFoo"
   }
</pre>
<p dir="auto">Option 3:</p>
<p dir="auto">Fake main package file - so when gomobile bind sees the 'main' package, it runs gobind on all the imported packages, and process the command that specifies the custom package name for java and prefix for obj-c.</p>
<blockquote>
<p dir="auto">gomobile bind -target=android -o myapp.aar myapp.go</p>
</blockquote>
<pre class="notranslate">   /* myapp.go */
   package main
   import (
          _ "pkg1"  // android:com.example.foo ios:MyFoo
          ...
   )
   func main() {
   }
</pre>
<p dir="auto">/cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/crawshaw/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/crawshaw">@crawshaw</a> <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/rakyll/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/rakyll">@rakyll</a></p>