lib

package
v3.3.361 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2026 License: MIT Imports: 40 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Examples

Constants

View Source
const (
	// AdaptiveConcurrencyDefaultInitialTarget is the default starting target used by NewAdaptiveConcurrencyManager.
	AdaptiveConcurrencyDefaultInitialTarget = 8
	// AdaptiveConcurrencyDefaultMinTarget is the default minimum target for config-based managers.
	AdaptiveConcurrencyDefaultMinTarget = 2
	// AdaptiveConcurrencyDefaultGrowEvery is the default success count between growth steps.
	AdaptiveConcurrencyDefaultGrowEvery = 8
	// AdaptiveConcurrencyDefaultGrowStep is the default normal growth step.
	AdaptiveConcurrencyDefaultGrowStep = 1
	// AdaptiveConcurrencyDefaultFailureShrinkPercent is the default shrink percentage after failure.
	AdaptiveConcurrencyDefaultFailureShrinkPercent = 50
	// AdaptiveConcurrencyDefaultBackPressureShrinkPercent is the default shrink percentage after backpressure.
	AdaptiveConcurrencyDefaultBackPressureShrinkPercent = 50
	// AdaptiveConcurrencyDefaultBackPressurePause is the default pause after backpressure.
	AdaptiveConcurrencyDefaultBackPressurePause = time.Second
)
View Source
const (
	BasePart = int64(1024 * 1024 * 5)
)
View Source
const MinMeterResolution time.Duration = time.Millisecond * 100

MinMeterResolution MinResolution is the minimum time resolution to measure bit rate.

View Source
const (
	URLPathSeparator = "/"
)

Variables

View Source
var DefaultClient *http.Client
View Source
var ErrAttachmentSizeMismatch = errors.New("attachment does not have its declared size")

ErrAttachmentSizeMismatch is returned, wrapped, when the reader of an attachment made with NewJSONAttachment ends before or continues after its size.

View Source
var ErrAttachmentTooLarge = errors.New("attachment is larger than its limit")

ErrAttachmentTooLarge is returned, wrapped, when the reader of an attachment made with NewJSONAttachmentUpTo has more bytes than its limit.

View Source
var ErrInvalidMeterParameter = errors.New("meter invalid parameter")

ErrInvalidMeterParameter is the error thrown when a parameter is invalid.

View Source
var PartSizes = partSizes()

PartSizes return 10k parts that add up to 4.9 TB

Functions

func AnyError

func AnyError(callback func(error), functions ...func() error)

func Bool

func Bool(bool bool) *bool

func BuildPath

func BuildPath(resourcePath string, values interface{}) (string, error)

func BuildPathSpecTest

func BuildPathSpecTest(t *testing.T, mutex *sync.Mutex, tt PathSpecTest, sourceFs ReadWriteFs, destinationFs ReadWriteFs, cmdBuilder func(PathSpecArgs) Cmd)

func ChangeDir

func ChangeDir(fs ReadWriteFs, relativePath string, fullPath string, mutex *sync.Mutex) (func(), bool, error)

func CheckRequired

func CheckRequired(iStruct interface{}) error

func CloneHTTPClientWithExactMaxConnsPerHost added in v3.3.126

func CloneHTTPClientWithExactMaxConnsPerHost(client *http.Client, maxConnsPerHost int) (*http.Client, bool)

func CloneHTTPClientWithMatchingMaxConnsPerHost added in v3.3.314

func CloneHTTPClientWithMatchingMaxConnsPerHost(client *http.Client, maxConnsPerHost int) *http.Client

CloneHTTPClientWithMatchingMaxConnsPerHost returns client itself when its transport already allows exactly maxConnsPerHost connections per host, or is a RoundTripper whose connections this package cannot configure. Otherwise it returns a copy of client on a new transport, configured like client's, idle limits and dial callbacks included, that allows exactly maxConnsPerHost. It never writes client or its transport, which other requests may be using. The new transport starts with no connections of its own, and whoever keeps the copy owns them: close its idle connections once its requests are done.

func CloneHTTPClientWithMaxConnsPerHost added in v3.3.125

func CloneHTTPClientWithMaxConnsPerHost(client *http.Client, maxConnsPerHost int) (*http.Client, bool)

func CloseBody

func CloseBody(res *http.Response)

func CopyAt

func CopyAt(dst io.WriterAt, writeOff int64, src io.Reader) (written int64, err error)

func CreateError

func CreateError(i interface{}, name string) error

func DecimalOverrideValues added in v3.3.272

func DecimalOverrideValues(v any, overrides ...DecimalOverride) (url.Values, error)

DecimalOverrideValues encodes v like query.Values, sending each decimal text as the single value for its key.

func DefaultAPIBackoff added in v3.3.347

func DefaultAPIBackoff(_, max time.Duration, attemptNum int, resp *http.Response) time.Duration

DefaultAPIBackoff is a retryablehttp.Backoff for a caller to set as Config.APIBackoff; the SDK never sets it. It waits as long as a valid Retry-After header asks, read as the SDK's default Backoff reads it and not limited by max. Otherwise it waits 100 ms, doubled for each later retry and at most max: 100, 200 and 400 ms for the SDK's three retries with its 30 s RetryWaitMax. It does not use its first argument, the retry client's RetryWaitMin, which it leaves as it is.

func DefaultRetryableHttp

func DefaultRetryableHttp(logger Logger, client ...*http.Client) *retryablehttp.Client

func DefaultString

func DefaultString(a, b string) string

func ExpandTilde

func ExpandTilde(path string) string

func GetConnectionStatsFromClient

func GetConnectionStatsFromClient(client *http.Client) (map[string]int, bool)

func Int64

func Int64(i int64) *int64

func IsDecimalText added in v3.3.272

func IsDecimalText(text string) bool

IsDecimalText reports whether text is a finite base-10 number, such as "1.5", "-0.25", ".5", "01.50" or "2e-3". It rejects empty text, spaces, NaN, infinities, hexadecimal, fractions and underscores. It checks syntax only: it sets no range or precision limit, and the API decides which values it accepts.

func IsHTML

func IsHTML(res *http.Response) bool

func IsJSON

func IsJSON(res *http.Response) bool

func IsNonOkStatus

func IsNonOkStatus(res *http.Response) bool

func IsOkStatus

func IsOkStatus(res *http.Response) bool

func IsStatus

