addlicense

package module
v1.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 2, 2023 License: Apache-2.0 Imports: 16 Imported by: 1

README

addlicense

⚠ 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.

Documentation

Overview

This program ensures source code files have copyright license headers. See usage with "addlicense -h".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(
	ignorePatternList []string,
	spdx spdxFlag,
	license LicenseData,
	licenseFileOverride string,
	verbose bool,
	checkonly bool,
	patterns []string,
	logger *log.Logger,
) error

Run executes addLicense with supplied variables

func ValidSPDX

func ValidSPDX(id string) bool

Types

type LicenseData

type LicenseData struct {
	Year   string // Copyright year(s).
	Holder string // Name of the copyright holder.
	SPDXID string // SPDX Identifier
}

LicenseData specifies the data used to fill out a license template.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL