This is a creation in Article, where the information may have evolved or changed.
Go 1.4 src/pkg→src
Russ Cox
June
[If you found this document because your Go tree are not building, skip to the Updating sections at the end.]
Abstract
We propose to delete the ' pkg ' level of the $GOROOT directory hierarchy.
Background
The structure of the main go repo have evolved with go.
originally, in March, there is a src/lib directory containing Fmt.go and sys.go, for package FMT and package sys . The rest of the repo held the Go compiler and other support tools. Src/lib was the (eventually) library.
in July, we started placing larger packages such as Syscall in their own directories. Small packages stayed in single files.
In could , we decided to place all packages, regardless of size, in their own directories.
in June, we renamed Src/lib to src/pkg, matching the name of the directory where compiled packages live. There is still a fair amount of non-go in other src directories.
in April, after a few months of discussion, we introduced $GOPATH-to-allow developers-work on code outside the Standard tree. The form of a $GOPATH directory mimics the main repo, but because it's all Go, we shortened src/pkg to SRC. The extra "pkg" element is a special case with the GO command that makes the $GOROOT workspace different from the $GOPATH wo Rkspaces.
Proposal
We propose to move all directories in $GOROOT/src/pkg to $GOROOT/src.
Other files and directories in $GOROOT/SRC stay where they is.
This would make the $GOROOT workspace has same layout as the $GOPATH workspaces, which'll remove special cases in th E go command. It would stop confusing users who compare the the and try to set up their $GOPATH like $GOROOT.
it also gives an import path for internal packages built as part of commands. For example, assuming that the internal packages rules is adopted, code in $GOROOT/src/cmd/asm/internal can is imported using
Import "Cmd/asm/internal"
It also simplifies the rules needed for internal packages. Without moving the library, the internal packages proposal needs a special rule to ignore pkg, or else $GOROOT/src/cmd/. . Code cannot import Code-from $GOROOT/src/pkg/internal/.
Implementation
This would cause churn, especially for people who has pending modifications to the files in $GOROOT/src/pkg/.
On the other hand, if we were ever going to remove this irregularity, sooner is better than. There would is more than files and more people working on them in the future.
Perhaps the best time-of-the-September 1, at the start of the Go 1.4 release freeze. There should not being many people with pending changes, and we would still has three months to shake off any possible build Problems. Until September we would live with special cases on the GO command, including in the support for internal packages.
Updating
Go Contributors working in the main repository would need to does three things to update their trees:
1. Run "Hg sync" to get the changes.
2. Look at $GOROOT/src/pkg, which are likely to being full of untracked files.
Copy those want to keep elsewhere, and then Rm-rf $GOROOT/src/pkg.
3. Code Review metadata would still refer to the old files.
reassign files in pending CLs by running "HG Change # # #".