Build Go project with GB

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

GB Introduction

    • site:https://getgb.io/
    • Github:https://github.com/constabula ...

Homepage Introduction
A project based build tool for the Go programming language.

So GB is a build tool that relies on the management plug-in to complete the Gb-vendor
Doc

Why use GB, the favorite point is Project based workflow based on project
Bashd, notGOPATH bashd

The project does not need to be GOPATH under

Project structure

Two important directories

    • $ project/src/our own code of business
    • $ project/vendor/src/third-party dependence in this

For example, a named redeem project, project structure

.├── README.md├── bin│   └── redeem├── src│   └── redeem│       └── main.go└── vendor    ├── manifest    └── src        ├── github.com        └── gopkg.in

Use GB vendor to process dependencies, such as

$ gb vendor fetch github.com/urfave/cli

Gitlab CI

It's also easy to build in Gopath using go build, I'm Gitlab ci
That's how it's handled.

The build project on Gitlab CI usesimage: golang:latest
The GB tool is not installed and can be used directlygo build

Only need to put the dependency on /vendor/src src/redeem/vendor , Gopath set the
GOPATH: $CI_PROJECT_DIR

such as before_script: part

  Image:golang:latestvariables:GOPATH: $CI _project_dirbefore_script:-MV vendor/src/* src/redeem/vendor/- CD src/redeemstages:-test-buildformat:stage:test script:-Go FMT $ (go list./... | grep-v/vendo    r/)-Go vet $ (go list./... | grep-v/vendor/)-Go test-race $ (go list .../... | grep-v/vendor/) Compile: Stage:build script:-Goos=darwin goarch=amd64 go build-o $CI _project_dir/redeem_mac-goos=windows GOARCH= AMD64 go build-o $CI _project_dir/redeem_win artifacts:paths:-Redeem_mac-redeem_win  

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.