func IsStatus(status int) func(res *http.Response) error

func IsXML

func IsXML(res *http.Response) bool

func JSONEmptyValue

func JSONEmptyValue(v reflect.Type) string

func MarshalDecimalOverrides added in v3.3.272

func MarshalDecimalOverrides(v any, overrides ...DecimalOverride) ([]byte, error)

MarshalDecimalOverrides encodes v, a request struct type without its own MarshalJSON method, as JSON, sending each decimal text as a JSON string. Without decimal text the result is exactly json.Marshal(v).

func MultipartBody added in v3.3.301

func MultipartBody(values Values) (io.Reader, string, error)

MultipartBody encodes the request body as multipart/form-data when the parameters set a file parameter, a field declared as io.Writer. Each file is sent as a part holding its bytes, and every other parameter as a form field encoded as it would be in a query string. The body is held in memory, so the request can be sent again on retry. When no file parameter is set it returns a nil body and the request is sent as JSON as before.

A file must also be readable, such as an *Attachment, *bytes.Buffer or *os.File. Content is read from its current position, a buffer's unread bytes are not consumed, and the value is never closed.

func NewReader

func NewReader(ctx context.Context, r io.ReadCloser) io.ReadCloser

NewReader gets a context-aware io.Reader.

func NewReaderAt

func NewReaderAt(ctx context.Context, r io.ReaderAt) io.ReaderAt

NewReaderAt gets a context-aware io.ReaderAt.

func NonJSONError

func NonJSONError(res *http.Response) error

func NonOkError

func NonOkError(res *http.Response) error

func NonOkErrorCustom

func NonOkErrorCustom(callbacks ...func(error) error) func(res *http.Response) error

func NormalizeAPIPath added in v3.3.180

func NormalizeAPIPath(parts ...string) string

NormalizeAPIPath applies the Files.com Normalize algorithm to the joined parts: null bytes are removed, backslashes become slashes, and empty, "." and ".." components are dropped without collapsing their neighbors.

func NormalizeForComparison

func NormalizeForComparison(path string) string

func NotStatus

func NotStatus(status int) func(res *http.Response) error

func PathEscape

func PathEscape(path string) (string, error)

func Ptr added in v3.2.130

func Ptr[T any](t T) *T

func ResponseErrors

func ResponseErrors(res *http.Response, errorFunc ...func(res *http.Response) error) error

func S3ErrorIsRequestHasExpired added in v3.0.4

func S3ErrorIsRequestHasExpired(err error) bool

func S3ErrorIsRequestTimeout deprecated added in v3.0.4

func S3ErrorIsRequestTimeout(err error) bool

Deprecated: Use ClassifyS3Error and inspect the Class field instead.

func S3XMLError

func S3XMLError(res *http.Response) error

func String

func String(string string) *string

func Time

func Time(t time.Time) *time.Time

func UnWrapBool

func UnWrapBool(b *bool) bool

func UnderscoreDestinationPath added in v3.3.180

func UnderscoreDestinationPath(root string, id int64, relativePath string) string

func UploadRetryableHttp added in v3.3.106

func UploadRetryableHttp(base *retryablehttp.Client, canReplay func() bool) *retryablehttp.Client

func UploadRetryableHttpWithObserver added in v3.3.125

func UploadRetryableHttpWithObserver(base *retryablehttp.Client, canReplay func() bool, observer func(UploadRetryAttempt)) *retryablehttp.Client

func UrlJoinNoEscape

func UrlJoinNoEscape(paths ...string) string

func UrlLastSegment

func UrlLastSegment(path string) (rest string, lastSegment string)

Types

type AdaptiveConcurrencyConfig added in v3.3.125

type AdaptiveConcurrencyConfig struct {
	MaxConcurrency                         int
	InitialTarget                          int
	MinTarget                              int
	GrowthCeiling                          int
	GrowthCeilingProbeBytes                int64
	GrowthCeilingProbeSuccesses            int
	GrowthCeilingProbeRate                 float64
	ThroughputFloor                        int
	GrowEvery                              int
	GrowStep                               int
	SqrtGrowth                             bool
	FailureShrinkPercent                   int
	BackPressureShrinkPercent              int
	BackPressurePause                      time.Duration
	ThroughputWindow                       int
	ThroughputMinGainPercent               int
	ThroughputShrinkPercent                int
	ThroughputHoldWindows                  int
	ThroughputProbeMinWindows              int
	ThroughputProbeFloor                   int
	ThroughputProbeFloorRate               float64
	ThroughputProbePlateauTarget           int
	ThroughputProbeMinGainPerTargetPercent float64
	ThroughputProbeLossTolerancePercent    int
	LatencyFloor                           int
	LatencyShrinkPercent                   int
	LatencyQueueHigh                       float64
	LatencyGrowthQueueHigh                 float64
	// WarmStart starts the manager at one attempt instead of InitialTarget, and raises it only as measured windows,
	// of at least two answers whatever ThroughputWindow, earn each raise, until a window measures a fast link
	// (ThroughputProbeFloorRate) or the raises reach InitialTarget; from there the rest of this config applies as it
	// would from InitialTarget (see adaptivewarmstart.go). It needs InitialTarget above one, ThroughputWindow and ThroughputProbeFloorRate, and
	// attempts admitted by WaitForAttemptWithContext that report AttemptSending and end with their number.
	WarmStart bool
}

func DefaultAdaptiveConcurrencyConfig added in v3.3.171

func DefaultAdaptiveConcurrencyConfig(maxConcurrency int) AdaptiveConcurrencyConfig

DefaultAdaptiveConcurrencyConfig returns the default manager config with the supplied maximum concurrency. Callers can override individual fields before passing it to NewAdaptiveConcurrencyManagerWithConfig.

type AdaptiveConcurrencyDefaults added in v3.3.171

type AdaptiveConcurrencyDefaults struct {
	MaxConcurrency int
	InitialTarget  int
}

AdaptiveConcurrencyDefaults contains the primary concurrency settings callers usually need when initializing an adaptive manager.

func DefaultAdaptiveConcurrencyDefaults added in v3.3.171

func DefaultAdaptiveConcurrencyDefaults(maxConcurrency int) AdaptiveConcurrencyDefaults

DefaultAdaptiveConcurrencyDefaults returns the SDK's default adaptive concurrency settings with the supplied maximum concurrency.

