最近代码规范很烦人。要求一个函数不能超过80行。只能在git pre-commit钩子上检查下了。 这里使用golangci-lint,里面包含了funlen检查器 config.yaml
pre-commit 可以与 golangci-lint 集成,用于在每次提交代码前自动执行 Go 代码检查。 pre-commit 是一个流行的开源工具,用于在代码提交之前执行一系列检查和测试。通过集成 pre-commit 和 golangci-lint,可以在每次提交 Go 代码时自动运行静态代码检查,确保代码质量。 安装pre-commit 首先,确保系统上已经安装了 Py...
- repo: https://github.com/dnephin/pre-commit-golang rev: master hooks: - id: go-fmt - id: go-vet - id: go-lint - id: go-imports - id: go-cyclo args: [-over=15] - id: validate-toml - id: no-go-testing - id: golangci-lint - id: go-critic - id: go-unit-tests ...
ionicwang2楼
Pre-Commit-GoLang A set of git pre-commit hooks for Golang with support for multi-module monorepos, the ability to pass arguments and environment variables to all hooks, and the ability to invoke custom go tools. Requires the Pre-Commit.com Hook Management Framework. Installation You can ...
2)golang 代码格式化 pre-commit #!/bin/sh echo "DIY your git hooks @ pre-commit" run_GoFormat() { gf=`gofmt -l -w .;` if test -z "$gf" then return fi echo "$gf" ga=`git add \*\.go; ` echo "$ga" } run_GoFormat ...
我正在尝试使用 github 操作中与 golang 相关的一些挂钩运行 pre-commit.com 脚本。似乎测试环境缺少一些工具来执行 go-imports 和 golangci-lint。我已经在预提交步骤之前添加了在环境中设置所需工具的步骤,但这没有帮助。.pre-commit-config.yaml:repos:- repo: https://github.com/dnephin/pre-commit-go...
golang The hook repository must contain go source code. It will be installed viago install ./... pre-commit will create an isolatedGOPATHfor each hook and theentryshould match an executable which will get installed into theGOPATH'sbindirectory. This...
今天给大家介绍一下开发过程中,四个环境以及各自的功能特点,四个环境分别是:pro、pre、test、dev环境,中文名字:生产环境、灰度环境、测试环境、开发环境,其实大家看英文应该就差不多可以看出来对应的是什么环境。 环境介绍: pro环境:生产环境,面向外部用户的环境,连接上互联网即可访问的正式环境。
# git gofmt pre-commit hook # # To use, store as .git/hooks/pre-commit inside your repository and make sure # it has execute permissions. # # This script does not handle file names that contain spaces. gofiles=$(git diff --cached --name-only --diff-filter=ACM | grep '.go$')...