内容简介:什么是 custom import path?就是例如第一行,就是 custom import path。因为目前
什么是 custom import path?就是 package
后面的注释,注释的内容是 // import xxxx
。这就是传说中的 custom import path。
例如 Docker
中的 代码
:
package daemon // import "github.com/docker/docker/daemon"
import (
swarmtypes "github.com/docker/docker/api/types/swarm"
"github.com/sirupsen/logrus"
)
// SetContainerConfigReferences sets the container config references needed
func (daemon *Daemon) SetContainerConfigReferences(name string, refs []*swarmtypes.ConfigReference) error {
if !configsSupported() && len(refs) > 0 {
logrus.Warn("configs are not supported on this platform")
return nil
}
c, err := daemon.GetContainer(name)
if err != nil {
return err
}
c.ConfigReferences = append(c.ConfigReferences, refs...)
return nil
}
第一行,就是 custom import path。因为目前 github.com/docker/docker
已经重命名为了 github.com/moby/moby
。所以如果
想愉快的补全代码或者是用IDE分析代码,正确的做法是,拷贝代码到本地,然后把 moby/moby
的路径改成 docker/docker
。
custom import path的出现就是为了防止仓库名发生改变之后,无法导入,然后制定的一种方案。好了,到了吐槽时间,这确实是属于 Go的设计不合理的地方之一。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网
猜你喜欢:本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Pattern Recognition and Machine Learning
Christopher Bishop / Springer / 2007-10-1 / USD 94.95
The dramatic growth in practical applications for machine learning over the last ten years has been accompanied by many important developments in the underlying algorithms and techniques. For example,......一起来看看 《Pattern Recognition and Machine Learning》 这本书的介绍吧!