Skip to content
quarry Artifact [d6f229dba1]
Login

Artifact [d6f229dba1]

Artifact d6f229dba1339209b796002eebc9b27c682d9866a5a487bcf08fa75ce453906e:


// Package legal serves the notices a public forge owes its readers: the
// third-party licence inventory, and the privacy statement describing
// what this instance actually stores.
package legal

import (
	_ "embed"
	"encoding/json"
	"fmt"
)

//go:embed licenses.json
var inventory []byte

// Quarry is this software's own licence, embedded from the repository
// root so the page cannot disagree with the file that governs.
//
//go:embed LICENSE
var Quarry string

// Notice is one dependency's licence.
type Notice struct {
	Module  string `json:"module"`
	Version string `json:"version"`
	License string `json:"license"`
	Text    string `json:"text"`
}

// Notices returns the embedded inventory. Generated by cmd/licensegen
// and checked for freshness by a test, because a licence page that has
// silently stopped listing a dependency is worse than none: it asserts
// completeness it no longer has.
func Notices() ([]Notice, error) {
	var out []Notice
	if err := json.Unmarshal(inventory, &out); err != nil {
		return nil, fmt.Errorf("legal: inventory: %w", err)
	}
	return out, nil
}