Go command base go run

an introduction

Used to run command source files.
Only one command source file and several library source files can be accepted as file parameters.
Its internal execution steps are: first compile the source file and then run


 
 
Two goc2p project introduction
1. Project address
2. Project description
Example project of "go concurrent programming practice"
3. Project installation
Get the project with git clone and use its root directory as a workspace
4, ds command and pds command


 
 
Three go run command combat
  1. [root@localhost ds]# cd ~
  2. [root@localhost ~]# ls |grep go
  3. go1.8.3.linux-amd64.tar.gz
  4. gobin
  5. goc2p
  6. golib
  7. goproject
  8. [root@localhost ~]# cd goc2p/src/helper/ds
  9. [root@localhost ds]# ls
  10. showds.go
  11. [root@localhost ds]# go run showds.go
  12. /root/goc2p/src/helper/ds:
  13. showds.go
  14. [root@localhost ds]# go run showds.go -p ~/goc2p/src/helper/
  15. /root/goc2p/src/helper/:
  16. ds/
  17. showds.go
  18. pds/
  19. showpds.go
The use of four commonly used go run tags


 


 
 
Five Commonly Marked Case Demonstrations
  1. [root@localhost ds]# go run showds.go
  2. /root/goc2p/src/helper/ds:
  3. showds.go
  4. [root@localhost ds]# go run -n showds.go
  5. #
  6. # command-line-arguments
  7. #
  8. mkdir -p $WORK/command-line-arguments/_obj/
  9. mkdir -p $WORK/command-line-arguments/_obj/exe/
  10. cd /root/goc2p/src/helper/ds
  11. /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
  12. cd .
  13. /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
  14. $WORK/command-line-arguments/_obj/exe/showds
  15. [root@localhost ds]# go run -x showds.go
  16. WORK=/tmp/go-build846499095
  17. mkdir -p $WORK/command-line-arguments/_obj/
  18. mkdir -p $WORK/command-line-arguments/_obj/exe/
  19. cd /root/goc2p/src/helper/ds
  20. /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
  21. cd .
  22. /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
  23. $WORK/command-line-arguments/_obj/exe/showds
  24. /root/goc2p/src/helper/ds:
  25. showds.go
  26. [root@localhost ds]# go run -v showds.go
  27. command-line-arguments
  28. /root/goc2p/src/helper/ds:
  29. showds.go
  30. [root@localhost ds]# go run -work showds.go
  31. WORK=/tmp/go-build568181490
  32. /root/goc2p/src/helper/ds:
  33. showds.go

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326942218&siteId=291194637
Go