Go: How does go run file.go work

前端 未结 4 1752
一个人的身影
一个人的身影 2021-01-07 19:08

The commands go build and go install compile the files into binaries. Does go run compile or interpret the file? I couldn\'t find expl

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-07 19:44

    Command go run performs project's building under the hood (so yes it builds project)
    and with flag --work (go run --work main.go) you can see the location of temporary build files.

    Also in official documentation (go1.11) you can find:

    go run - compiles and runs the named main Go package.

    go build - compiles the packages named by the import paths, along with their dependencies, but it does not install the results.

    go install - compiles and installs the packages named by the import paths.

提交回复
热议问题