main.go
代码如下:
package main
import (
_ "github.com/docker/docker/pkg/discovery/file"
_ "github.com/docker/docker/pkg/discovery/kv"
_ "github.com/docker/docker/pkg/discovery/nodes"
_ "github.com/docker/swarm/discovery/token"
"github.com/docker/swarm/cli"
)
func main() {
cli.Run()
}
以下4
行代码保证相应package
的init
函数可以执行:
_ "github.com/docker/docker/pkg/discovery/file"
_ "github.com/docker/docker/pkg/discovery/kv"
_ "github.com/docker/docker/pkg/discovery/nodes"
_ "github.com/docker/swarm/discovery/token"
只有token
这个package
是swarm
新实现的,其余file
,kv
和nodes
都是docker
现有的。
cli package
利用github.com/codegangsta/cli这个project
构建CLI
程序。而cli.Run()
函数则会执行swarm
具体的command
(create
,manage
等等)。
有疑问加站长微信联系(非本文作者)