{"id":18810359,"url":"https://github.com/absaoss/golic","last_synced_at":"2025-04-13T20:30:58.574Z","repository":{"id":45337536,"uuid":"345969750","full_name":"AbsaOSS/golic","owner":"AbsaOSS","description":"GoLic, injects license into source code files","archived":false,"fork":false,"pushed_at":"2021-12-20T12:39:50.000Z","size":170,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-06-19T11:17:08.563Z","etag":null,"topics":["go","golang","inject-license","license"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AbsaOSS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null}},"created_at":"2021-03-09T10:34:58.000Z","updated_at":"2023-07-27T17:03:10.000Z","dependencies_parsed_at":"2022-09-10T17:40:57.487Z","dependency_job_id":null,"html_url":"https://github.com/AbsaOSS/golic","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbsaOSS%2Fgolic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbsaOSS%2Fgolic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbsaOSS%2Fgolic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbsaOSS%2Fgolic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AbsaOSS","download_url":"https://codeload.github.com/AbsaOSS/golic/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223603223,"owners_count":17172062,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","inject-license","license"],"created_at":"2024-11-07T23:19:57.123Z","updated_at":"2024-11-07T23:19:57.714Z","avatar_url":"https://github.com/AbsaOSS.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# golic\nA declarative tool injecting licenses into source code\n```\ngolic inject -c=\"2022 MyCompany ltd.\" --dry\n```\n![Screenshot 2021-03-30 at 17 04 50](https://user-images.githubusercontent.com/7195836/113011391-0c19ff00-917a-11eb-9579-60851a2f9be2.png)\n## Quickstart \nInstall and run **GOLIC**\n```shell\n# GO 1.16 \ngo install github.com/AbsaOSS/golic@latest\ngolic version\n```\nGolic has two configurations `.licignore` and `.golic.yaml`. The first determines which \nfiles will be selected for license injection. The second contains a configuration of license text and formatting rules.\n\n### .licignore\n.licignore determines which files will be selected for license injection. The syntax of the file is the same as for .gitignore.\nFor simplicity, we have created inverse rules - we denied everything and allowed where to place license.\n\nCreate `.licignore` in project root\n```shell\n# Ignore everything\n*\n\n# But not these files...\n!Dockerfile*\n!Makefile\n!*.go\n\n# ...even if they are in subdirectories\n!*/\n````\n### .golic.yaml\ngolic.yaml contains a configuration with license text and formatting rules. Golic uses embeded [master configuration](https://raw.githubusercontent.com/AbsaOSS/golic/main/.golic.yaml) \nby default. The master configuration is compiled and goes with binary, so it can change from version to version.\nIf you need to change configuration, you can override it. For example, you want to replace the license text, \nor extend with new file types. All you have to do is to create a `.golic.yaml` file in the project root. Golic will \nread it and overrides master configuration rules.\n\nExample below overrides master configuration by adding `apacheX` licenses and sets new rule for `*.go.txt` and `.mzm`.\nFor more details see [master configuration](https://raw.githubusercontent.com/AbsaOSS/golic/main/.golic.yaml) example.\n```yaml\n# .golic.yaml \ngolic:\n  licenses:\n    apacheX: |\n      Copyright MyCompany\n      Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Pellentesque pretium lectus id turpis. \n      Suspendisse sagittis ultrices augue. Integer pellentesque quam vel velit. In sem justo, commodo ut \n      suscipit at, pharetra vitae, orci\n      \n      for more details see https://github.com/mycompany/myproject/LICENSE\n  rules:\n    \"*.go.txt\":\n      prefix: \"/*\"\n      suffix: \"*/\"\n    .mzm:\n      prefix: \"\"  # no indent, no prefix or suffix, just place license text into top of the file \n```\n\n### Running from commandline\nIf you already created `.licignore` and `.golic.yaml`, run command : \n```shell\ngolic inject -t apacheX\n```\nConsider to use `--dry` flag to preview which files will be affected, before golic modify files.\nFor more command line options (like placeholders, default values etc.), see [Usage](#usage) section.\n\n## CI support\nUsually you want to find out that something went wrong during CI / CD. For example, a file is missing a license. \nIn terms of golic, we want the build pipe to end with an error if we find at least one file with a missing license.\nThe `-x` argument handles that.\n```shell\n  go install github.com/AbsaOSS/golic@latest\n  golic inject --dry -x -t apache2\n```\n\n## Updating license\nThe moment you need to change or delete the license text, the `remove` command comes into play. It deletes license \ndepending on `.golic.yaml` and `.licignore`. If you want to update the license (e.g. the text in the license needs to be changed),\nyou must first remove the license and then re-inject the updated version. I highly recommend using the `--dry`argument \nbefore removing the license.\n```shell\n# updating apacheX license\n\n# remove apacheX license from the source\ngolic remove -t apacheX\n# now update apacheX in .golic.yaml and inject back\ngolic inject -t apacheX\n```\n\n## Usage\n```\nAvailable Commands:\n  help        Help about any command\n  inject      Injects licenses\n  remove      Remove licenses\n  version     Print the version number of Golic\n\n\nFlags:\n  -h, --help      help for this command\n  -v, --verbose   verbose output\n\nUsage inject:\n   inject [flags]\n\nFlags:\n  -p, --config-path string   path to the local configuration overriding config-url (default \".golic.yaml\")\n  -c, --copyright string     company initials entered into license (default \"2022 MyCompany\")\n  -d, --dry                  dry run\n  -h, --help                 help for inject\n  -l, --licignore string     .licignore path (default \".licignore\")\n  -x, --modified-exit        If enabled, exits with status 1 when any file is modified. The settings is used by CI\n  -t, --template string      license key (default \"apache2\")\n\nUsage remove:\n   remove [flags]\n\nFlags:\n  -p, --config-path string   path to the local configuration overriding config-url (default \".golic.yaml\")\n  -c, --copyright string     company initials entered into license (default \"2022 MyCompany\")\n  -d, --dry                  dry run\n  -h, --help                 help for inject\n  -l, --licignore string     .licignore path (default \".licignore\")\n  -t, --template string      license key (default \"apache2\")\n\nGlobal Flags:\n  -v, --verbose   verbose output\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabsaoss%2Fgolic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabsaoss%2Fgolic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabsaoss%2Fgolic/lists"}