Thus, dep is used to obtain the private library.

  Dependency management tools, golang

Thus, dep is used to obtain the private library.

Introduction

depIs a dependency management tool. It requires 1.9 or newerGolangVersion to compile

depIt can be used safely in the production process, but it is still in the official test stage, that is, it is not yet in place.go toolChina. But I think sooner or later: =)

For guidelines and reference materials, please refer toDocument

Get private library

We often usegitThere are two ways, the first is throughssh, the second ishttps

In this paper, we usegitlab.comFor the case, create aprivatePrivate warehouse of

viasshMode

First, we need to generate it locallyssh-key, if not generated can turn rightPortal

Get what you need to usessh-keyAfter that, we opened ourgitlab.com, copy and paste into ourSettings->SSH KeysIn

图片描述

After the success of the addition, we directly inGopkg.tomlIn the configuration of our parameters

[[constraint]]
  branch = "master"
  name = "gitlab.com/eddycjy/test"
  source = "git@gitlab.com:EDDYCJY/test.git"

Before pulling resources, be careful to assume that this is your first time to use it.ssh-keyPull, need to use manually firstgit clonePull it again and agreeECDSA key fingerprint

$ git clone git@gitlab.com:EDDYCJY/test.git
Cloning into 'test'...
The authenticity of host 'gitlab.com (52.167.219.168)' can't be established.
ECDSA key fingerprint is xxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
...

Next, we are under the projectDirect executiondep ensureYou can pull it out.Down!

Problem

  1. Suppose that this is your first time and you have not performed the above step (ECDSA key fingerprint), will always be stuck
  2. The correct feedback should be that there is no error after executing the command, but if the error prompt appears, it means that the storage warehouse has not been included.dep(example:gitee)
$ dep ensure

The following issues were found in Gopkg.toml:

unable to deduce repository and source type for "xxxx": unable to read metadata: go-import metadata not found

ProjectRoot name validation failed

viahttpsMode

We are directly inGopkg.tomlIn the configuration of our parameters

[[constraint]]
  branch = "master"
  name = "gitlab.com/eddycjy/test"
  source = "https://{username}:{password}@gitlab.com"

It is mainly a revision.sourceThe configuration item for,usernameFill ingitlabThe user name of,passwordFor password

Finally back to the projectcarry outdep ensurePull resourcesJust do it

Last

depAt present, it is still an official test stage, and there may be variables.

Please be sure tosfsuperiorOriginal textSubject, ifdepThe new version is subject to change and will be revised accordingly.