I have 2 points of confusion about the How to Write Go Code article. They may be mistakes in the article, or I may just be missing the point. In describing the structure of the typical workspace, the article says
The src subdirectory typically contains multiple version control repositories (such as for Git or Mercurial) that track the development of one or more source packages.
The first example workspace in the article matches this description, with 2 folders representing repositories (github.com/golang/example/
and golang.org/x/image/
), each of which has a .git directory immediately below it.
Later, the article says:
If you're using a source control system, now would be a good time to initialize a repository, add the files, and commit your first change. Again, this step is optional: you do not need to use source control to write Go code.
Then the article shows example code running git init
in the src/github.com/user/hello/
directory. This is point of confusion #1. Since github.com/user
is the repository and hello
is the package, it seems like the git init
should be done at the level of github.com/user
.
Point of confusion #2 comes near the end of the article, when it says:
After issuing the above go get command, the workspace directory tree should now look like this:
It then shows another example repository, which has a .git
directory under the github.com/golang/example/
directory, but none under the github.com/user/
directory, either right below it or in the hello
package where it was initialized earlier.
My questions are:
- Should the repository have been initialized in the
hello
directory or one level up? - Should the final repository show a
.git
directory?