Golang Glide,vendor User Guide

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

The company intends to use glide to manage the third party package, studied his use of the method, encountered some pits, so record a bit. (Environment Darwin)

Installation

Go get github.com/masterminds/glide

Initialization

Glide init (Create)

Problem:

Project Catalog:

Src$echo $GOPATH

/users/shaozhenyu/go

Src$pwd

/users/shaozhenyu/test/event/src

At this point, the internal package is put in when it is initialized, which is obviously wrong.

[info]--> Found Reference to decode

[info]--> Adding sub-package Adview to decode

[info]--> Found Reference to handle

[info]--> Found Reference to Utils/aes

[info]--> Found Reference to Utils/log/hooks/fluent

So at Init, we need to add the current directory to Gopath and then initialize it.

/users/shaozhenyu/go:/users/shaozhenyu/test/event

You can see only third-party packages.

[INFO] Generating a YAML configuration file and guessing the dependencies

[INFO] Attempting to import from the other package managers (use--skip-import to skip)

[INFO] Scanning code to look for dependencies

[info]--> Found Reference to Github.com/buaazp/fasthttprouter

[info]--> Found Reference to GITHUB.COM/TINYLIB/MSGP/MSGP

[info]--> Found Reference to Github.com/valyala/fasthttp

[info]--> Found Reference to GOPKG.IN/REDIS.V5

[info]--> Found Reference to Gopkg.in/yaml.v2

[INFO] Writing configuration file (Glide.yaml)

Next you can configure the Glide.yaml file yourself (below is the initialization of my Glide.yaml)

Package:.

Import

-package:github.com/buaazp/fasthttprouter

-package:github.com/tinylib/msgp

Subpackages:

-msgp

-package:github.com/valyala/fasthttp

-package:gopkg.in/redis.v5

-package:gopkg.in/yaml.v2

Parsing download Package dependencies

Glide Update (UP)

Glide will download the third-party package in the configuration file to the Vendor folder in the current directory.

Next you can go build. However, an error has been made.

Eventmain.go:24:2: Cannot find package "Github.com/buaazp/fasthttprouter" in any of:

/usr/local/cellar/go/1.8.3/libexec/src/github.com/buaazp/fasthttprouter (from $GOROOT)

/users/shaozhenyu/go/src/github.com/buaazp/fasthttprouter (from $GOPATH)

/users/shaozhenyu/test/event/src/github.com/buaazp/fasthttprouter

Eventmain.go:25:2: Cannot find package "github.com/valyala/fasthttp" in any of:

/usr/local/cellar/go/1.8.3/libexec/src/github.com/valyala/fasthttp (from $GOROOT)

/users/shaozhenyu/go/src/github.com/valyala/fasthttp (from $GOPATH)

/users/shaozhenyu/test/event/src/github.com/valyala/fasthttp

Google a bit, found that the problem is my directory structure is not correct, the fundamental problem is:

The vendor directory cannot be placed under the root directory ($GOPATH/src) of the workspace source package directory, and must be placed under a (project) folder.

So you need to create a new directory in SRC, and then put this project in the directory can be, want to learn more about this problem of students can see the following link:

Www.cnblogs.com/phpgo/p/6367738.html

Go build is done.

A problem was encountered during the compilation process:

Vendor/gopkg.in/redis.v5/command.go:10:2: Use of the internal package not allowed

Vendor/gopkg.in/redis.v5/ring.go:13:2: Use of the internal package not allowed

Vendor/gopkg.in/redis.v5/ring.go:14:2: Use of the internal package not allowed

Vendor/gopkg.in/redis.v5/command.go:11:2: Use of the internal package not allowed

Vendor/gopkg.in/redis.v5/command.go:12:2: Use of the internal package not allowed

By this problem wasted a lot of time, looked up a lot of information is not solved.

Finally, the ~/.glide (stored in the download of the third-party library cache) in all the deleted items, the project Glide.yaml, Glide.lock, vendor all deleted.

All over again, and then it's settled.

Glide's other commands are not available for the time being, and subsequent updates if useful.

Summarize

Glide is indeed a golang third-party package management tool that facilitates version control, and team use.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.