Skip to content

Instantly share code, notes, and snippets.

@alexniver
Last active November 24, 2015 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexniver/059e25b5f36c3c511626 to your computer and use it in GitHub Desktop.
Save alexniver/059e25b5f36c3c511626 to your computer and use it in GitHub Desktop.

假设~/golang/helloworld目录下有helloworld.go文件

cd ~/golang/helloworld
docker run -it --rm -v $(pwd):/go -u 1000:1000 golang:latest go build -o HelloWorld.out

使用golang的最新版本docker镜象, 编译本地文件夹的helloworld.go, 生成可执行文件属于用户id为1000, 组id为1000的user. 生成的可执行文件叫HelloWorld.out. 命令执行完毕之后, 自动删除continer

以上命令不需要本机安装任何go环境, 便可以在本地生成可执行文件, 同理, 在不安装任何java环境的情况下, 也可以构建java代码. 再同理, 可以构建任意golang版本或java版本的代码.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment