简体   繁体   中英

Setting up environment - $GOPATH

I have defined my $GOPATH to be $HOME/go and when using vim-go, it has installed several binaries (using :GoInstallBinaries) into that folder. Now the structure is similar to:

--go/
----bin/
------ list of binaries

----pkg/
------linux_amd64
--------- list of other directories

----src/
------github.com
--------several other directories, similar with ones below
------golang.org
------gopg.in

I'm confused now where to start my own project within this structure? Say I wanted to create my own project virtual_tree, from what I understand it should be under src. But should that be inside of github.com? Where should my project go? Do I need to use pkg/ for anything? I understand that bin/ contains the executable for the project.

Thanks!

  1. You should follow the convention of $GOPATH/src/REPOSITORY_PROVIDER/USERNAME/PROJECT . So, if your virtual_tree project resides in github, then you should locate it in $GOPATH/src/github.com/naz/virtual_tree .

  2. The pkg directory contains the compiled packages. Within that directory a sub-directory that describes the target architecture is created and that mirrors the source directories.

Read more on:

https://dave.cheney.net/2014/12/01/five-suggestions-for-setting-up-a-go-project

https://www.goinggo.net/2013/07/how-packages-work-in-go-language.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM