pkgsite: Index | Files

package sample

import ""

Package sample provides functionality for generating sample values of the types contained in the internal package.


Package Files

documentation.gen.go sample.go


var (
    DocumentationHTML = testconversions.MakeHTMLForTest("" /* 12549 byte string literal not displayed */,
    DocumentationSource = []byte{ /* 7874 elements not displayed */ }
    Documentation       = &internal.Documentation{
        Synopsis: Synopsis,
        GOOS:     GOOS,
        GOARCH:   GOARCH,
        Source:   DocumentationSource,
var (
    ModulePath      = ""
    RepositoryURL   = ""
    VersionString   = "v1.0.0"
    CommitTime      = NowTruncated()
    LicenseType     = "MIT"
    LicenseFilePath = "LICENSE"
    LicenseMetadata = []*licenses.Metadata{
            Types:    []string{LicenseType},
            FilePath: LicenseFilePath,
            OldCoverage: oldlicensecheck.Coverage{
                Percent: 100,
                Match:   []oldlicensecheck.Match{{Name: LicenseType, Type: oldlicensecheck.MIT, Percent: 100}},
    Licenses = []*licenses.License{
        {Metadata: LicenseMetadata[0], Contents: []byte(`Lorem Ipsum`)},
    NonRedistributableLicense = &licenses.License{
        Metadata: &licenses.Metadata{
            FilePath: "NONREDIST_LICENSE",
            Types:    []string{"UNKNOWN"},
        Contents: []byte(`unknown`),
    PackageName    = "foo"
    Suffix         = "foo"
    PackagePath    = path.Join(ModulePath, Suffix)
    V1Path         = PackagePath
    Imports        = []string{"path/to/bar", "fmt"}
    Synopsis       = "This is a package synopsis"
    ReadmeFilePath = ""
    ReadmeContents = "readme"
    GOOS           = "linux"
    GOARCH         = "amd64"

These sample values can be used to construct test cases.

var LicenseCmpOpts = []cmp.Option{
    cmpopts.IgnoreFields(licensecheck.Match{}, "Start", "End"),

LicenseCmpOpts are options to use when comparing licenses with the cmp package.

func AddLicense Uses

func AddLicense(m *internal.Module, lic *licenses.License)

func AddPackage Uses

func AddPackage(m *internal.Module, pkg *internal.Unit) *internal.Module

func AddUnit Uses

func AddUnit(m *internal.Module, u *internal.Unit)

func DefaultModule Uses

func DefaultModule() *internal.Module

func DefaultVersionMap Uses

func DefaultVersionMap() *internal.VersionMap

func Module Uses

func Module(modulePath, version string, suffixes ...string) *internal.Module

Module creates a Module with the given path and version. The list of suffixes is used to create Units within the module.

func ModuleInfo Uses

func ModuleInfo(modulePath, versionString string) *internal.ModuleInfo

func NowTruncated Uses

func NowTruncated() time.Time

NowTruncated returns time.Now() truncated to Microsecond precision.

This makes it easier to work with timestamps in PostgreSQL, which have Microsecond precision:

func PackageMeta Uses

func PackageMeta(fullPath string) *internal.PackageMeta

func UnitEmpty Uses

func UnitEmpty(path, modulePath, version string) *internal.Unit

func UnitForModuleRoot Uses

func UnitForModuleRoot(m *internal.ModuleInfo) *internal.Unit

func UnitForPackage Uses

func UnitForPackage(path, modulePath, version, name string, isRedistributable bool) *internal.Unit

UnitForPackage constructs a unit with the given module path and suffix.

If modulePath is the standard library, the package path is the suffix, which must not be empty. Otherwise, the package path is the concatenation of modulePath and suffix.

The package name is last component of the package path.

func UnitMeta Uses

func UnitMeta(path, modulePath, version, name string, isRedistributable bool) *internal.UnitMeta

Package sample imports 15 packages (graph) and is imported by 2 packages. Updated 2021-01-15. Refresh now. Tools for package owners.