我正在尝试使用构建一个简单的 golang 程序 go-dockerclient
package main
import (
docker "github.com/fsouza/go-dockerclient"
)
func main () {
h := &docker.HostConfig {
Memory: 4194304,
MemorySwap: -1,
CPUShares: 5,
NetworkMode: "host",
}
client, err := docker.NewClient("unix:///var/run/docker.sock")
config := &docker.Config {
Env: ["FOO=foo"],
Image: "redis",
}
opts := docker.CreateContainerOptions {
Config: config,
HostConfig: hostConfig,
}
container, _ := client.CreateContainer(opts)
err = client.StartContainer(container.ID)
}
这给了我:
:~/gosrc/src/github.com/achanda$ go build
# github.com/achanda
./main.go:16: syntax error: unexpected comma
./main.go:22: non-declaration statement outside function body
./main.go:23: non-declaration statement outside function body
./main.go:24: non-declaration statement outside function body
./main.go:25: syntax error: unexpected }
我似乎没有发现语法有什么问题(虽然这确实是个菜鸟)。问题是什么?
繁花不似锦
相关分类