func (AdaptiveConcurrencyDefaults) Config added in v3.3.171

Config returns a full manager config for these defaults.

type AdaptiveConcurrencyManager added in v3.3.125

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

func NewAdaptiveConcurrencyManager added in v3.3.125

func NewAdaptiveConcurrencyManager(maxConcurrency int) *AdaptiveConcurrencyManager

func NewAdaptiveConcurrencyManagerWithConfig added in v3.3.125

func NewAdaptiveConcurrencyManagerWithConfig(config AdaptiveConcurrencyConfig) *AdaptiveConcurrencyManager

func NewAdaptiveConcurrencyManagerWithDefaults added in v3.3.171

func NewAdaptiveConcurrencyManagerWithDefaults(defaults AdaptiveConcurrencyDefaults) *AdaptiveConcurrencyManager

func NewAdaptiveConcurrencyManagerWithInitial added in v3.3.125

func NewAdaptiveConcurrencyManagerWithInitial(maxConcurrency int, initialTarget int) *AdaptiveConcurrencyManager

func (*AdaptiveConcurrencyManager) AttemptSending added in v3.3.313

func (a *AdaptiveConcurrencyManager) AttemptSending(attempt uint64)

AttemptSending reports that an admitted attempt is being sent, past any other limiter it waited for.

func (*AdaptiveConcurrencyManager) Done added in v3.3.125

func (a *AdaptiveConcurrencyManager) Done()

func (*AdaptiveConcurrencyManager) DoneNeutral added in v3.3.141

func (a *AdaptiveConcurrencyManager) DoneNeutral()

func (*AdaptiveConcurrencyManager) DoneNeutralAttempt added in v3.3.313

func (a *AdaptiveConcurrencyManager) DoneNeutralAttempt(attempt uint64)

DoneNeutralAttempt is DoneNeutral for a numbered attempt.

func (*AdaptiveConcurrencyManager) DoneWithSample added in v3.3.125

func (a *AdaptiveConcurrencyManager) DoneWithSample(sample AdaptiveConcurrencySample)

func (*AdaptiveConcurrencyManager) Max added in v3.3.125

func (*AdaptiveConcurrencyManager) NewSubWorker added in v3.3.125

func (*AdaptiveConcurrencyManager) RunningCount added in v3.3.125

func (a *AdaptiveConcurrencyManager) RunningCount() int

func (*AdaptiveConcurrencyManager) Snapshot added in v3.3.125

func (*AdaptiveConcurrencyManager) StartupState added in v3.3.313

StartupState returns the target with the warm start's phase, read together, so that a target the warm start set is never read with the phase after it ended, and the attempts waiting for admission.

func (*AdaptiveConcurrencyManager) Target added in v3.3.125

func (a *AdaptiveConcurrencyManager) Target() int

func (*AdaptiveConcurrencyManager) Wait added in v3.3.125

func (a *AdaptiveConcurrencyManager) Wait()

func (*AdaptiveConcurrencyManager) WaitAllDone added in v3.3.125

func (a *AdaptiveConcurrencyManager) WaitAllDone()

func (*AdaptiveConcurrencyManager) WaitForADone added in v3.3.125

func (a *AdaptiveConcurrencyManager) WaitForADone() bool

func (*AdaptiveConcurrencyManager) WaitForADoneWithContext added in v3.3.141

func (a *AdaptiveConcurrencyManager) WaitForADoneWithContext(ctx context.Context) bool

func (*AdaptiveConcurrencyManager) WaitForAttemptWithContext added in v3.3.313

func (a *AdaptiveConcurrencyManager) WaitForAttemptWithContext(ctx context.Context) (uint64, bool)

WaitForAttemptWithContext waits like WaitWithContext, and returns the number of the attempt it admitted, from one, which its AttemptSending and the sample or DoneNeutralAttempt that ends it give back.

func (*AdaptiveConcurrencyManager) WaitWithContext added in v3.3.125

func (a *AdaptiveConcurrencyManager) WaitWithContext(ctx context.Context) bool

type AdaptiveConcurrencyManagerWithSample added in v3.3.125

type AdaptiveConcurrencyManagerWithSample interface {
	ConcurrencyManager
	DoneWithSample(AdaptiveConcurrencySample)
}

type AdaptiveConcurrencySample added in v3.3.125

type AdaptiveConcurrencySample struct {
	Success      bool
	Duration     time.Duration
	Bytes        int64
	StatusCode   int
	BackPressure bool
	RetryAfter   time.Duration
	// Attempt is the number WaitForAttemptWithContext gave the attempt this sample ends, or 0 if it is not known.
	Attempt uint64
}

type AdaptiveConcurrencySnapshot added in v3.3.125

type AdaptiveConcurrencySnapshot struct {
	Target                                  int
	Max                                     int
	GrowthCeiling                           int
	GrowthCeilingUnlocked                   bool
	GrowthCeilingProbeSuccessThreshold      int
	Running                                 int
	PeakTarget                              int
	PeakRunning                             int
	SuccessTotal                            int
	FailureTotal                            int
	GrowTotal                               int
	ShrinkTotal                             int
	BackPressureTotal                       int
	RetryAfterTotal                         int
	ThroughputBackoffTotal                  int
	ThroughputProbeMissTotal                int
	ThroughputProbeEfficiencyMissTotal      int
	LatencyBackoffTotal                     int
	LatencyGrowthSuppressionTotal           int
	BytesTotal                              int64
	AverageDuration                         time.Duration
	LastThroughputBytesPerSecond            float64
	BestThroughputBytesPerSecond            float64
	LastThroughputProbeGainPercent          float64
	LastThroughputProbeTargetDelta          int
	LastThroughputProbeGainPerTargetPercent float64
	LastQueueEstimate                       float64
	MinDurationPerByte                      float64
	LastDurationPerByte                     float64
	// WarmStarted reports whether the manager began with a warm start (AdaptiveConcurrencyConfig.WarmStart), and
	// Warming whether it is still under way. WarmStartEnd is how it ended: "fast_link" when a judged window reached
	// ThroughputProbeFloorRate, "raised" when measured raises reached InitialTarget, or "" while warming or without one.
	WarmStarted  bool
	Warming      bool
	WarmStartEnd string
	// WarmStartRaiseTotal counts the warm start's raises, and WarmStartSettleTotal the raises it withdrew.
	WarmStartRaiseTotal  int
	WarmStartSettleTotal int
	// WarmStartUnjudgedWindowTotal counts warm windows not judged because fewer attempts than the target were sending
	// for more than a quarter of the window: waiting for a part to be ready, or for a shared limiter.
	WarmStartUnjudgedWindowTotal int
	// WarmStartQueueEstimate is the queue estimate the warm start last judged a window with.
	WarmStartQueueEstimate float64
	// WarmStartPhase is where the warm start is ("baseline", "settling", "resting"), or "" when it is not warming.
	// WarmStartLastDecision is its last judgment, and WarmStartLastWithdrawal the last raise it took back, with what
	// each was decided on.
	WarmStartPhase          string
	WarmStartLastDecision   AdaptiveConcurrencyWarmDecision
	WarmStartLastWithdrawal AdaptiveConcurrencyWarmDecision
}

