c2fdf8388205845f5e35f43d11b624361f1b53eb
Move the logic for selecting a license template based on user input into a standalone func (fetchTemplate), and add test cases for all code paths. Delay parsing predefined license templates. This allows the new fetchTemplate method to modify these templates before returning in the future (to add SPDX license information). Add tests to ensure that these templates must always parse properly. Rename copyrightData type to licenseData, since we will soon begin to add more than just copyright data here (SPDX ID). Rename prefix func to executeTemplate, since this better describes what the function is doing. These are all refactoring and cleanup changes; no behavioral changes.
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.
install
go get -u github.com/google/addlicense
usage
addlicense [flags] pattern [pattern ...]
-c copyright holder (defaults to "Google LLC")
-f custom license file (no default)
-l license type: apache, bsd, mit, mpl (defaults to "apache")
-y year (defaults to current year)
-check check only mode: verify presence of license headers and exit with non-zero code if missing
The pattern argument can be provided multiple times, and may also refer to single files.
Running in a Docker Container
- Clone the repository using
git clone https://github.com/google/addlicense.git - Build your docker container
docker build -t google/addlicense .
- Test the image
docker run -it google/addlicense -h
- Usage example
docker run -v ${PWD}:/go/src/app/ -it google/addlicense -c "Google LLC" *.go
license
Apache 2.0
This is not an official Google product.
Description
Languages
Go
94.3%
Makefile
4.3%
Dockerfile
1.4%