What do the elipsis "..." at the end of a package/repo name in `go get` control?

blov · · 518 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Here&#39;s an example illustrating my question:</p> <pre><code>$ go get -u k8s.io/code-generator package k8s.io/code-generator: no Go files in /home/me/go/src/k8s.io/code-generator $ echo $? 1 $ go get -u k8s.io/code-generator/... $ echo $? 0 </code></pre> <p>The 2nd <code>go get</code> uses an elipsis <code>...</code> after the package/repo name and it seems to work. What exactly is happening here that it is successful?</p> <p>Thanks in advance!</p> <hr/>**评论:**<br/><br/>j_Bugman: <pre><p>&#39;pattern &#34;./...&#34; means start in the current directory (&#34;./&#34;) and find all packages below that directory (&#34;...&#34;)&#39; (from <a href="https://golang.org/doc/articles/go_command.html" rel="nofollow">https://golang.org/doc/articles/go_command.html</a>). Usually, it is used to install not only [library] package itself but also related binaries.</p></pre>chillysurfer: <pre><p>Ah ok perfect makes complete sense. Thanks!!!</p></pre>sh41: <pre><p>It’s called an import path pattern. It’s documented at <a href="https://golang.org/cmd/go/#hdr-Package_lists:" rel="nofollow">https://golang.org/cmd/go/#hdr-Package_lists:</a></p> <blockquote> <p>An import path is a pattern if it includes one or more &#34;...&#34; wildcards, each of which can match any string, including the empty string and strings containing slashes. Such a pattern expands to all package directories found in the GOPATH trees with names matching the patterns.</p> </blockquote> <p>You can practice using it with <code>go list</code> command. Try <code>go list net/...</code> and <code>go list ...util</code>.</p> <p>To get back to your question, you can see which packages <code>k8s.io/code-generator/...</code> pattern matches by doing either:</p> <pre><code>go get -u -v k8s.io/code-generator/... </code></pre> <p><code>-v</code> flag makes <code>go get</code> show the packages it’s working on.</p> <p>Or do <code>go list k8s.io/code-generator/...</code> afterwards.</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

518 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传