go build filename 用于编译, 在编译之前需要把当前工程目录(src目录的父目录) export到GOPATH go在编译文件filename的时候会自动寻找依赖,比如寻找GOPATH目录下的src下的cg目录和ipc目录 build的-x选项用于输出详细编译信息
song@ubuntu:~/gobook-src/chapter4/cgss/src$ ls -l total 12 drwxrwxr-x 2 song song 4096 Jun 25 00:26 cg -rwxrwxr-x 1 song song 2906 Jun 25 00:26 cgss.go drwxrwxr-x 2 song song 4096 Jun 25 00:26 ipc
song@ubuntu:~/gobook-src/chapter4/cgss/src$ go build -x cgss.go WORK=/tmp/go-build423507130 mkdir -p $WORK/command-line-arguments/_obj/ mkdir -p $WORK/command-line-arguments/_obj/exe/ cd /home/song/gobook-src/chapter4/cgss/src /usr/local/go/pkg/tool/linux_amd64/compile -o $WORK/command-line-arguments.a -trimpath $WORK -p main -complete -buildid 7d8322f4be13db970a7735a1c1c5429a89836db0 -D _/home/song/gobook-src/chapter4/cgss/src -I $WORK -I /home/song/gobook-src/chapter4/cgss/pkg/linux_amd64 -pack ./cgss.go cd . /usr/local/go/pkg/tool/linux_amd64/link -o $WORK/command-line-arguments/_obj/exe/a.out -L $WORK -L /home/song/gobook-src/chapter4/cgss/pkg/linux_amd64 -extld=gcc -buildmode=exe -buildid=7d8322f4be13db970a7735a1c1c5429a89836db0 $WORK/command-line-arguments.a mv $WORK/command-line-arguments/_obj/exe/a.out cgss
|
请发表评论