type AdaptiveConcurrencyStartupState added in v3.3.313

type AdaptiveConcurrencyStartupState struct {
	Target      int
	StartTarget int
	Warming     bool
	WarmStarted bool
	Waiting     int
}

AdaptiveConcurrencyStartupState is a manager's target read together with the phase of its warm start, its start (InitialTarget, where a warm start ends), and the attempts waiting for admission (StartupState).

type AdaptiveConcurrencySubWorker added in v3.3.125

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

func (*AdaptiveConcurrencySubWorker) AttemptSending added in v3.3.313

func (s *AdaptiveConcurrencySubWorker) AttemptSending(attempt uint64)

func (*AdaptiveConcurrencySubWorker) Done added in v3.3.125

func (s *AdaptiveConcurrencySubWorker) Done()

func (*AdaptiveConcurrencySubWorker) DoneNeutral added in v3.3.141

func (s *AdaptiveConcurrencySubWorker) DoneNeutral()

func (*AdaptiveConcurrencySubWorker) DoneNeutralAttempt added in v3.3.313

func (s *AdaptiveConcurrencySubWorker) DoneNeutralAttempt(attempt uint64)

func (*AdaptiveConcurrencySubWorker) DoneWithSample added in v3.3.125

func (s *AdaptiveConcurrencySubWorker) DoneWithSample(sample AdaptiveConcurrencySample)

func (*AdaptiveConcurrencySubWorker) RunningCount added in v3.3.125

func (s *AdaptiveConcurrencySubWorker) RunningCount() int

func (*AdaptiveConcurrencySubWorker) Wait added in v3.3.125

func (s *AdaptiveConcurrencySubWorker) Wait()

func (*AdaptiveConcurrencySubWorker) WaitAllDone added in v3.3.125

func (s *AdaptiveConcurrencySubWorker) WaitAllDone()

func (*AdaptiveConcurrencySubWorker) WaitForADone added in v3.3.125

func (s *AdaptiveConcurrencySubWorker) WaitForADone() bool

func (*AdaptiveConcurrencySubWorker) WaitForADoneWithContext added in v3.3.141

func (s *AdaptiveConcurrencySubWorker) WaitForADoneWithContext(ctx context.Context) bool

func (*AdaptiveConcurrencySubWorker) WaitForAttemptWithContext added in v3.3.313

func (s *AdaptiveConcurrencySubWorker) WaitForAttemptWithContext(ctx context.Context) (uint64, bool)

func (*AdaptiveConcurrencySubWorker) WaitWithContext added in v3.3.125

func (s *AdaptiveConcurrencySubWorker) WaitWithContext(ctx context.Context) bool

type AdaptiveConcurrencyWarmDecision added in v3.3.313

type AdaptiveConcurrencyWarmDecision struct {
	Decision string
	From     int
	To       int
	// Answers and Throughput (bytes per second) of the window judged; Required, the throughput a raise judged needed.
	Answers    int
	Throughput float64
	Required   float64
	// The window's queue estimate against the fastest window judged at the target compared with, and the estimate at
	// which a raise is not kept: half the attempts added, or that the next raise would add.
	QueueEstimate float64
	QueueLimit    float64
}

AdaptiveConcurrencyWarmDecision is a judgment of the warm start (AdaptiveConcurrencySnapshot.WarmStartLastDecision, WarmStartLastWithdrawal): what it decided, from which target to which, and the window it decided on. It is the last such judgment when the snapshot was taken, not a record of every one. Decision is empty for none, or:

  • "raised": a judged window earned a raise, or ended a rest; "raised_to_start": that raise reached InitialTarget, ending the warm start; "fast_link": the window reached ThroughputProbeFloorRate, ending it at InitialTarget.
  • "withdrawn": a raised target did not earn its keep, so it went back to To; Throughput below Required, or QueueEstimate at or above QueueLimit, or both, say why.
  • "queued": the baseline, or a rest's last window, queued: it rests again instead of raising.
  • "failure", "back_pressure": a failed or throttled attempt lowered the target from From to To.

func (AdaptiveConcurrencyWarmDecision) String added in v3.3.313

String formats a decision for logs, or "" for none.

type AtomicValue added in v3.2.13

type AtomicValue[T comparable] struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*AtomicValue[T]) CompareAndUpdate added in v3.2.13

func (av *AtomicValue[T]) CompareAndUpdate(cmpValue T, updateFunc func() T)

func (*AtomicValue[T]) Load added in v3.2.13

func (av *AtomicValue[T]) Load() T

func (*AtomicValue[T]) Store added in v3.2.13

func (av *AtomicValue[T]) Store(val T)

type Attachment added in v3.3.301

type Attachment struct {
	bytes.Buffer
	FileName    string `json:"-" url:"-"`
	ContentType string `json:"-" url:"-"`
}

Attachment is a file to send with a request, with the file name and media type to send it under. Assign it to a request's file parameter, such as BundleCreateParams.WatermarkAttachmentFile. It is an io.Writer, so content can be copied into it, or it can be built with NewAttachment.

func NewAttachment added in v3.3.301

func NewAttachment(fileName string, contentType string, content []byte) *Attachment

NewAttachment returns an Attachment holding a copy of content.

type Cmd

type Cmd interface {
	SetOut(io.Writer)
	SetErr(newErr io.Writer)
	Run() error
	Args() []string
}

type ConcurrencyManager

