← 全部工具

addlicense

热度 85 更新于 开发与构建

Scan directories recursively to ensure source files have license headers

homebrewauto-collected

安装

Homebrew
brew install addlicense

通过 Homebrew 安装。

addlicense

The program ensures source code files have copyright license headers by scanning directory patterns recursively.

It modifies all source files in place and avoids adding a license header to any file that already has one.

addlicense requires go 1.16 or later.

install

go install github.com/google/addlicense@latest

usage

addlicense [flags] pattern [pattern ...]

-c copyright holder (default "Google LLC") -check check only mode: verify presence of license headers and exit with non-zero code if missing -f license file -ignore file patterns to ignore, for example: -ignore /.go -ignore vendor/ -l license type: apache, bsd, mit, mpl (default "apache") -s Include SPDX identifier in license header. Set -s=only to only include SPDX identifier. -v verbose mode: print the name of the files that are modified -y copyright year(s) (default is the current year)

The pattern argument can be provided multiple times, and may also refer to single files. Directories are processed recursively.

For example, to run addlicense across everything in the current directory and all subdirectories:

addlicense .

The -ignore flag can use any pattern supported by doublestar.

Running in a Docker Container

The simplest way to get the addlicense docker image is to pull from GitHub Container Registry:

docker pull ghcr.io/google/addlicense:latest

Alternately, you can build it from source yourself:

docker build -t ghcr.io/google/addlicense .