GitHub Actions | CircleCI |
---|---|
This is an example of a golang-based monorepo. It has the following features:
pkg
);vendor
codes.For now, CircleCI 2.1 and GitHub Actions are supported. But since it uses bash scripts and Makefiles, it should be fairly straightforward to port to TravisCI or AppVeyor, etc.
At the moment, CI is setup with GO111MODULE=on
and GOFLAGS=-mod=vendor
environment variables enabled during build. See sample dockerfile for more details.
During CI builds, build.sh iterates the updated files within the commit range (CIRCLE_COMPARE_URL
environment variable in CircleCI) or the modified files within a single commit (when the value is not a valid range), excluding hidden files, pkg
, and vendor
folders. It will then try to walk up the directory path until it can find a Makefile (excluding root Makefile). Once found, the root Makefile will include that Makefile and call the custom
rule as target, thus, initiating the build.
When the changes belong to either pkg
or vendor
, the script will then try to determine the services (and cmds) that have dependencies using the go list
command. All dependent services will then be built using the same process described above.
You can override the COMMIT_RANGE
environment variable for your own CI. If this is set, build.sh
will use its value. You also want to set CIRCLE_SHA1
to your commit SHA (CIRCLE_SHA1
is CircleCI-specific). Example for GitHub Actions is here. Something like:
# If your commit range is correct:
COMMIT_RANGE: aaaaa..bbbbb
CIRCLE_SHA1: aaaaa
# If no valid commit range:
COMMIT_RANGE: <your_commit_sha>
CIRCLE_SHA1: <your_commit_sha>
services/
- Basically, long running services.cmd/
- CLI-based tools that are not long running.pkg/
- Shared codes, or libraries common across the repo.vendor/
- Third party codes from different vendors.Although we have this structure, there is no limitation into where should you put your services/cmds. Any subdirectory structure is fine as long as a Makefile is provided.
A reference template named samplesvc is provided. Basically, these are the things that you need to do:
services/
or tool under cmd/
. You may copy the samplesvc contents to your new directory.pkg
and vendor
directories).MODULE
variable with your service name. The only required rule is the custom
part so you may need to change that as well (i.e. name of the dockerfile used in docker build
).PR's are welcome!
go test ...
for pkg/
when Makefile is rootvendor
folder as wellgolang golang 格式的 chaincode。
gosql 是一款 golang style 语法的 golang orm 库。 优雅的语法,支持批量插入; 轻松嵌套条件,处理各种复杂的查询 sql,诸如:and 和 or 组合; 全语法支持:for update 锁、is null、exists 子查询等基本上所有 sql 语法 特xing Golang-style SQL builder go语言风格sql生成 Unlimited nest
html2article — 基于文本密度的html2article实现[golang] Install go get -u -v github.com/sundy-li/html2article Performance avg 3.2ms per article, accuracy >= 98% (对比其他开源实现,可能是目前最快的html2article实现,我们测试的数据集约3kw来自于微信
Libretto 是一个 Golang 库,可在任何云和虚拟机托管平台(如 AWS,Azure,OpenStack,vSphere 或VirtualBox)上创建虚拟机(VM)。 可在下列平台部署 AWS Azure DigitalOcean Exoscale Google Cloud Platform Openstack (Mirantis) Virtualbox >= 4.3.30 VMwar
Gos 自称为 “Armed Golang(加强版的 Go)”,定位是原生 go 命令的一个“加强版”解决方案。 据官方介绍可以使用 gos 代替 go: go get => gos getgo build => gos buildgo run => gos rungo ... => gos ... 因为 gos 兼容所有的 go 命令,并且还额外增加了搭载智能 GOPROXY 的 go mod/
Go 语言实现 API 网关基础功能。(主要看重 Go 并发处理能力) 获取代码 go get -u github.com/wisrc/gateway 日志框架使用了 golang.org/x/sys 中的包,如果出现下载这个包超时的情况,请到 github.com/golang/sys 中下载,然后将 github.com/golang/sys 重命名为 golang.org/x/sys 配置介
一个golang并行编程库,用于业务聚合或重构。可以用最少的代码,将串行的函数调用并行化,无需改变函数的声明。 实现原理和demo参考github地址:https://github.com/buptmiao/parallel 使用: 以下有三种方法:testjoba,testjobb,testjobc执行并行: import ( "github.com/buptmiao/parallel")
Leaps 是一个用go语言实现的、用来协作开发的命令行工具。使用它可以通过http来编辑你本地的文件。