Thanks to visit codestin.com
Credit goes to hub.docker.com

hedzr/bgo

By hedzr

Updated 9 months ago

To make go building easier

Image
0

407

hedzr/bgo repository overview

hedzr/bgo

Go GitHub tag (latest SemVer) Docker Pulls Docker Image Version (latest semver) Docker Image Size (latest semver)

bgo provides a super easy way to build your go apps. All things you need to do is entering the golang project directory and entering bgo and pressing Enter.

powered by cmdr.

tip-for-bgo

Features

bgo makes your golang building life easier, it's an efficent and extensible build tool.

  • Run go building with or without a config file .bgo.yml

  • Scan the directory to grab all main packages and initial .bgo.yml

  • While

    • you have lots of small cli apps in many sub-directories
    • one project wants go1.18beta1 and others stays in go1.17
    • too much -tags, -ldflags, -asmflags, ...
    • multiple targets, cross compiling
    • etc.

    have a try bgo.

History

  • v0.3.3 (WIP)

    • fix: bugs
    • fea: Aliases definitions in primary config directory can be merged into bgo command system now
      • fea: check-code-qualities alias command added and play gofmt, golint and golint at once.
      • fea: Extend bgo command system with Aliases definitions.
    • fea: bgo init -o bgo.{yml,yaml,json,toml} writes different config file formats with giving suffix
    • fix: TargetPlatforms.FilterBy not very ok
    • imp: added cmdr global pre-action: verbose info for debugging
    • CHANGE: .bgo.yml is loaded as an alternative config file now
    • CHANGE: $HOME/.bgo and conf.d subdirectory is primary config files now
    • CHANGE: primary config files will be distributed with binary executable
  • v0.3.0

    • fix: init not work
    • fix: zsh completion file not fully written
  • v0.2.17 and older

    • pre-releases

Getting Started

Install

Download the prebuilt binaries from Release page.

Or Built from source code:

git clone http://github.com/hedzr/bgo.git
cd bgo
go run . -s

go run . -s will run bgo from source code and install itself to ~/go/bin/.

image-20220130101919648

You could run bgo via docker way:

docker pull hedzr/bgo
# or
docker pull ghcr.io/hedzr/bgo:latest

And run it:

docker run -it --rm -v $PWD:/app -v /tmp:/tmp -v /tmp/go-pkg:/go/pkg hedzr/bgo

For macOS/Linux, there is a brew formula:

brew install hedzr/brew/bgo
Run directly

To work without .bgo.yml, simply go into a folder and run bgo, the cli apps under the folder will be found out and built.

cd my-projects
bgo

image-20220128104835837

Filter the target systems by -for OS/ARCH, -os OS and -arch ARCH:

bgo --for linux/386 -for linux/amd64,darwin/arm64
bgo -os linux -arch 386 -arch amd64 -arch arm64

Both long and short options are available for for, os and arch.

Run with .bgo.yml
Create .bgo.yml at first
cd my-projects
bgo init  # create bgo.yml by scanning
mv bgo.yml .bgo.yml # rename it
Tune .bgo.yml

See sample of .bgo.yml

.bgo.yml

Run
bgo

bgo will load projects from .bgo.yml and build them

Scopes
  1. bgo -s: short mode - this will build first project with current GOOS/GOARCH.
  2. bgo|bgo -a: auto mode - build projects in .bgo.yml
  3. bgo -f: full mode - build by scanning current directory
Using shell auto-completion

Run bgo gen sh --zsh to install auto-completion script to the proper location and enable the feature:

image-20220130092618399

Run bgo gen sh --bash -o=bgo.bash to get bash completions script and put it to the right location. Generally it should be:

bgo generate shell --bash -o=bgo.bash
mv bgo.bash /etc/bash-completion.d/bgo

Nothing needs to do if installed via brew (since v0.3.3+).

Inspired By:

LICENSE

Apache 2.0

Tag summary

Content type

Image

Digest

sha256:836373d36

Size

82.1 MB

Last updated

9 months ago

Requires Docker Desktop 4.37.1 or later.