No description
  • Go 98%
  • Shell 1.6%
  • Dockerfile 0.4%
Find a file
2023-02-03 14:41:09 -08:00
.github Prep repo for publication (#5) 2023-01-19 08:52:52 -08:00
testdata (feat): Ignore Terraform lockfile (#6) 2023-01-30 11:05:36 -08:00
.copywrite.hcl Prep repo for publication (#5) 2023-01-19 08:52:52 -08:00
.gitignore build and publish release artifacts for git tags 2021-08-09 11:23:59 -07:00
.golangci.yaml migrate CI to GitHub Actions 2021-07-27 22:11:04 -07:00
.goreleaser.yaml Update .goreleaser.yaml 2022-12-23 10:11:19 -08:00
CONTRIBUTING.md Internal links fixed 2018-12-18 22:21:14 -03:00
Dockerfile fix building docker image 2021-07-27 23:25:45 -07:00
generate-spdx-list.sh Prep repo for publication (#5) 2023-01-19 08:52:52 -08:00
go.mod Update go.mod 2022-08-16 15:18:38 -07:00
go.sum support ignoring file or directories 2021-08-09 12:52:40 -07:00
LICENSE initial import 2016-06-27 12:03:58 +01:00
main.go Mark "skipping $fileName" logs as debug-only 2023-02-01 17:43:06 -08:00
main_test.go Feat/handlebars support (#7) 2023-02-01 15:30:49 -08:00
README.md Update README.md 2023-02-03 14:41:09 -08:00
spdx.go Prep repo for publication (#5) 2023-01-19 08:52:52 -08:00
spdx_test.go Prep repo for publication (#5) 2023-01-19 08:52:52 -08:00
tmpl.go Allow copyright-only headers 2022-08-31 12:55:54 -07:00
tmpl_test.go Allow copyright-only headers 2022-08-31 12:55:54 -07:00

addlicense

This repo has moved to https://github.com/hashicorp/copywrite/tree/main/addlicense and no further contributions will show up here.


⚠️ This is an internally-maintained fork of github.com/google/addLicense. It is meant only for HashiCorp usage and is not supported.

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 (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
-ignore file patterns to ignore, for example: -ignore **/*.go -ignore vendor/**

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 .

Once you have the image, you can test that it works by running:

docker run -it ghcr.io/google/addlicense -h

Finally, to run it, mount the directory you want to scan to /src and pass the appropriate addlicense flags:

docker run -it -v ${PWD}:/src ghcr.io/google/addlicense -c "Google LLC" *.go

license

Apache 2.0

This is not an official Google product.