type ConcurrencyManager interface {
	// Wait until a slot is available for the new goroutine.
	Wait()

	// Done Mark a goroutine as finished
	Done()

	// WaitAllDone Wait for all goroutines are done
	WaitAllDone()

	// RunningCount Returns the number of goroutines which are running
	RunningCount() int

	// WaitWithContext Acquires a semaphore to allow a new goroutine to run or returns false if the context is done
	WaitWithContext(ctx context.Context) bool

	// WaitForADone Blocks until at least one goroutine has completed.
	WaitForADone() bool

	// WaitForADoneWithContext blocks until at least one goroutine has completed or returns false if the context is done.
	WaitForADoneWithContext(ctx context.Context) bool
}

type ConcurrencyManagerWithSubWorker

type ConcurrencyManagerWithSubWorker interface {
	ConcurrencyManager
	NewSubWorker() ConcurrencyManager
}

type Conn

type Conn struct {
	net.Conn

	sync.Once
	// contains filtered or unexported fields
}

func (*Conn) Close

func (c *Conn) Close() (err error)

type ConstrainedWorkGroup

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

func NewConstrainedWorkGroup

func NewConstrainedWorkGroup(maxConcurrency int) *ConstrainedWorkGroup

func (*ConstrainedWorkGroup) Done

func (cw *ConstrainedWorkGroup) Done()

func (*ConstrainedWorkGroup) Max

func (cw *ConstrainedWorkGroup) Max() int

func (*ConstrainedWorkGroup) NewSubWorker

func (cw *ConstrainedWorkGroup) NewSubWorker() ConcurrencyManager

func (*ConstrainedWorkGroup) RemainingCapacity

func (cw *ConstrainedWorkGroup) RemainingCapacity() int

func (*ConstrainedWorkGroup) RunningCount

func (cw *ConstrainedWorkGroup) RunningCount() int

func (*ConstrainedWorkGroup) Wait

func (cw *ConstrainedWorkGroup) Wait()

func (*ConstrainedWorkGroup) WaitAllDone

func (cw *ConstrainedWorkGroup) WaitAllDone()

func (*ConstrainedWorkGroup) WaitForADone

func (cw *ConstrainedWorkGroup) WaitForADone() bool

func (*ConstrainedWorkGroup) WaitForADoneWithContext added in v3.3.141

func (cw *ConstrainedWorkGroup) WaitForADoneWithContext(ctx context.Context) bool

func (*ConstrainedWorkGroup) WaitWithContext

func (cw *ConstrainedWorkGroup) WaitWithContext(ctx context.Context) bool

type DecimalOverride added in v3.3.272

type DecimalOverride struct {
	Key     string // JSON and query key shared by both fields
	Field   string // Go name of the float64 field; the text field is Field + "Decimal"
	Float   *float64
	Decimal **string
}

DecimalOverride pairs a float64 request field, released before the API accepted exact decimals for it, with the *string field that sends exact decimal text under the same key instead. Generated request types keep the float64 field for existing callers and use these helpers to encode and decode either.

func (*DecimalOverride) UnmarshalJSON added in v3.3.272

func (o *DecimalOverride) UnmarshalJSON(data []byte) error

UnmarshalJSON makes o the decoding target for its key. Generated request types decode each override in the same encoding/json pass as their other fields, so key matching and repeated keys behave as in plain decoding, and the last occurrence of the key decides the route. A JSON string sets the decimal text and clears the float64; null clears the text and, as in plain decoding, leaves the float64 alone; any other value clears the text and decodes into the float64 as plain decoding would.

type DirEntry

type DirEntry struct {
	fs.DirEntry
	fs.FileInfo
	// contains filtered or unexported fields
}

func DirEntryWalkFile

func DirEntryWalkFile(d fs.DirEntry, path string, err error) (DirEntry, error)

func (DirEntry) Err

func (d DirEntry) Err() error

func (DirEntry) Path

func (d DirEntry) Path() string

type ErrorWithOriginalResponse

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

func (ErrorWithOriginalResponse) OriginalResponse

func (u ErrorWithOriginalResponse) OriginalResponse() interface{}

func (ErrorWithOriginalResponse) ProcessError

func (u ErrorWithOriginalResponse) ProcessError(data []byte, err error, t interface{}) error

type ExeCmd

type ExeCmd struct {
	*exec.Cmd
}

func (ExeCmd) Args

func (e ExeCmd) Args() []string

func (ExeCmd) Run

func (e ExeCmd) Run() error

func (ExeCmd) SetErr

func (e ExeCmd) SetErr(w io.Writer)

func (ExeCmd) SetOut

func (e ExeCmd) SetOut(w io.Writer)

type ExportValues

type ExportValues struct {
	url.Values
}

func (ExportValues) ToJSON

func (m ExportValues) ToJSON() (io.Reader, error)

func (ExportValues) ToValues

func (m ExportValues) ToValues() (url.Values, error)

type FSWithContext

type FSWithContext interface {
	WithContext(ctx context.Context) fs.FS
}

type FileWithContext

type FileWithContext interface {
	WithContext(ctx context.Context) fs.File
}

type IsDir

type IsDir interface {
	IsDir() bool
}

type IterChan

type IterChan[T any] struct {
	Send      chan T
	SendError chan error

	Error atomic.Value
	Start func(*IterChan[T])
	context.Context
	Stop context.CancelFunc
	// contains filtered or unexported fields
}

func (*IterChan[T]) Current

func (i *IterChan[T]) Current() interface{}

func (*IterChan[T]) Err

func (i *IterChan[T]) Err() error

func (*IterChan[T]) Init

func (i *IterChan[T]) Init(ctx context.Context) *IterChan[T]

func (*IterChan[T]) Next

func (i *IterChan[T]) Next() bool

func (*IterChan[T]) Resource

func (i *IterChan[T]) Resource() T

type JSONAttachment added in v3.3.306

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

JSONAttachment is file content for a request parameter that takes a file, such as files_sdk.UserUpdateParams.AvatarFileAttachment. Unlike an Attachment, which a parameter's io.Writer field sends as a multipart/form-data part, the request sends it in the same JSON body as the other parameters, as a file object:

{"encoded_content": "<base64 of the content>", "filename": "...", "type": "..."}

Before sending, the SDK reads the content once, from the reader's current position, and keeps it encoded: in memory, or in a temporary file in os.TempDir when its size or limit encodes to more than 1 MiB. The file is created with os.CreateTemp, which on Unix lets only its owner read it, and is removed when the call returns. If the HTTP transport is still sending the request body then, the file stays open until the transport closes the body, and on Windows, where an open file cannot be removed, it is removed only then. Retries resend the kept copy, so every attempt sends the same bytes. The SDK does not close or seek the reader, and a JSONAttachment can be sent only once.

