Description
Faster builds (by defaulting to go install except for main packages, and by running concurrent go install commands when the dependency tree allows) Faster testing (by caching test results and not retesting except when necessary) Faster linting (by caching lint results from gometalinter) Did I mention fast! Automatically runs go generate if its dependency calculation determines it's required Operates on all packages in a repository (by default) with intelligent support for vendored packages Can complement other build tools like make Does not interfere with tools like govendor or gb
zb alternatives and similar packages
Based on the "Go Tools" category.
Alternatively, view zb alternatives based on common mentions on social networks and blogs.
-
The Go Play Space
Advanced Go Playground frontend written in Go, with syntax highlighting, turtle graphics mode, and more -
Sonic
Sonic is a Go library for network and I/O programming that provides developers with a consistent asynchronous model, with a focus on achieving the lowest possible latency and jitter in Go. -
typex
[TOOL/CLI] - Filter and examine Go type structures, interfaces and their transitive dependencies and relationships. Export structural types as TypeScript value object or bare type representations. -
Viney's go-cache
A flexible multi-layer Go caching library to deal with in-memory and shared cache by adopting Cache-Aside pattern. -
gothanks
GoThanks automatically stars Go's official repository and your go.mod github dependencies, providing a simple way to say thanks to the maintainers of the modules you use and the contributors of Go itself. -
go-lock
go-lock is a lock library implementing read-write mutex and read-write trylock without starvation -
goroutines
It is an efficient, flexible, and lightweight goroutine pool. It provides an easy way to deal with concurrent tasks with limited resource. -
PDF to Image Converter Using Golang
This project will help you to convert PDF file to IMAGE using golang. -
go-james
DISCONTINUED. James is your butler and helps you to create, build, debug, test and run your Go projects -
docs
Automatically generate RESTful API documentation for GO projects - aligned with Open API Specification standard -
rescached
DISCONTINUED. [mirror] Resolver (DNS) cache daemon. See https://sr.ht/~shulhan/rescached [Moved to: https://github.com/shuLhan/rescached] -
Goenv
DISCONTINUED. ๐บ Manage Your Applications Go Environment. [Moved to: https://github.com/Clivern/Goenv] -
modver
Compare two versions of a Go module to check the version-number change required (major, minor, or patchlevel), according to semver rules. -
channelize
A websocket framework to manage outbound streams. Allowing to have multiple channels per connection that includes public and private channels. -
IP2Location.io Command Line
IP2Location.io command line to query IP geolocation data from IP2Location.io API
SaaSHub - Software Alternatives and Reviews
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of zb or a related project?
README
zb โ an opinionated repo based tool for linting, testing and building go source
โโโโโโโโโโโโโโโ โโโโโโโ โโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโ โโโโโ โโโโโโโโ โโโ โโโโโโ โโโโโโโโโ โโโโโโโโ โโโ โโโ โโโโโ โโโโโโโโ โโโ โโโโโโ โโโโโโโโโ โโโโโโโโ โโโ โโโ โโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โโโ โโโ โโโโโโโโโโโโโโโ โโโโโโโ โโโโโโโ โโโโโโโโโโโโโโโโ โโโ โโโ
Benefits
- Faster builds (by defaulting to
go install
except formain
packages, and by running concurrentgo install
commands when the dependency tree allows) - Faster testing (by caching test results and not retesting except when necessary)
- Faster linting (by caching lint results from
gometalinter
) - Did I mention fast!
- Automatically runs
go generate
if its dependency calculation determines it's required - Operates on all packages in a repository (by default) with intelligent support for vendored packages
- Can complement other build tools like
make
- Does not interfere with tools like
govendor
orgb
Installation
Simply run go get jrubin.io/zb
Rationale
Many go repositories have multiple packages. It is often necessary to build/install, test, lint, etc. across all packages within the repository. Go "ellipsis" wildcards (...
) can be used to select all subdirectories of a given repository, but don't exclude vendored packages which makes running tests and linting complicated. Some operations should be aware of vendored packages (e.g. build/install), while others should ignore them (e.g. lint). Yet others need to be aware of changes in vendored packages, but should not operate directly on them (e.g. test). Traditional build tools, like make
, can be used to supplement the go
command to work only on the intended packages. Building dependency lists for make targets, which are required, for example, to dynamically identify modified .go
files and what would need to be rebuilt as a result, is at the very least complicated (consider .go
files modified outside the repo) and at best slow.
zb
fixes all of this
Packages โ Repositories
zb
is aware of the directory it is called from. If any of its commands is called without a package argument, it will use the current working directory.
zb
can also be passed packages just like the go
command. Both package names (e.g. fmt
, jrubin.io/zb
) and relative package names (e.g. ./jrubin.io/zb
) are supported, as are ellipsis (...
).
zb
will identify the repository associated with each package by locating the directory and walking up the directory tree to find the repository directory (containing .git
[only git
is supported at present]). It will then execute the command for all packages in each repository it identified.
go generate
go generate
is great, but sometimes it needs to be executed before a build. Forgetting to execute go generate
can be a major problem if, for example, new values were added to a stringer
.
zb
does its own dependency calculation and can identify go generate
dependencies provided an additional annotation is also present.
The following formats are available to define dependencies of go generate
zb:generate
formats
//zb:generate glob glob...
Causesgo generate
to be executed on the go file with the annotation if the go file itself is newer than the files expanded from the globs. This is useful with commands like stringer://go:generate stringer -type=YourType //zb:generate yourtype_string.go
//zb:generate -patsubst %pattern %replacement glob glob...
Works likemake
's patsubst. Causesgo generate
to be executed on the go file with the annotation if any of the files expanded from the globs is newer than any of the filenames generated through the pattern substitution.//go:generate make proto //zb:generate -patsubst %.proto %.pb.go *.proto
This command first matches all files matching
*.proto
and then performs the substitution by extracting the part of each of those file names before.proto
(identified with the%
in%.proto
) and taking that extracted pattern and inserting it into the%
part of%.pb.go
.So if there were files
message.proto
andtypes.proto
,go generate
would be executed if either of those files were newer thanmessage.pb.go
ortypes.pb.go
(including if the.pb.go
files did not yet exist).//zb:generate -target file glob glob...
Basically a simplified-patsubst
. Causesgo generate
to be executed if any of the files expanded from the globs is newer thanfile
Can also be written as//zb:generate -patsubst % file glob glob...
Commands
install
Initially, zb install
appears to do the same things as go install
(just for all packages in the repositories). In fact, zb install
just calls go install
under the hood and supports all of its flags. There are a few differences though.
go generate
may be called before building the package according to the//go:generate
and//zb:generate
annotationsmain
packages (commands) are built with extra linker flags that causemain.gitCommit
andmain.buildDate
variables to be set if they exist. Seezb/main.go
as an example of how to utilize this.- Executes
go install
for each stale package it finds and will execute concurrentgo install
processes when the dependency tree allows. Concurrency can be limited with$GOMAXPROCS
. - If any of the non-vendored
.go
files in the repository containTODO
orFIXME
these lines will be emitted to the console as warnings (unless the global-n
flag is enabled).
build
zb build
differs from go build
in that non main
packages will be installed with go install
. Commands, however, will not be installed (to $GOPATH/bin
), they are built with the binary being placed in the root of the repository tree. If there is already a directory in the root of the repository with the same name as the command, the command will be placed in that directory instead.
Otherwise, zb build
is identical to zb install
.
lint
Delegates functionality to gometalinter
but with more useful defaults and caching of results.
- The
--concurrency, -j
flag is dynamically calculated to be1
less than half the number of CPU cores (but at least1
) [gometalinter
default is16
] --tests
is enabled by default--deadline
is set to30s
[gometalinter
default is5s
]--enable-gc
is enabled by defaultalighcheck
,dupl
,gocyclo
andstructcheck
are disabled by defaulterrcheck
,gofmt
,goimports
andunused
are enabled (in addition to all other default enabled checkers) by default
The -n
flag can be used to hide golint
warnings about missing comments.
Since dependency calculation can sometimes add a non-trivial amount of time to the zb lint
command, go generate
will not be executed.
Files matching certain suffixes will be excluded from the results. This list can be modified with the --ignore-suffix
flag. By default files with the following suffixes will be excluded:
.pb.go
.pb.gw.go
_string.go
bindata.go
bindata_assetfs.go
static.go
All other gometalinter
flags will be honored as defined.
test
Delegates functionality to go test
but caches the results (like gt
).
Honors all other flags just like go test
except those intended to be passed directly to the test binary.
Use the -f
flag to treat the test results as uncached, forcing the tests to be executed (and cached) again.
To see which tests would be executed (because their results are not-cached or the -f
flag was provided), use the -l
flag.
Since dependency calculation can sometimes add a non-trivial amount of time to the zb test
command, go generate
will not be executed.
complete
zb
has full support for shell autocompletion in both bash
and zsh
.
Simply execute eval "$(zb complete)"
(or put in your init files) to enable.
clean
Removes the executables produced by zb build
commands
Lists the absolute paths where each of the commands (from main
packages) will be placed with zb build
list
Similar to go list
(and takes the same flags) but will list all of the packages in each of the repositories. Use the --vendor
flag to exclude vendored packages.
help
zb
contains a built-in, comprehensive help system. Running zb
by itself (or with the -h
or --help
flags) will list the commands and global flags. zb help <command>
, zb <command> -h
and zb <command> --help
will show contextual help for the given command.
Global Flags
--log-level, -l, $LOG_LEVEL
Defaults to info
. Available levels are:
error
warn
info
debug
--no-warn-todo-fixme, -n, $NO_WARN_TODO_FIXME
Do not warn when finding WARN or FIXME in .go
files
--cache, $CACHE
Modify the base directory used for storing results of commands that cache their results (test
and lint
).
Defaults to $HOME/Library/Caches/zb
on mac and $HOME/.cache/zb
elsewhere.
--package, -p
Causes zb
to execute only on the explicitly listed packages and not on all packages in their repositories.