What does go install do?

前端 未结 2 1580
無奈伤痛
無奈伤痛 2021-01-30 15:38

The docs say nothing about what build vs install does

My expectation was that it\'s like make install; i.e. it takes the compiled

2条回答
  •  天命终不由人
    2021-01-30 16:11

    go build vs go install:

    go build just compiles the executable file and moves it to the destination. go install does a little bit more. It moves the executable file to $GOPATH/bin and caches all non-main packages which are imported to $GOPATH/pkg. The cache will be used during the next compilation provided the source did not change yet.


    A package tree after go build and go install:

    .
    ├── bin
    │   └── hello  # by go install
    └── src 
        └── hello
            ├── hello  # by go build
            └── hello.go
    

    More detailed information.

提交回复
热议问题