https://github.com/AbsaOSS/golic Skip to content Navigation Menu Toggle navigation Sign in * Product + GitHub Copilot Write better code with AI + Security Find and fix vulnerabilities + Actions Automate any workflow + Codespaces Instant dev environments + Issues Plan and track work + Code Review Manage code changes + Discussions Collaborate outside of code + Code Search Find more, search less Explore + All features + Documentation + GitHub Skills + Blog * Solutions By company size + Enterprises + Small and medium teams + Startups By use case + DevSecOps + DevOps + CI/CD + View all use cases By industry + Healthcare + Financial services + Manufacturing + Government + View all industries View all solutions * Resources Topics + AI + DevOps + Security + Software Development + View all Explore + Learning Pathways + White papers, Ebooks, Webinars + Customer Stories + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Enterprise + Enterprise platform AI-powered developer platform Available add-ons + Advanced Security Enterprise-grade security features + GitHub Copilot Enterprise-grade AI features + Premium Support Enterprise-grade 24/7 support * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up Reseting focus You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} AbsaOSS / golic Public * Notifications You must be signed in to change notification settings * Fork 1 * Star 62 GoLic, injects license into source code files License Apache-2.0 license 62 stars 1 fork Branches Tags Activity Star Notifications You must be signed in to change notification settings * Code * Issues 0 * Pull requests 0 * Actions * Projects 0 * Security * Insights Additional navigation options * Code * Issues * Pull requests * Actions * Projects * Security * Insights AbsaOSS/golic main BranchesTags Go to file Code Folders and files Name Name Last commit Last commit message date Latest commit History 35 Commits .github/workflows .github/ workflows cmd cmd impl/update impl/update utils utils .gitignore .gitignore .golangci .golangci .golic.yaml .golic.yaml .licignore .licignore CODEOWNERS CODEOWNERS LICENSE LICENSE Makefile Makefile README.md README.md config.yaml config.yaml go.mod go.mod go.sum go.sum main.go main.go View all files Repository files navigation * README * Apache-2.0 license golic A declarative tool injecting licenses into source code golic inject -c="2022 MyCompany ltd." --dry Screenshot 2021-03-30 at 17 04 50 Quickstart Install and run GOLIC # GO 1.16 go install github.com/AbsaOSS/golic@latest golic version Golic has two configurations .licignore and .golic.yaml. The first determines which files will be selected for license injection. The second contains a configuration of license text and formatting rules. .licignore .licignore determines which files will be selected for license injection. The syntax of the file is the same as for .gitignore. For simplicity, we have created inverse rules - we denied everything and allowed where to place license. Create .licignore in project root # Ignore everything * # But not these files... !Dockerfile* !Makefile !*.go # ...even if they are in subdirectories !*/ .golic.yaml golic.yaml contains a configuration with license text and formatting rules. Golic uses embeded master configuration by default. The master configuration is compiled and goes with binary, so it can change from version to version. If you need to change configuration, you can override it. For example, you want to replace the license text, or extend with new file types. All you have to do is to create a .golic.yaml file in the project root. Golic will read it and overrides master configuration rules. Example below overrides master configuration by adding apacheX licenses and sets new rule for *.go.txt and .mzm. For more details see master configuration example. # .golic.yaml golic: licenses: apacheX: | Copyright MyCompany Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque pretium lectus id turpis. Suspendisse sagittis ultrices augue. Integer pellentesque quam vel velit. In sem justo, commodo ut suscipit at, pharetra vitae, orci for more details see https://github.com/mycompany/myproject/LICENSE rules: "*.go.txt": prefix: "/*" suffix: "*/" .mzm: prefix: "" # no indent, no prefix or suffix, just place license text into top of the file Running from commandline If you already created .licignore and .golic.yaml, run command : golic inject -t apacheX Consider to use --dry flag to preview which files will be affected, before golic modify files. For more command line options (like placeholders, default values etc.), see Usage section. CI support Usually you want to find out that something went wrong during CI / CD. For example, a file is missing a license. In terms of golic, we want the build pipe to end with an error if we find at least one file with a missing license. The -x argument handles that. go install github.com/AbsaOSS/golic@latest golic inject --dry -x -t apache2 Updating license The moment you need to change or delete the license text, the remove command comes into play. It deletes license depending on .golic.yaml and .licignore. If you want to update the license (e.g. the text in the license needs to be changed), you must first remove the license and then re-inject the updated version. I highly recommend using the --dryargument before removing the license. # updating apacheX license # remove apacheX license from the source golic remove -t apacheX # now update apacheX in .golic.yaml and inject back golic inject -t apacheX Usage Available Commands: help Help about any command inject Injects licenses remove Remove licenses version Print the version number of Golic Flags: -h, --help help for this command -v, --verbose verbose output Usage inject: inject [flags] Flags: -p, --config-path string path to the local configuration overriding config-url (default ".golic.yaml") -c, --copyright string company initials entered into license (default "2022 MyCompany") -d, --dry dry run -h, --help help for inject -l, --licignore string .licignore path (default ".licignore") -x, --modified-exit If enabled, exits with status 1 when any file is modified. The settings is used by CI -t, --template string license key (default "apache2") Usage remove: remove [flags] Flags: -p, --config-path string path to the local configuration overriding config-url (default ".golic.yaml") -c, --copyright string company initials entered into license (default "2022 MyCompany") -d, --dry dry run -h, --help help for inject -l, --licignore string .licignore path (default ".licignore") -t, --template string license key (default "apache2") Global Flags: -v, --verbose verbose output About GoLic, injects license into source code files Topics go golang license inject-license Resources Readme License Apache-2.0 license Activity Custom properties Stars 62 stars Watchers 7 watching Forks 1 fork Report repository Releases 18 v0.7.2 Latest Dec 20, 2021 + 17 releases Packages 0 No packages published Languages * Go 96.7% * Makefile 3.3% Footer (c) 2024 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact * Manage cookies * Do not share my personal information You can't perform that action at this time.