Golang Advanced (i)--glide user manual

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

+++
Title= "Golang Advanced (i)--glide manual"
Date= "2017-10-10"
tags=["Golang", "Glide", "Docker"]
categories=["Resource Management"]
Description= "Golang also has package management, similar to Maven,gradle,npm,bower and the like"
Featured=true
Image= "Img/201710/fengjing1.jpeg"
+++

Golang package management software has a lot of, I chose glide, because of the deep in the poison of Docker, so the way to use Docker way, do not understand the first fill Docker class

Glide's Dockerfile

Glide directly into the mirror, the base image is Golang, the two packaged into a golang of the operating environment

Dockerfile files are as follows

golang:1.8"lastsweetop@163.com"/root/app//root/app/export GOPATH=/root/app >> /root/.bashrcCMD tail -f ~/.bashrc

Docker build, glide image is made, as long as a person to do the mirror, the team of other people directly use it, more convenient Docker AH

Stack file

In addition, the command line for Docker run is too long, although only one server, as well as a stack, writes all configurations in the stack's configuration file.

version:   "3"  services:  dev:  image:  www.lastsweetop. com:  5000 /godev deploy:   Replicas:  1  resources:  limits:  cpus:  " 0.1 " memory:  50  M restart_policy:  condition:  on-failure Span class= "Hljs-symbol" >volumes: - $PWD  :/ Root/app  

This allows the local project to be combined with the container created by the glide image.

Glide operation

Start with the Chase

glide init

This produces a Glide.yaml file with the following format

package.import[]

If a new third-party package is added to the code

package cmdimport (    "github.com/spf13/cobra")var RootCmd = &cobra.Command{    Use:   "hugo",    "Hugo is a very fast static site generator",    `A Fast and Flexible Static Site Generator built with                love by spf13 and friends in Go.                Complete documentation is available at http://hugo.spf13.com`,    func(cmd *cobra.Command, args []string) {        // Do Stuff Here    },}

Actually just need

glide up

This will do, automatically installs all of your new packages, but does not appear in the Glide.yaml file, but it doesn't matter, the version uniqueness between colleagues is controlled by Glide.lock

hash:   3  bac0e5b315ed9ae09f31bfae4f77c882ce25d42ccfa70f4dc9fe0cd0bef499fupdated:  2017 -10 -09  t10:55 : 56.169042004  z  imports: -Name:github.com / Inconshreveable/mousetrap version: 76626  ae9c91c4f2a10f34cad8ce83ea42c93bb75- Name:github.com /spf13/cobra version: 50204810   fdb5010baae72e4f41b303689cbdcc9f-name:github.com /spf13/pflag Version:a9789e855c7696159b7db0db7f440b449edf2b31testimports:  []  

You need to modify the Glide.yaml file unless you need to specify a specific version of the package

Directory structure

This is a big pit, other materials are said to put in the project root directory, in fact, there is ambiguity, in fact, is placed in the Gopath src file directory of any level

This is my directory structure.

.├── README.md├── bin│   └── main├── pkg│   └── linux_amd64│       ├── lastsweetop.com│       └── vendor├── src│   ├── glide.lock│   ├── glide.yaml│   ├── lastsweetop.com│   │   ├── cmd│   │   ├── main│   │   ├── model│   │   └── tools│   └── vendor│       └── github.com└── stack-gonne.yml
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.