GB (one)

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

GB Go Language Project-based compilation tool

1. Installation

1.1 Constraints

GB dependent Go1.4 or later

1.2 Installation

Install with the following command

go get github.com/constabulary/gb...

1.3 Upgrade

GB is still in development, upgrade to the latest version with the following command

go get -u github.com/constabulary/gb/...

1.4 Multi-Version go scenarios

Install GB for each go version

1.5 Note

The GB command after installation conflicts with the shorthand command for the OH-MY-ZSH configuration git branch , using ~/.ZSHRC

unalias gb

To block

2. Project

GB is based on the project. A GB project for a compilation unit, each GB of the project directory contains a src/ subdirectory, no configuration file settings, the following documents we collectively refer to the directory of the project as$PROJECT

2.1 Own code, third-party code

GB projects differentiate between their own code and dependent third-party code. GB project, your own code is placed within the

$PROJECT/src/

The third-party code is placed in

$PROJECT/vendor/src/

2.2 Items are not configured under $gopath

GB projects are not $GOPATH related,
GB will not be used go get to download management dependencies; Dependent third-party library code should be placed in the $PROJECT/vendor/src/ directory
GB projects can also be used go get to get, but cannot be go tools built by tools, because GB projects do not follow go get the conventions

2.3 Creating a Project

Creating a GB project is also creating a normal file directory:

% mkdir -p $HOME/code/demo-project

This directory will be the root of the GB project and now create src/ subdirectories to hold your own project code:

% mkdir -p $PROJECT/src% tree $PROJECT/home/dfc/code/demo-project└── src

2.4 Creating a Package

Note: GB does not compile $PROJECT/src/ the code, and does not compile the code under the root directory, you must put the code in a package, let us create a packet:

% mkdir -p $PROJECT/src/hello% tree $PROJECT/home/dfc/code/demo-project└── src    └── hello        └── hello.go

Let's take a look at the Hello.go file:

package main import "fmt" func main() {    fmt.Println("Hello gb")}

2.5 Compiling

Note: Use GB's own compile command:

% gb build allhello% bin/helloHello gb% tree $PROJECT/home/dfc/code/demo-project├── bin    └── hello└── src    └── hello        └── hello.go

2.6 Version Control

Note: Generally do not submit $PROJECT/pkg and $PROJECT/bin under the content, only submit $PROJECT/src/ under the code

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.