This is a creation in Article, where the information may have evolved or changed.
1. Golang features included
- Godeps
- Vendor
_Underline
2.Godeps
- After the golang1.1 version, with the GODEP Dependency management tool, the project under the new Godeps folder, which contains the project depends on the package, the record package depends on the file for Godeps.json, here is an example of distribution2.1 project Godeps, on GitHub . Com/docker/distribution can be directly used in the structure of the Github.com/spf13/cobra without importing, the
ImportPath following package can be directly called Deps under the package containing:
{"Importpath":"Github.com/docker/distribution","Goversion":"go1.4.2","Packages": ["./..."],"Deps": [ {"Importpath":"Github.com/adroll/goamz/aws","Rev":"AA6E716D710A0C7941CB2075CFBB9661F16D21F1"}, {"Importpath":"Github.com/adroll/goamz/cloudfront","Rev":"AA6E716D710A0C7941CB2075CFBB9661F16D21F1"}, {"Importpath":"GITHUB.COM/ADROLL/GOAMZ/S3","Rev":"AA6E716D710A0C7941CB2075CFBB9661F16D21F1"}, {"Importpath":"Github.com/azure/azure-sdk-for-go/storage","Rev":"97D9593768BBBBD316F9C055DFC5F780933CD7FC"}, {"Importpath":"Github.com/sirupsen/logrus","Comment":"v0.7.3","Rev":"55eb11d21d2a31a3cc93838241d04800f52e823d"}, {"Importpath":"Github.com/bugsnag/bugsnag-go","Comment":"v1.0.2-5-gb1d1530","Rev":"b1d153021fcd90ca3f080db36bec96dc690fb274"}, {"Importpath":"Github.com/bugsnag/osext","Rev":"0dd3f918b21bec95ace9dc86c7e70266cfc5c702"}, {"Importpath":"Github.com/bugsnag/panicwrap","Rev":"E5f9854865b9778a45169fc249e99e338d4d6f27"}, {"Importpath":"Github.com/denverdino/aliyungo/oss","Rev":"0e0f322d0a54b994dea9d32541050d177edf6aa3"}, {"Importpath":"Github.com/denverdino/aliyungo/util","Rev":"0e0f322d0a54b994dea9d32541050d177edf6aa3"}, {"Importpath":"Github.com/docker/docker/pkg/tarsum","Comment":"v1.4.1-3932-gb63ec6e","Rev":"b63ec6e4b1f6f5c77a6a74a52fcea9564538c575"}, {"Importpath":"Github.com/docker/libtrust","Rev":"Fa567046d9b14f6aa788882a950d69651d230b21"}, {"Importpath":"Github.com/garyburd/redigo/internal","Rev":"535138d7bcd717d6531c701ef5933d98b1866257"}, {"Importpath":"Github.com/garyburd/redigo/redis","Rev":"535138d7bcd717d6531c701ef5933d98b1866257"}, {"Importpath":"Github.com/gorilla/context","Rev":"14f550f51af52180c2eefed15e5fd18d63c0a64a"}, {"Importpath":"Github.com/gorilla/handlers","Rev":"60c7bfde3e33c201519a200a4507a158cc03a17b"}, {"Importpath":"Github.com/gorilla/mux","Rev":"E444E69CBD2E2E3E0749A2F3C717CEC491552BBF"}, {"Importpath":"Github.com/inconshreveable/mousetrap","Rev":"76626ae9c91c4f2a10f34cad8ce83ea42c93bb75"}, {"Importpath":"Github.com/mitchellh/mapstructure","Rev":"482a9fd5fa83e8c4e7817413b80f3eb8feec03ef"}, {"Importpath":"Github.com/ncw/swift","Rev":"CA8CBBDE50D4E12DD8AD70B1BD66589AE98EFC5C"}, {"Importpath":"Github.com/noahdesu/go-ceph/rados","Comment":"v.0.3.0-29-gb15639c","Rev":"B15639C44C05368348355229070361395D9152EE"}, {"Importpath":"Github.com/spf13/cobra","Rev":"312092086bed4968099259622145a0c9ae280064"}, {"Importpath":"Github.com/spf13/pflag","Rev":"5644820622454e71517561946e3d94b9f9db6842"}, {"Importpath":"Github.com/stevvooe/resumable","Rev":"51AD44105773CAFCBE91927F70AC68E1BF78F8B4"}, {"Importpath":"Github.com/yvasiyarov/go-metrics","Rev":"57bccd1ccd43f94bb17fdd8bf3007059b802f85e"}, {"Importpath":"Github.com/yvasiyarov/gorelic","Comment":"v0.0.6-8-ga9bba5b","Rev":"a9bba5b9ab508a086f9a12b8c51fab68478e2128"}, {"Importpath":"Github.com/yvasiyarov/newrelic_platform_go","Rev":"B21fdbd4370f3717f3bbd2bf41c223bc273068e6"}, {"Importpath":"Golang.org/x/crypto/bcrypt","Rev":"c10c31b5e94b6f7a0283272dc2bb27163dcea24b"}, {"Importpath":"Golang.org/x/crypto/blowfish","Rev":"c10c31b5e94b6f7a0283272dc2bb27163dcea24b"}, {"Importpath":"Golang.org/x/net/context","Rev":"1dfe7915deaf3f80b962c163b918868d8a6d8974"}, {"Importpath":"Gopkg.in/check.v1","Rev":"64131543e7896d5bcc6bd5a76287eb75ea96c673"}, {"Importpath":"Gopkg.in/yaml.v2","Rev":"bef53efd0c76e49e6de55ead051f886bea7e9420"} ]}
3.vendor
- golang1.5 version after adding Vendor Dependency package management tool, still in the trial phase, you need to import environment variables export go15vendorexperiment= 1, so you can directly in the writing go code when the package in the vendor directory without starting from Gopath, such as docker1.9 project, import "Github.com/docker/distribution/digest" The import is the corresponding package in the vendor directory
4. _ Underline
_The use of underscores in Golang
- One case is a placeholder, the method returns two results, and you only want one result, and the other uses _ placeholder, and if the variable is not used, the compiler will error.
- There is another case similar to import _ "FMT" This, import a package come in, but do not use, just let the package itself initialized, run the package inside the init () function, or the import package will not be error. Remember, however, that it is not necessary to call the other functions or variables within the package in this case.
Copyright NOTICE: This article is for bloggers original article, reprint please explain the source.