When the reader fails, the request's error names the parameter and wraps the reader's error without repeating its text, which can include a signed URL of the content's source. Use errors.Is, errors.As or errors.Unwrap to inspect the reader's error.

Reading stops with the request context's error (see files_sdk.WithContext) at the next read after the context is done. A Read that is already blocked is not interrupted; to stop one, close or unblock the reader.

A JSONAttachment can also be a top-level value of the map given to an UpdateWithMap method, keyed by the parameter name.

func NewJSONAttachment added in v3.3.306

func NewJSONAttachment(r io.Reader, size int64, filename string, contentType string) *JSONAttachment

NewJSONAttachment returns an attachment of exactly size bytes read from r, such as an *os.File and its Stat size. The request fails, before anything is sent, if r ends before size bytes or has more. filename and contentType, such as "avatar.png" and "image/png", are sent as given; the server validates them.

Example

A file's size is known, so NewJSONAttachment checks the file has exactly that many bytes when the request reads it.

package main

import (
	"context"
	"log"
	"os"

	files_sdk "github.com/Files-com/files-sdk-go/v3"
	"github.com/Files-com/files-sdk-go/v3/lib"
	"github.com/Files-com/files-sdk-go/v3/user"
)

func main() {
	ctx := context.Background()
	client := user.Client{Config: files_sdk.Config{APIKey: os.Getenv("FILES_API_KEY")}.Init()}

	avatar, err := os.Open("avatar.png")
	if err != nil {
		log.Fatal(err)
	}
	// The SDK reads the file but leaves closing it to you.
	defer avatar.Close()
	info, err := avatar.Stat()
	if err != nil {
		log.Fatal(err)
	}

	_, err = client.Update(files_sdk.UserUpdateParams{
		Id:                   123,
		Name:                 "Avatar Owner",
		AvatarFileAttachment: lib.NewJSONAttachment(avatar, info.Size(), "avatar.png", "image/png"),
	}, files_sdk.WithContext(ctx))
	if err != nil {
		log.Fatal(err)
	}
}

func NewJSONAttachmentUpTo added in v3.3.306

func NewJSONAttachmentUpTo(r io.Reader, maxSize int64, filename string, contentType string) *JSONAttachment

NewJSONAttachmentUpTo returns an attachment of everything r has, up to maxSize bytes, for a reader whose length is not known in advance, such as a response body. The request fails with ErrAttachmentTooLarge, before anything is sent, if r has more than maxSize bytes. To find that out the SDK reads at most one byte past maxSize.

Example

A response body's length is not known in advance, so NewJSONAttachmentUpTo sets the most it may have.

package main

import (
	"context"
	"log"
	"net/http"
	"os"

	files_sdk "github.com/Files-com/files-sdk-go/v3"
	"github.com/Files-com/files-sdk-go/v3/lib"
	"github.com/Files-com/files-sdk-go/v3/user"
)

func main() {
	ctx := context.Background()
	client := user.Client{Config: files_sdk.Config{APIKey: os.Getenv("FILES_API_KEY")}.Init()}

	response, err := http.Get("https://example.com/avatar.png")
	if err != nil {
		log.Fatal(err)
	}
	defer response.Body.Close()

	_, err = client.Update(files_sdk.UserUpdateParams{
		Id:                   123,
		AvatarFileAttachment: lib.NewJSONAttachmentUpTo(response.Body, 5<<20, "avatar.png", response.Header.Get("Content-Type")),
	}, files_sdk.WithContext(ctx))
	if err != nil {
		log.Fatal(err)
	}
}

type KeyedMutex

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

func NewKeyedMutex

func NewKeyedMutex() KeyedMutex

func (KeyedMutex) Lock

func (s KeyedMutex) Lock(key interface{})

func (KeyedMutex) Unlock

func (s KeyedMutex) Unlock(key interface{})

type LeveledLogger added in v3.2.136

type LeveledLogger interface {
	Error(string, ...any)
	Warn(string, ...any)
	Info(string, ...any)
	Debug(string, ...any)
	Trace(string, ...any)
}

func NewLeveledLogger added in v3.2.136

func NewLeveledLogger(logger Logger) LeveledLogger

type LocalFileSystem

type LocalFileSystem struct{}

func (LocalFileSystem) Chdir

func (w LocalFileSystem) Chdir(dir string) error

func (LocalFileSystem) Chtimes added in v3.1.50

func (w LocalFileSystem) Chtimes(name string, atime time.Time, mtime time.Time) error

func (LocalFileSystem) Create

func (w LocalFileSystem) Create(path string) (io.WriteCloser, error)

func (LocalFileSystem) Getwd

func (w LocalFileSystem) Getwd() (string, error)

func (LocalFileSystem) MkdirAll

func (w LocalFileSystem) MkdirAll(path string, mode fs.FileMode) error

func (LocalFileSystem) MkdirTemp

func (w LocalFileSystem) MkdirTemp(dir, pattern string) (string, error)

func (LocalFileSystem) Open

func (w LocalFileSystem) Open(path string) (fs.File, error)

func (LocalFileSystem) PathJoin

func (w LocalFileSystem) PathJoin(paths ...string) string

func (LocalFileSystem) PathSeparator

func (w LocalFileSystem) PathSeparator() string

func (LocalFileSystem) RelPath

func (w LocalFileSystem) RelPath(parent, child string) (string, error)

func (LocalFileSystem) Remove

func (w LocalFileSystem) Remove(path string) error

func (LocalFileSystem) RemoveAll

func (w LocalFileSystem) RemoveAll(path string) error

func (LocalFileSystem) SplitPath

func (w LocalFileSystem) SplitPath(path string) (string, string)

func (LocalFileSystem) TempDir

func (w LocalFileSystem) TempDir() string

type Logger

type Logger interface {
	Printf(string, ...any)
}

type Map

type Map[T any] struct {
	sync.Map
}

func (*Map[T]) Delete

func (m *Map[T]) Delete(key any)

func (*Map[T]) Load

func (m *Map[T]) Load(key any) (value T, ok bool)

func (*Map[T]) Store

