modlicense

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

README

modlicense

A binary tool to track go.mod dependency versions

Usage

$ pwd
/my/go/project
$ modlicense 
{
    "module1 x.y.z": "MIT",
    "module2 x.y.z-alpha": "unknown"
}
$ # same as above
$ modlicense --directory . --file "go.mod" 
$ cat known-licenses.json
{
    "module2 x.y.z-alpha": "ECL"
}
$ modlicense --known=./known-licenses.json
{
    "module1 x.y.z": "MIT",
    "module2 x.y.z-alpha": "ECL"
}
$ # in automation
$ modlicense --known=./known-licenses.json > new-licenses.json
$ diff known-licenses.json new-licenses.json
$ # when there's no delta, proceed with CI
$ # when there is a delta, require manual verification to proceed

Documentation

Index

Constants

View Source
const Version = "0.0.1"

Variables

View Source
var ErrNoConfidentLicense = fmt.Errorf("no confident license found in file")
View Source
var ErrNoLicenseFile = fmt.Errorf("no license file found")

Functions

This section is empty.

Types

type Dependency

type Dependency struct {
	Module  string
	Version string
}

func ParseDependency

func ParseDependency(modline []byte) (Dependency, error)

func (Dependency) GetLicense

func (d Dependency) GetLicense() (License, error)

func (Dependency) MarshalJSON

func (d Dependency) MarshalJSON() ([]byte, error)

func (Dependency) String

func (d Dependency) String() string

func (*Dependency) UnmarshalJSON

func (d *Dependency) UnmarshalJSON(b []byte) error

type License

type License string

type ModLicenses

type ModLicenses struct {
	Licenses map[Dependency]License `json:"licenses"`
}

func FromDir

func FromDir(dir string) (ModLicenses, error)

func FromModFilePath

func FromModFilePath(modpath string) (ModLicenses, error)

func FromModfile

func FromModfile(r io.Reader) (ModLicenses, error)

func FromWD

func FromWD() (ModLicenses, error)

func (ModLicenses) MarshalJSON

func (ml ModLicenses) MarshalJSON() ([]byte, error)

func (*ModLicenses) UnmarshalJSON

func (ml *ModLicenses) UnmarshalJSON(in []byte) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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