博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Go 1.4 src/pkg → src
阅读量:6232 次
发布时间:2019-06-22

本文共 3225 字,大约阅读时间需要 10 分钟。

hot3.png

Go 1.4 src/pkg → src

Russ Cox

June 2014

[If you found this document because your Go tree is not building, skip to the Updating section at the end.]

Abstract

We propose to delete the “pkg” level of the $GOROOT directory hierarchy.

Background

The structure of the main Go repo has evolved with Go.

Originally, in March 2008, there was 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 standard) library.

In July 2008, we started placing larger packages such as syscall in their own directories. Small packages stayed in single files.

In May 2009, we decided to place all packages, regardless of size, in their own directories.

In June 2009, we renamed src/lib to src/pkg, matching the name of the directory where compiled packages live. There was still a fair amount of non-Go in other src directories.

In April 2011, after a few months of discussion, we introduced $GOPATH to allow developers to 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 in the go command that makes the $GOROOT workspace different from the $GOPATH workspaces.

Proposal

We propose to move all directories in $GOROOT/src/pkg to $GOROOT/src.

Other files and directories in $GOROOT/src stay where they are.

This will make the $GOROOT workspace have same layout as the $GOPATH workspaces, which will remove special cases in the go command. It will stop confusing users who compare the two or 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 rules are adopted, code in $GOROOT/src/cmd/asm/internal can be 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 will cause churn, especially for people who have pending modifications to files in $GOROOT/src/pkg/.

On the other hand, if we are ever going to remove this irregularity, sooner is better than later. There will only be more files and more people working on them in the future.

Perhaps the best time to make this change is September 1, at the start of the Go 1.4 release freeze. There should not be many people with pending changes, and we would still have three months to shake out any possible build problems. Until September we would live with special cases in the go command, including in the support for internal packages.

Updating

Go contributors working in the main repository will need to do three things to update their trees:

1. Run “hg sync” to get the changes.

2. Look at $GOROOT/src/pkg, which is likely to be full of untracked files.

Copy those you want to keep elsewhere, and then rm -rf $GOROOT/src/pkg.

3. Code review metadata will still refer to the old files.

Reassign files in pending CLs by running “hg change ###”.

转载于:https://my.oschina.net/tsuibin/blog/482291

你可能感兴趣的文章
盒子传值
查看>>
使用NSStream来实现Socket
查看>>
iPhone开发之调用系统提示音教程
查看>>
OAuth认证协议原理分析及使用方法
查看>>
二叉树
查看>>
linux 文件搜索命令
查看>>
黄聪:登陆页优化
查看>>
黄聪:Python+NLTK自然语言处理学习(一):环境搭建
查看>>
leetcode110
查看>>
剑指Offer 10 斐波那契数列
查看>>
Ruby之基本数据类型(三)
查看>>
集合框架
查看>>
技术总结
查看>>
mysql基本操作
查看>>
redis设置最大内存上限对置换策略的解读
查看>>
IOS代码布局(一) UIView
查看>>
北大光华管理学院公开课北京站
查看>>
android 随手记 图片缓存
查看>>
HTTP请求协议中请求报文(Request Headers)跟响应报文(Response Headers)的简单理解...
查看>>
es7 class装饰器
查看>>