一 简介
用于运行命令源码文件。
只能接受一个命令源码文件以及若干个库源码文件作为文件参数。
其内部执行步骤是:先编译源码文件再运行
二 goc2p项目介绍
1、项目地址
2、项目说明
《go并发编程实战》的示例项目
3、项目安装
用git clone获取项目,并将其根目录作为一个工作区
4、ds命令和pds命令
三 go run命令实战
[[email protected] ds]# cd ~
[[email protected] ~]# ls |grep go
go1.8.3.linux-amd64.tar.gz
gobin
goc2p
golib
goproject
[[email protected] ~]# cd goc2p/src/helper/ds
[[email protected] ds]# ls
showds.go
[[email protected] ds]# go run showds.go
/root/goc2p/src/helper/ds:
showds.go
[[email protected] ds]# go run showds.go -p ~/goc2p/src/helper/
/root/goc2p/src/helper/:
ds/
showds.go
pds/
showpds.go
四 go run常用标记的使用
五 常用标记案例演示
[[email protected] ds]# go run showds.go
/root/goc2p/src/helper/ds:
showds.go
[[email protected] ds]# go run -n showds.go
#
# command-line-arguments
#
mkdir -p $WORK/command-line-arguments/_obj/
mkdir -p $WORK/command-line-arguments/_obj/exe/
cd /root/goc2p/src/helper/ds
/usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/command-line-arguments.a -trimpath $WORK -p main -complete -buildid 8060af8f0adc5e810678187f90009efa4132850d-D _/root/goc2p/src/helper/ds -I $WORK -pack ./showds.go
cd .
/usr/local/go/pkg/tool/linux_amd64/link -o $WORK/command-line-arguments/_obj/exe/showds -L $WORK -w -extld=gcc -buildmode=exe -buildid=8060af8f0adc5e810678187f90009efa4132850d $WORK/command-line-arguments.a
$WORK/command-line-arguments/_obj/exe/showds
[[email protected] ds]# go run -x showds.go
WORK=/tmp/go-build846499095
mkdir -p $WORK/command-line-arguments/_obj/
mkdir -p $WORK/command-line-arguments/_obj/exe/
cd /root/goc2p/src/helper/ds
/usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/command-line-arguments.a -trimpath $WORK -p main -complete -buildid 8060af8f0adc5e810678187f90009efa4132850d-D _/root/goc2p/src/helper/ds -I $WORK -pack ./showds.go
cd .
/usr/local/go/pkg/tool/linux_amd64/link -o $WORK/command-line-arguments/_obj/exe/showds -L $WORK -w -extld=gcc -buildmode=exe -buildid=8060af8f0adc5e810678187f90009efa4132850d $WORK/command-line-arguments.a
$WORK/command-line-arguments/_obj/exe/showds
/root/goc2p/src/helper/ds:
showds.go
[[email protected] ds]# go run -v showds.go
command-line-arguments
/root/goc2p/src/helper/ds:
showds.go
[[email protected] ds]# go run -work showds.go
WORK=/tmp/go-build568181490
/root/goc2p/src/helper/ds:
showds.go
请发表评论