Go use GVM and glide to create management engineering

Source: Internet
Author: User
Go use GVM and glide to create management engineering

With GVM and glide installed, here's how to create go works, according to the Glide official documentation, the proposed project directory structure is as follows:

-$GOPATH/src/myproject (Your project)
  | | Glide.yaml
  | glide.lock
  |-main.go (Your main Go code can live h ere) | |-
  mysubpackage (you can create your own subpackages, too)
  |    | --foo.go
       | | vendor |--...
Create and set Gopath
$ cd ~
$ mkdir Workspace
$ export Gopath=~/workspace
Create a project directory
$ cd $GOPATH
$ mkdir-p src/myproject
Initialization of the project
$ glide Create
Add dependencies

Edit Glide.yaml file, add Yaml dependencies

Package:.
Import:
-Package:gopkg.in/yaml.v2
Installation dependencies
$ Glide Install
Engineering Main program Main.go
Package main

Import (
        "FMT"
        "Log"
        "Gopkg.in/yaml.v2"
)

var data = '
a:easy!
B:
  c:2
  D: [3, 4]
'

type T struct {
        A string
        B struct {
                renamedc int   ' YAML: ' C ' ' C16/>d        []int ' Yaml:, Flow '
        }
}

func main () {
        T: = t{}

        Err: = Yaml. Unmarshal ([]byte (data), &t)
        If err!= nil {
                log. Fatalf ("Error:%v", err)
        }
        fmt. PRINTF ("---t:\n%v\n\n", t)

        D, err: = Yaml. Marshal (&t)
        If err!= nil {
                log. Fatalf ("Error:%v", err)
        }
        fmt. PRINTF ("---t dump:\n%s\n\n", string (d))
}
Compiling engineering
$ cd $GOPATH/src/myproject
$ go Build
Run Tests
$ cd $GOPATH/src/myproject
$/myproject
View Dependencies
$ cd $GOPATH/src/myproject
$ glide list
installed packages:
    gopkg.in/yaml.v2

Reprint please indicate this link form link
This article link: http://blog.csdn.net/kongxx/article/details/52942261

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.