31 lines
857 B
Go
31 lines
857 B
Go
package app
|
|
|
|
import "sync"
|
|
|
|
// LicenseTexts holds the embedded LICENSE and NOTICE.md texts bundled into the
|
|
// executable so users can inspect them offline from the About page.
|
|
type LicenseTexts struct {
|
|
License string `json:"license"`
|
|
Notice string `json:"notice"`
|
|
}
|
|
|
|
var embeddedLicenses struct {
|
|
mu sync.RWMutex
|
|
data LicenseTexts
|
|
}
|
|
|
|
// RegisterLicenseTexts stores the repository's LICENSE and NOTICE.md text
|
|
// embedded by package main.
|
|
func RegisterLicenseTexts(license, notice string) {
|
|
embeddedLicenses.mu.Lock()
|
|
embeddedLicenses.data = LicenseTexts{License: license, Notice: notice}
|
|
embeddedLicenses.mu.Unlock()
|
|
}
|
|
|
|
// GetLicenseTexts returns the embedded Apache-2.0 LICENSE and NOTICE.md texts.
|
|
func (a *App) GetLicenseTexts() LicenseTexts {
|
|
embeddedLicenses.mu.RLock()
|
|
defer embeddedLicenses.mu.RUnlock()
|
|
return embeddedLicenses.data
|
|
}
|