url

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2024 License: MIT Imports: 12 Imported by: 16

Documentation

Overview

Package url abstracts local and remote file URLs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromBytes

func FromBytes(data []byte) extsort.SortType

Types

type Option

type Option func(u *URL)

func WithAllVersions

func WithAllVersions(isAllVersions bool) Option

func WithRaw

func WithRaw(mode bool) Option

func WithVersion

func WithVersion(versionID string) Option

type URL

type URL struct {
	Type        urlType
	Scheme      string
	Bucket      string
	Path        string
	Delimiter   string
	Prefix      string
	VersionID   string
	AllVersions bool
	// contains filtered or unexported fields
}

URL is the canonical representation of an object, either on local or remote storage.

func New

func New(s string, opts ...Option) (*URL, error)

New creates a new URL from given path string.

func (*URL) Absolute

func (u *URL) Absolute() string

Absolute returns the absolute URL format of the object.

func (*URL) Base

func (u *URL) Base() string

Base returns the last element of object path.

func (*URL) Clone

func (u *URL) Clone() *URL

Clone creates a copy of the receiver.

func (*URL) Dir

func (u *URL) Dir() string

Dir returns all but the last element of path, typically the path's directory.

func (*URL) EscapedPath

func (u *URL) EscapedPath() string

func (*URL) IsBucket

func (u *URL) IsBucket() bool

IsBucket returns true if the object url contains only bucket name

func (*URL) IsPrefix

func (u *URL) IsPrefix() bool

IsPrefix reports whether the remote object is an S3 prefix, and does not look like an object.

func (*URL) IsRaw added in v2.3.0

func (u *URL) IsRaw() bool

func (*URL) IsRemote

func (u *URL) IsRemote() bool

IsRemote reports whether the object is stored on a remote storage system.

func (*URL) IsVersioned

func (u *URL) IsVersioned() bool

IsVersioned returns true if the URL has versioning related values

func (*URL) IsWildcard

func (u *URL) IsWildcard() bool

IsWildcard reports whether if a string contains any wildcard chars.

func (*URL) Join

func (u *URL) Join(s string) *URL

Join joins string and returns new URL.

func (URL) MarshalJSON

func (u URL) MarshalJSON() ([]byte, error)

MarshalJSON is the json.Marshaler implementation of URL.

func (*URL) Match

func (u *URL) Match(key string) bool

Match reports whether if given key matches with the object.

func (*URL) Relative

func (u *URL) Relative() string

Relative returns a URI reference based on the calculated prefix.

func (*URL) SetRelative

func (u *URL) SetRelative(base *URL)

SetRelative explicitly sets the relative path of u against given base value. If the base path contains `globCharacters` then, the relative path is determined with respect to the parent directory of the so called wildcarded object.

func (*URL) String

func (u *URL) String() string

String is the fmt.Stringer implementation of URL.

func (URL) ToBytes

func (u URL) ToBytes() []byte

Jump to

Keyboard shortcuts

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