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