<p>Okay, I am new to Golang, and I think I have the $GOROOT path thing down. So, this seems a little strange. </p>
<p>I created a directory $GOROOT/src/path with a simple main.go file.</p>
<pre><code>package main
import (
"fmt"
"path/filepath"
)
func main() {
path := filepath.Join("templates", "chat.html")
fmt.Println(path)
}
</code></pre>
<p>In my $GOROOT directory, I enter <code>go install path</code>, and nothing happens. There is no executable in $GOROOT/bin. Then, I change the directory name to <code>htap</code> and enter <code>go install htap</code>. Like magic there is a executable named htap in the bin directory. </p>
<p>Looking at the <a href="https://golang.org/cmd/go" rel="nofollow">Go Command Page</a> there doesn't appear to be anything special about <code>go install path</code>. Has anyone else encountered this? </p>
<p>Config:
Ubuntu 16.10; Go 1.8 </p>
<hr/>**评论:**<br/><br/>dinkumator: <pre><p>A package named "path" is part of the stdlib, you're clobbering it so there's no wonder it doesn't work. Also, its standard to use GOPATH, not GOROOT for development (GOROOT is where the toolchain and stdlib live)</p></pre>scottg2k: <pre><p>Thx! I'll be more careful in naming my project directories in the future. Oops, I meant GOPATH. Copy-paste err.</p></pre>ROFLLOLSTER: <pre><p>The standard is for the source folder is this structure:</p>
<pre><code>github.com
(username)
(package)
(subpackage)
</code></pre>
<p>This is how go get installs dependencies.</p></pre>whizack: <pre><p>GOROOT is different from GOPATH</p>
<p>GOROOT is the path to the official go binaries/libs
GOPATH is the base path to the source you write</p>
<p>GOPATH/src/<repo host>/<organization>/<project> is usually how GOPATH is structured and you'd work out of the <project> folder</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传