Documentation ¶
Index ¶
- Variables
- func CreateTempCertificateFiles(certPath, keyPath string, domains []string) errors.E
- func DecodeJSON(reader io.Reader, v interface{}) errors.E
- func DecodeJSONWithoutUnknownFields(reader io.Reader, v interface{}) errors.E
- func InferGitLabProjectID(path string) (string, errors.E)
- func Marshal(v interface{}) ([]byte, errors.E)
- func MarshalWithoutEscapeHTML(v interface{}) ([]byte, errors.E)
- func RatPrecision(rat *big.Rat) (int, int)
- func Unmarshal(data []byte, v interface{}) errors.E
- func UnmarshalWithoutUnknownFields(data []byte, v interface{}) errors.E
- type Counter
- type CountingReader
- type Progress
- type RetryableResponse
- type SyncVar
- type Ticker
Constants ¶
This section is empty.
Variables ¶
var ( ErrOpenGitRepository = errors.Base("cannot open git repository") ErrObtainGitRemote = errors.Base("cannot obtain git remote") ErrParseGitRemoteURL = errors.Base("cannot parse git remote URL") )
var ( ErrResponseClosed = errors.Base("response already closed") ErrResponseReadBeyondEnd = errors.Base("read beyond the expected end of the response body") ErrResponseBadStatus = errors.Base("bad response status") ErrResponseMissingContentLength = errors.Base("missing Content-Length header in response") ErrResponseLengthMismatch = errors.Base("content after retry has different length than before") )
var ErrJSONUnmarshalExtraData = errors.Base("invalid data after top-level value")
var ErrSyncVarAlreadyStored = errors.Base("already stored")
Functions ¶
func CreateTempCertificateFiles ¶
CreateTempCertificateFiles creates a pair of files for given domains. It generates a ECDSA private key.
func DecodeJSON ¶
DecodeJSON reads one JSON object from reader and unmarshals it into v. It errors if there is more data trailing after the object.
func DecodeJSONWithoutUnknownFields ¶
DecodeJSONWithoutUnknownFields reads one JSON object from reader and unmarshals it into v. It errors if there is more data trailing after the object. It returns an error if there is any unknown field present in JSON.
func InferGitLabProjectID ¶
InferGitLabProjectID infers a GitLab project ID from "origin" remote of a git repository at path.
func Marshal ¶
Marshal is a standard JSON marshal, just that it returns an error with a stack trace.
func MarshalWithoutEscapeHTML ¶
MarshalWithoutEscapeHTML is a standard JSON marshal, just that it does not escape HTML characters.
func RatPrecision ¶
RatPrecision computes for rat the number of non-repeating digits on the right of the decimal point and the number of repeating digits which cyclicly follow.
It can be used with Rat.FloatString to convert a number to full precision representation, when there are no repeating digits.
This is similar to Rat.FloatPrec but returns also the number of repeating digits following the non-repeating digits. Rat.FloatPrec is also much faster.
func Unmarshal ¶
Unmarshal is a standard JSON unmarshal, just that it returns an error with a stack trace and adds JSON data as an error detail.
func UnmarshalWithoutUnknownFields ¶
UnmarshalWithoutUnknownFields is a standard JSON unmarshal, just that it returns an error if there is any unknown field present in JSON. It also adds JSON data to any error as an error detail.
Types ¶
type Counter ¶
type Counter int64
Counter is an int64 value which implements counter interface.
type CountingReader ¶
CountingReader is an io.Reader proxy which counts the number of bytes it read and passed on.
func NewCountingReader ¶
func NewCountingReader(reader io.Reader) *CountingReader
NewCountingReader returns a new CountingReader which reads from the reader and counts the bytes.
func (*CountingReader) Count ¶
func (c *CountingReader) Count() int64
Count implements counter interface for CountingReader.
It returns the number of bytes read until now.
type Progress ¶
type Progress struct { Count int64 Size int64 Started time.Time Current time.Time Elapsed time.Duration // contains filtered or unexported fields }
Progress describes current progress as reported by the counter.
type RetryableResponse ¶
RetryableResponse reads the response body until it is completely read.
If reading fails before full contents have been read (based on the Content-Length header), it transparently retries the request using Range request header and continues reading the new response body.
It embeds the current response (so you can access response headers, etc.) but the current response can change when the request is retried.
func NewRetryableResponse ¶
func NewRetryableResponse(client *retryablehttp.Client, req *retryablehttp.Request) (*RetryableResponse, errors.E)
NewRetryableResponse returns a RetryableResponse given the client and request to do (and potentially retry).
func (*RetryableResponse) Close ¶
func (d *RetryableResponse) Close() error
Close implements io.Closer interface for RetryableResponse.
It closes the underlying response body.
func (*RetryableResponse) Count ¶
func (d *RetryableResponse) Count() int64
Count implements counter interface for RetryableResponse.
It returns the number of bytes read until now.
func (*RetryableResponse) Read ¶
func (d *RetryableResponse) Read(p []byte) (int, error)
Read implements io.Reader for RetryableResponse.
Use this to read the response body and not RetryableResponse.Response.Body.Read.
func (*RetryableResponse) Size ¶
func (d *RetryableResponse) Size() int64
Size returns the expected number of bytes to read.
type SyncVar ¶
type SyncVar[T any] struct { // contains filtered or unexported fields }
SyncVar allows multiple goroutines to wait for a value to be available while one other goroutine stored the value.
It is useful if you do not know in advance which goroutine will be the one (and only one) which stores the value while all goroutines need the value.
The zero value for a SyncVar is not usable. Use NewSyncVar.
func (*SyncVar[T]) Load ¶
func (w *SyncVar[T]) Load() T
Load returns the value stored in the SyncVar. It blocks until the value is stored.
func (*SyncVar[T]) LoadContext ¶
LoadContext is similar to Load, but it stops waiting if ctx gets cancelled, returning an error in that case.