go mod vendor test

go modYou can make the project independent from the mandatory dependencies GOPATH out, that is no longer dependent on your project needs to be placed in GOPATH below, and each project dependencies, the current version of the project can be managed independently!

mod operation records

  1. export GO111MODULE=on

  2. go mod init github.com/mutex73/ga

    Increased reliance can manually go.uber.org/atomic v1.4.0or let go automatically discover and maintain the following build will automatically find dependencies

  3. go build src/practice/mod/vendor_test.go

    vendor_test.go document adds import "go.uber.org/zap" statement, IDE prompts an error, dependencies recorded in go.mod executed after build

    module github.com/mutex73/ga
    
    go 1.12
    
    require (
        go.uber.org/atomic v1.4.0 // indirect
    	go.uber.org/multierr v1.1.0 // indirect
        go.uber.org/zap v1.10.0
    )
    
  4. go mod download

    Dependencies are automatically downloaded to $GOPATH/pkg/modmultiple projects can be shared cache mod
    Here Insert Picture Description

  5. go mod vendor

    Copied from mod project into vendorthe directory, so that the IDE can be identified!

Published 27 original articles · won praise 2 · views 50000 +

Guess you like

Origin blog.csdn.net/jackgo73/article/details/94337347