func (m *Map[T]) Store(key any, value T)

type Meter

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

Meter measures the latest data transfer amount.

func NewMeter

func NewMeter(resolution, sample time.Duration) (*Meter, error)

NewMeter creates a meter with specified resolution and sample duration. sample must be an integral multiple of Resolution

func (*Meter) BitRate

func (m *Meter) BitRate(tc time.Time) uint64

BitRate returns the bit rate in the last sample period.

func (*Meter) Close

func (m *Meter) Close(tc time.Time)

Close stops measuring the data transfer.

func (*Meter) Record

func (m *Meter) Record(tc time.Time, b uint64)

Record records the data transfer into the meter.

func (*Meter) Start

func (m *Meter) Start(tc time.Time)

Start starts measuring the data transfer.

func (*Meter) Total

func (m *Meter) Total(tc time.Time) (uint64, time.Duration, float64)

Total returns the data transfer amount, elapsed time, and bit rate in the entire period from Start to Close.

type MeterItem

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

MeterItem is an element of linked list for the meter.

type NullLogger

type NullLogger struct{}

func (NullLogger) Printf

func (n NullLogger) Printf(_ string, _ ...any)

type Params

type Params struct {
	Params interface{}
}

func (Params) HasJSONAttachments added in v3.3.306

func (p Params) HasJSONAttachments() bool

HasJSONAttachments reports whether p sends any JSONAttachment. files_sdk.Call sends such a request with PrepareJSON instead of ToJSON.

func (Params) PrepareJSON added in v3.3.306

func (p Params) PrepareJSON(ctx context.Context) (*PreparedJSON, error)

PrepareJSON reads the attachments of p and returns the whole JSON request body: the other parameters, encoded as ToJSON would encode them, with a file object for each attachment. Nothing is read from any reader until the other parameters and every attachment have been checked. ctx stops the reading at the next read after it is done. The caller must Close the result.

func (Params) ToJSON

func (p Params) ToJSON() (io.Reader, error)

func (Params) ToValues

func (p Params) ToValues() (url.Values, error)

type Path

type Path struct {
	Path      string
	Separator string
}

func NewUrlPath

func NewUrlPath(path string) Path

func (Path) ConvertEmptyToRoot

func (p Path) ConvertEmptyToRoot() Path

func (Path) EndingSlash

func (p Path) EndingSlash() bool

func (Path) Join

func (p Path) Join(str ...string) Path

func (Path) NormalizePathSystemForAPI

func (p Path) NormalizePathSystemForAPI() Path

func (Path) PathSeparator

func (p Path) PathSeparator() string

func (Path) Pop

func (p Path) Pop() string

func (Path) PruneEndingSlash

func (p Path) PruneEndingSlash() Path

func (Path) PruneStartingSlash

func (p Path) PruneStartingSlash() Path

func (Path) String

func (p Path) String() string

func (Path) SwitchPathSeparator

func (p Path) SwitchPathSeparator(separator string) Path

type PathSpecArgs

type PathSpecArgs struct {
	Src           string
	Dest          string
	PreserveTimes bool
}

type PathSpecEntry

type PathSpecEntry struct {
	Dir bool

	Preexisting bool
	Mtime       time.Time
	// contains filtered or unexported fields
}

type PathSpecTest

type PathSpecTest struct {
	Name string
	Args PathSpecArgs
	Dest []PathSpecEntry
	Src  []PathSpecEntry
}

func PathSpec

func PathSpec(t *testing.T, srcPathSeparator string, destPathSeparator string) []PathSpecTest

type PreparedJSON added in v3.3.306

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

PreparedJSON is a JSON request body that can be read any number of times, returned by Params.PrepareJSON for requests with attachments, and by CopyBody. Its content does not change.

func CopyBody added in v3.3.306

func CopyBody(ctx context.Context, r io.Reader) (*PreparedJSON, error)

CopyBody reads r to its end and returns a copy of what it read, kept as attachment content is: in memory up to 1 MiB, and otherwise in a temporary file that Close removes. It reads at most 32 KiB at a time, and ctx stops the reading at the next read after it is done. It returns r's error unchanged; it keeps nothing when it fails.

func (*PreparedJSON) Close added in v3.3.306

func (b *PreparedJSON) Close() error

Close removes the temporary files that hold the body. While readers from Open are still open, the files stay open for them: Close removes their names at once where the system allows that for an open file (not on Windows), and the last of the readers to close closes the files and removes any that remain. Readers from NewReader fail once the files are closed. Close can be called more than once.

func (*PreparedJSON) Len added in v3.3.306

func (b *PreparedJSON) Len() int64

Len returns the length of the body in bytes.

func (*PreparedJSON) NewReader added in v3.3.306

func (b *PreparedJSON) NewReader() io.Reader

NewReader returns a reader over the whole body. Each reader has its own position, so readers can be used at the same time.

func (*PreparedJSON) Open added in v3.3.306

func (b *PreparedJSON) Open() io.ReadCloser

Open returns a reader over the whole body, like NewReader, that keeps the body's temporary files open until it is closed, even after Close. It is for an HTTP transport, which can finish sending a request body and close it after the call that sent the request returns. Closing the reader more than once is safe.

type ProgressWriter

type ProgressWriter struct {
	WriterAndAt
	ProgressWatcher func(int64)
}

func (ProgressWriter) Close

func (w ProgressWriter) Close() error

func (ProgressWriter) Write

func (w ProgressWriter) Write(p []byte) (n int, err error)

func (ProgressWriter) WriteAt

func (w ProgressWriter) WriteAt(p []byte, off int64) (n int, err error)

type Queue

type Queue[T any] struct {
	*sync.RWMutex
	// contains filtered or unexported fields
}

func (*Queue[T]) Clear

func (q *Queue[T]) Clear()

func (*Queue[T]) Init

func (q *Queue[T]) Init(size int) *Queue[T]

func (*Queue[T]) Len

func (q *Queue[T]) Len() int

func (*Queue[T]) Pop

func (q *Queue[T]) Pop() T

func (*Queue[T]) Push

func (q *Queue[T]) Push(item T)

type ReadWriteFs

type ReadWriteFs interface {
	WritableFs
	fs.FS
}

type ReaderAtCloser

type ReaderAtCloser interface {
	io.ReaderAt
	io.ReadCloser
}

type Resource

