github.com/darrenli6/fabric-sdk-example@v0.0.0-20220109053535-94b13b56df8c/docs/source/Style-guides/go-style.rst (about) 1 Coding guidelines 2 ----------------- 3 4 Coding Golang 5 ~~~~~~~~~~~~~~ 6 7 We code in Go™ and strictly follow the `best 8 practices <http://golang.org/doc/effective_go.html>`__ and will not 9 accept any deviations. You must run the following tools against your Go 10 code and fix all errors and warnings: - 11 `golint <https://github.com/golang/lint>`__ - `go 12 vet <https://golang.org/cmd/vet/>`__ - 13 `goimports <https://godoc.org/golang.org/x/tools/cmd/goimports>`__ 14 15 Generating gRPC code 16 --------------------- 17 18 If you modify any ``.proto`` files, run the following command to 19 generate/update the respective ``.pb.go`` files. 20 21 :: 22 23 cd $GOPATH/src/github.com/hyperledger/fabric 24 make protos 25 26 Adding or updating Go packages 27 ------------------------------ 28 29 Hyperledger Fabric uses Govendor for package 30 management. This means that all required packages reside in the 31 ``$GOPATH/src/github.com/hyperledger/fabric/vendor`` folder. Go will use 32 packages in this folder instead of the GOPATH when the ``go install`` or 33 ``go build`` commands are executed. To manage the packages in the 34 ``vendor`` folder, we use 35 `Govendor <https://github.com/kardianos/govendor>`__, which is installed 36 in the Vagrant environment. The following commands can be used for 37 package management: 38 39 :: 40 41 # Add external packages. 42 govendor add +external 43 44 # Add a specific package. 45 govendor add github.com/kardianos/osext 46 47 # Update vendor packages. 48 govendor update +vendor 49 50 # Revert back to normal GOPATH packages. 51 govendor remove +vendor 52 53 # List package. 54 govendor list 55 56 .. Licensed under Creative Commons Attribution 4.0 International License 57 https://creativecommons.org/licenses/by/4.0/ 58