π Golic
A declarative tool for injecting and managing license headers in source code.
Golic automates the tedious task of ensuring every source file in your project has the correct license header. Itβs built for developers who want a "set it and forget it" solution for compliance.
# Preview changes before applying
golic inject -c="2026 MyCompany ltd." --dry
π₯ Installation
Install the binary using Go 1.16+:
go install github.com/Bugs5382/golic/cmd/golic@latest
golic version
βοΈ Configuration
Golic relies on two small files in your project root to define what to license and how to format it.
1. .licignore
Determines which files Golic should touch. It uses standard .gitignore syntax.
Pro Tip: Use "inverse rules" to be safe. Deny everything by default, then allow specific files:
# .licignore
# 1. Ignore everything
*
# 2. Allow specific files/patterns
!Dockerfile*
!Makefile
!*.go
# 3. Allow subdirectories
!*/
2. .golic.yaml
Contains license text and formatting rules. Golic merges your local file with its embedded master configuration by default.
# .golic.yaml
golic:
licenses:
apacheX: |
Copyright MyCompany
License details go here...
rules:
"*.go.txt":
prefix: "/*"
suffix: "*/"
"technitium/**/*.yaml":
prefix: "{{/*"
suffix: "/*}}"
.mzm:
prefix: "" # No indent/prefix; place text directly at top
π οΈ Usage
π Injecting Licenses
Once your config is ready, run:
golic inject -t apacheX
[!TIP]
Always use the --dry flag first to see a preview of which files will be modified without actually changing them.
π Updating or Removing
To update a license, you must remove the old one first:
- Remove:
golic remove -t apacheX
- Update: Modify
.golic.yaml
- Re-inject:
golic inject -t apacheX
π€ CI/CD Integration
To fail a build if licenses are missing (e.g., a developer forgot to run Golic), use the -x (exit code) flag:
golic inject --dry -x -t apache2
π Development
π Build
To compile the project locally, execute:
make build
To remove build artifacts and clean your workspace:
make clean
If you are contributing to this project, you must first initialize the linting environment:
make lint-init
This command installs all necessary dependencies and tools for code analysis.
Once initialized, you can analyze the codebase by running:
make lint
To verify only the project licenses, use:
make license
π§ͺ Test
To execute the unit testing suite, run:
make test
π Command Reference
| Command |
Description |
inject |
Injects license headers based on templates. |
remove |
Removes license headers matching the config. |
version |
Prints current version. |
Common Flags:
-c, --copyright : Set the holder/year (Default: YYYY [Insert Company]). YYYY defaults to the current year.
-d, --dry : Run without writing to files.
-t, --template : Specify which license key to use from the config.
-v, --verbose : Enable detailed trace logging.
π€ Contributing
We welcome Pull Requests! Please follow these steps:
- β
Validation: Run
make lint to verify code quality.
- π§ͺ Testing: New features must include unit tests.
- βοΈ Security: All commits must be signed (GPG/SSH).
β€οΈ Acknowledgments
- AbsaOSS: For the original foundation of this project.
- Family: A special thanks to my wife, daughter, and son for their patience while I work in "geek mode."
π License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.