copyrighter

command module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

README

Copyrighter

Copyrighter is a utility that leverages Go's code generator to add a copyright notice to source files in the following languages:

  • C (.c)
  • C++ (.cpp)
  • C# (.cs)
  • CSS (.css)
  • Go (.go)
  • HTML (.html)
  • Java (.java)
  • JavaScript (.js)
  • PHP (.php)
  • PowerShell (.ps1)
  • Python (.py)
  • Shell (.sh)
  • SQL (.sql)
  • TypeScript (.ts)
  • XML (.xml)
  • YAML (.yaml, *.yml)

Usage

To install, go get github.com/microbus-io/copyrighter.

Place a copyright.go file in the root of the source code directory tree, with:

  • A comment at the top of the file with the copyright or license notice
  • A go generate directive
  • File matching patterns (optional)
  • package and import statements
/*
Copyright 2023 You
All rights reserved
*/

//go:generate go run github.com/microbus-io/copyrighter
// - *.*
// + *.go
// - /vendors/*

package yourpackage

import _ "github.com/microbus-io/copyrighter/i"

The first comment surrounded by /* and */ (on separate lines with nothing else added to those lines) or one where each line starts with // will be recognized as the copyright notice.

/*
Copyright 2023 You
All rights reserved
*/

...
// Copyright 2023 You
// All rights reserved

...

The special constant YYYY may be used as placeholder for the current year.

// Copyright 2023-YYYY You
File Matching Patterns

By default, all recognized source file types are processed. To customize which files to process, file matching patterns may be added anywhere in the file. Patterns are executed in the order of their appearance in file. The last pattern that matches the file wins.

The following examples excludes all files by default, then re-includes *.go and *.sql files, except in the /vendors directory.

// - *.*
// + *.go
// + *.sql
// - /vendors/*

A - or + is used to indicate if this pattern is an exclusion or inclusion pattern.

Patterns that start with a / are matched to the root directory where copyright.go is located. Otherwise, they are applied to any subdirectory.

The following pattern can be used to exclude hidden files on Unix:

// - .*
Verbose Flag

The -v flag may be added to the go:generate directive to produce verbose output.

//go:generate go run github.com/microbus-io/copyrighter -v

Copyrighter is released by Microbus LLC under the Apache 2.0 license.

Documentation

Overview

Package main runs a code generator that injects a copyright notice to source files.

Directories

Path Synopsis
i
Package i should be imported by projects that use the copyrighter in order to add it to go.mod.
Package i should be imported by projects that use the copyrighter in order to add it to go.mod.

Jump to

Keyboard shortcuts

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