pkguri

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultProto = "https"
)

Variables

View Source
var (
	ErrNoURI         = errors.New("pkguri: uri is not defined")
	ErrNoMarshaler   = errors.New("pkguri: cannot be marshal")
	ErrNoUnmarshaler = errors.New("pkguri: cannot be unmarshal")
	ErrHost          = errors.New("pkguri: host not match")
	ErrPath          = errors.New("pkguri: path not match")
)

Errors

Functions

func IsDockerOfficialRepository

func IsDockerOfficialRepository(uri string) bool

func IsYoutubeValidChannelId

func IsYoutubeValidChannelId(id string) bool

func Marshal

func Marshal(v interface{}) (string, error)

func ToURL

func ToURL(pu *PkgURI) string

func Unmarshal

func Unmarshal(pkguri string, v interface{}) error

Types

type Marshaler

type Marshaler interface {
	MarshalPkgURI() (*PkgURI, error)
}

type PkgURI

type PkgURI struct {
	Provider string
	Host     string
	URI      string
	Proto    string
}

PkgURI contains

func NewFromURI

func NewFromURI(pkguri string) (*PkgURI, error)

func ParseDocker

func ParseDocker(rawurl string) (*PkgURI, error)

func ParseGit

func ParseGit(rawurl string) (*PkgURI, error)

ParseGit parses git url to pkguri.

func ParseGithub

func ParseGithub(rawurl string) (*PkgURI, error)

ParseGithub parses github url to pkguri.

func ParseNpm

func ParseNpm(rawurl string) (*PkgURI, error)

ParseNpm parses npm package url to pkguri.

func ParseWebsite

func ParseWebsite(rawurl string) (*PkgURI, error)

func ParseYoutube

func ParseYoutube(rawurl string) (*PkgURI, error)

func (PkgURI) MarshalText

func (p PkgURI) MarshalText() ([]byte, error)

func (*PkgURI) Namespace

func (p *PkgURI) Namespace() string

Namespace returns the namespace of repo.

func (*PkgURI) RepoName

func (p *PkgURI) RepoName() string

RepoName returns the name of repo.

func (*PkgURI) String

func (p *PkgURI) String() string

String produces url format of pkguri, which is supported by Parse function.

func (*PkgURI) URISplits

func (p *PkgURI) URISplits() []string

URISplits splits uri by slash.

func (*PkgURI) URL

func (p *PkgURI) URL() string

URL produces accessible url with the specified protocol.

func (*PkgURI) UnmarshalText

func (p *PkgURI) UnmarshalText(text []byte) error

type Unmarshaler

type Unmarshaler interface {
	UnmarshalPkgURI(*PkgURI) error
}

Jump to

Keyboard shortcuts

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