item

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateItemJSON

func GenerateItemJSON(rev *ItemRevision, pretty bool) (b []byte, err error)

Types

type ChecksumType added in v0.6.0

type ChecksumType int
const (
	ChecksumTypeSHA256 ChecksumType = iota + 1
	ChecksumTypeCRC
	ChecksumTypeMD5
	ChecksumTypeUnknown ChecksumType = -1
)

type FormatParam added in v0.6.3

type FormatParam struct {
	Version string
	OS      string
	Arch    string
}

type Item

type Item struct {
	// contains filtered or unexported fields
}

Item wraps itemProps which corresponds to JSON structure of item data

func DecodeItemJSON

func DecodeItemJSON(b []byte) (item *Item, err error)

func (*Item) AddOrUpdateRevision

func (i *Item) AddOrUpdateRevision(rev *ItemRevision, mode ReviseMode)

func (*Item) DeleteRevision

func (i *Item) DeleteRevision(version string) (deleted bool)

func (*Item) GetLatest

func (i *Item) GetLatest() (rev *ItemRevision)

func (*Item) GetLatestURL

func (i *Item) GetLatestURL(param FormatParam) (url string, err error)

func (*Item) GetRevision

func (i *Item) GetRevision(version string) (rev *ItemRevision)

func (*Item) Print

func (i *Item) Print(pretty bool) (b []byte, err error)

func (*Item) String

func (i *Item) String() string

func (*Item) UpdateRevisionChecksum added in v0.6.0

func (i *Item) UpdateRevisionChecksum(ver string, sum *ItemChecksum) (success bool)

type ItemChecksum added in v0.5.0

type ItemChecksum struct {
	File   string `json:"file"`
	SHA256 string `json:"sha256,omitempty"`
	// CRC-32 IEEE Std.
	CRC string `json:"crc,omitempty"`
	MD5 string `json:"md5,omitempty"`
}

func NewItemChecksums

func NewItemChecksums(arg string) (sums []ItemChecksum)

func (*ItemChecksum) GetSumAndHasher added in v0.5.0

func (sum *ItemChecksum) GetSumAndHasher() (s string, h hash.Hash, t ChecksumType)

func (*ItemChecksum) SetSum added in v0.6.0

func (sum *ItemChecksum) SetSum(val string, t ChecksumType)

type ItemRevision

type ItemRevision struct {
	Version      string            `json:"version"`
	Checksums    []ItemChecksum    `json:"checksums,omitempty"`
	URLFormat    string            `json:"url-format,omitempty"`
	Replacements map[string]string `json:"replacements,omitempty"`
	Extension    map[string]string `json:"extension,omitempty"`
	RenameFiles  map[string]string `json:"rename-files,omitempty"`
}

func (*ItemRevision) AddOrSwapChecksum added in v0.6.0

func (rev *ItemRevision) AddOrSwapChecksum(sum *ItemChecksum)

func (*ItemRevision) ConvertFileName added in v0.6.3

func (rev *ItemRevision) ConvertFileName(src string, param FormatParam) (dest string)

func (*ItemRevision) GetChecksum added in v0.5.0

func (rev *ItemRevision) GetChecksum(file string) (sum *ItemChecksum)

func (*ItemRevision) GetURL

func (rev *ItemRevision) GetURL(param FormatParam) (url string, err error)

type ReviseMode

type ReviseMode int
const (
	ReviseModeNatural ReviseMode = iota + 1
	ReviseModeLatest
	ReviseModeOld
)

Jump to

Keyboard shortcuts

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