type Resource struct {
	Path   string
	Params interface{}
	Method string
	Entity UnmarshalJSON
}

func (Resource) Out

func (r Resource) Out() (ResourceOut, error)

type ResourceOut

type ResourceOut struct {
	Resource
	Values
}

type ResponseError

type ResponseError struct {
	StatusCode int

	Response *http.Response
	// contains filtered or unexported fields
}

func (ResponseError) Error

func (r ResponseError) Error() string

type S3Error

type S3Error struct {
	XMLName   xml.Name `xml:"Error"`
	Code      string   `xml:"Code"`
	Message   string   `xml:"Message"`
	HostId    string   `xml:"HostId"`
	RequestId string   `xml:"RequestId"`
}

func (S3Error) Empty

func (s S3Error) Empty() bool

func (S3Error) Error

func (s S3Error) Error() string

type S3ErrorClassification added in v3.3.106

type S3ErrorClassification struct {
	Class     string
	Message   string
	Retryable bool
}

func ClassifyS3Error added in v3.3.106

func ClassifyS3Error(err error) (S3ErrorClassification, bool)

func ClassifyS3ErrorCode added in v3.3.106

func ClassifyS3ErrorCode(code string) S3ErrorClassification

type Signal

type Signal struct {
	C chan bool
}

func (*Signal) Call

func (s *Signal) Call()

func (*Signal) Called

func (s *Signal) Called() bool

func (*Signal) Clear

func (s *Signal) Clear()

func (*Signal) Init

func (s *Signal) Init() *Signal

type SlogLogger added in v3.3.350

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

SlogLogger sends SDK diagnostics to a caller-owned standard Go logger. Printf logs at Info, and Trace logs at Debug. Its handler controls filtering and routing, including changes made through a shared slog.LevelVar.

func NewSlogLogger added in v3.3.350

func NewSlogLogger(logger *slog.Logger) *SlogLogger

NewSlogLogger adapts a non-nil logger for Config.Logger. Set it before Config.Init so the SDK's default retry client uses the same logger.

func (*SlogLogger) Debug added in v3.3.350

func (l *SlogLogger) Debug(format string, args ...any)

func (*SlogLogger) DebugEnabled added in v3.3.350

func (l *SlogLogger) DebugEnabled() bool

DebugEnabled reports whether the handler enables detailed SDK diagnostics.

func (*SlogLogger) Error added in v3.3.350

func (l *SlogLogger) Error(format string, args ...any)

func (*SlogLogger) Info added in v3.3.350

func (l *SlogLogger) Info(format string, args ...any)

func (*SlogLogger) Printf added in v3.3.350

func (l *SlogLogger) Printf(format string, args ...any)

func (*SlogLogger) Trace added in v3.3.350

func (l *SlogLogger) Trace(format string, args ...any)

func (*SlogLogger) Warn added in v3.3.350

func (l *SlogLogger) Warn(format string, args ...any)

type StatefulDirectory

type StatefulDirectory interface {
	Chdir(string) error
	Getwd() (string, error)
}

type SubWorker

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

func (*SubWorker) Done

func (sw *SubWorker) Done()

func (*SubWorker) RunningCount

func (sw *SubWorker) RunningCount() int

func (*SubWorker) Wait

func (sw *SubWorker) Wait()

func (*SubWorker) WaitAllDone

func (sw *SubWorker) WaitAllDone()

func (*SubWorker) WaitForADone

func (sw *SubWorker) WaitForADone() bool

WaitForADone Blocks until at least one goroutine has completed.

func (*SubWorker) WaitForADoneWithContext added in v3.3.141

func (sw *SubWorker) WaitForADoneWithContext(ctx context.Context) bool

func (*SubWorker) WaitWithContext

func (sw *SubWorker) WaitWithContext(ctx context.Context) bool

type Transport

type Transport struct {
	*http.Transport
	*net.Dialer
	// contains filtered or unexported fields
}

func DefaultPooledTransport added in v3.0.3

func DefaultPooledTransport() *Transport

func (*Transport) CloseIdleConnections added in v3.3.136

func (t *Transport) CloseIdleConnections()

func (*Transport) DialContext

func (t *Transport) DialContext(ctx context.Context, network, address string) (net.Conn, error)

func (*Transport) GetConnectionStats

func (t *Transport) GetConnectionStats() map[string]int

func (*Transport) RoundTrip added in v3.3.136

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error)

type UnmarshalJSON

type UnmarshalJSON interface {
	UnmarshalJSON(data []byte) error
}

type UploadRetryAttempt added in v3.3.125

type UploadRetryAttempt struct {
	StatusCode int
	Retryable  bool
	RetryAfter time.Duration
	Err        error
}

type Values

type Values interface {
	ToValues() (url.Values, error)
	ToJSON() (io.Reader, error)
}

type Walk

type Walk[T any] struct {
	fs.FS
	Queue[string]
	IterChan[T]
	ConcurrencyManager ConcurrencyManagerWithSubWorker
	// Root is the directory to walk. An empty Root walks the contents of the
	// filesystem root without emitting the root itself; "." or a named Root also
	// emits the root directory when ListDirectories is set.
	Root            string
	WalkFile        func(d fs.DirEntry, path string, err error) (T, error)
	ListDirectories bool
}

func (*Walk[T]) Walk

func (w *Walk[T]) Walk(parentCtx context.Context) *IterChan[T]

type WithContextReader

type WithContextReader interface {
	WithContext(context.Context) interface{}
	io.Reader
}

type WithContextReaderAt

type WithContextReaderAt interface {
	WithContext(context.Context) interface{}
	io.ReaderAt
}

type WritableFs

type WritableFs interface {
	MkdirAll(string, fs.FileMode) error
	MkdirTemp(dir, pattern string) (string, error)
	TempDir() string
	Create(string) (io.WriteCloser, error)
	RemoveAll(string) error
	Remove(string) error
	PathSeparator() string
	PathJoin(...string) string
	RelPath(parent, child string) (string, error)
	SplitPath(path string) (string, string)
	Chtimes(name string, atime time.Time, mtime time.Time) error
}

type WriterAndAt

type WriterAndAt interface {
	io.WriterAt
	io.Writer
	io.Closer
}

Directories

Path Synopsis
Package privatefile creates and maintains local files and directories that only the current user can read.
Package privatefile creates and maintains local files and directories that only the current user can read.

Jump to

Keyboard shortcuts

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