Documentation
¶
Overview ¶
Package notice provides functionality to detect license and copyright information of go modules.
Index ¶
Constants ¶
const OptionsFileName string = ".gotice.json" // the default filename of the notice options file
Variables ¶
var ( ErrNoPath = errors.New("environment variable GOPATH not found") ErrPathEmpty = errors.New("environment variable GOPATH is empty") ErrModNotFound = errors.New("module not found in GOPATH") )
var ( RenderingName = map[uint]string{ 1: "text", 2: "html", } RenderingValue = map[string]uint{ "text": 1, "html": 2, } )
var HtmlTemplate string // the built-in html template
var LicenseFiles = [...]string{
"LICENSE",
"LICENSE.txt",
"LICENSE.md",
}
The possible file names of license files used to detect the license texts of go modules.
var MarkdownTemplate string // the built-in markdown template
var TextTemplate string // the built-in text template
Functions ¶
func GetLicenseText ¶
GetLicenseText reads the license text of the go module defined by the given module path and module version.
func WriteHtml ¶ added in v0.4.0
WriteText generates the notice file and writes it to w using the html template tmpl.
func WriteOptions ¶ added in v0.3.0
WriteOptions writes the given options to the given writer w using the json format.
Types ¶
type Notice ¶
type Notice struct {
Path string // The path of the module
Version string // The version of the module
LicenseText string // The license text of the module
}
Notice encapsulates license and copyright information of a single go module.
type Options ¶ added in v0.3.0
type Options struct {
Template string `json:"template"` // the template that shall be used
Rendering Rendering `json:"rendering"` // the rendering that shall be used`
}
Options represents options for generating a notice file.
func NewOptions ¶ added in v0.3.0
func NewOptions() *Options
NewOptions returns a new Options struct with default values.
type Rendering ¶ added in v0.4.0
type Rendering int
Rendering represents the type of output rendering.
func ParseRendering ¶ added in v0.4.0
ParseRendering returns a Rendering based on the string s.
func (Rendering) MarshalJSON ¶ added in v0.4.0
MarshalJSON returns r as the JSON encoding of r.
func (*Rendering) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON sets *r to a copy of data.