Documentation
¶
Overview ¶
Package missinggo contains miscellaneous helpers used in many of anacrolix' projects.
Index ¶
- Constants
- func AddrIP(addr net.Addr) net.IP
- func AddrPort(addr net.Addr) int
- func ConvertToSliceOfEmptyInterface(slice interface{}) (ret []interface{})
- func CopyExact(dest interface{}, src interface{})
- func CopyURL(u *url.URL) (ret *url.URL)
- func CryHeard() bool
- func Fatal(msg interface{})
- func FileInfoAccessTime(fi os.FileInfo) time.Time
- func FilePathExists(p string) bool
- func GzipHTTPHandler(h http.Handler) http.Handler
- func HTTPQuotedString(s string) string
- func PathSplitExt(p string) (ret struct{ ... })
- func RequestedURL(r *http.Request) (ret *url.URL)
- func Unchomp(s string) string
- func WriteStack(w io.Writer, stack []uintptr)
- type HTTPBytesContentRange
- type HTTPBytesRange
- type HostMaybePort
- type HostPort
- type IndentMap
- type RWLocker
- type ReaderFromStatusResponseWriter
- type RunLengthEncoder
- type SingleFlight
- type StatWriter
- type StatusResponseWriter
- func (me *StatusResponseWriter) CloseNotify() <-chan bool
- func (me *StatusResponseWriter) Flush()
- func (me *StatusResponseWriter) Header() http.Header
- func (me *StatusResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (me *StatusResponseWriter) Write(b []byte) (n int, err error)
- func (me *StatusResponseWriter) WriteHeader(code int)
- type Wolf
- type ZeroReader
Constants ¶
Variables ¶
This section is empty.
Functions ¶
func ConvertToSliceOfEmptyInterface ¶
func ConvertToSliceOfEmptyInterface(slice interface{}) (ret []interface{})
func CryHeard ¶
func CryHeard() bool
Calls CryHeard() on a Wolf that is unique to the callers program counter. i.e. every CryHeard() expression has its own Wolf.
func FileInfoAccessTime ¶
Extracts the access time from the FileInfo internals.
func FilePathExists ¶
func GzipHTTPHandler ¶
Gzips response body if the request says it'll allow it.
func HTTPQuotedString ¶
Performs quoted-string from http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html
func PathSplitExt ¶
Splits the pathname p into Root and Ext, such that Root+Ext==p.
func RequestedURL ¶
Reconstructs the URL that would have produced the given Request. Request.URLs are not fully populated in http.Server handlers.
func WriteStack ¶
Types ¶
type HTTPBytesContentRange ¶
type HTTPBytesContentRange struct {
First, Last, Length int64
}
func ParseHTTPBytesContentRange ¶
func ParseHTTPBytesContentRange(s string) (ret HTTPBytesContentRange, ok bool)
type HTTPBytesRange ¶
type HTTPBytesRange struct {
First, Last int64
}
func ParseHTTPBytesRange ¶
func ParseHTTPBytesRange(s string) (ret HTTPBytesRange, ok bool)
type HostMaybePort ¶
func SplitHostPort ¶
func SplitHostPort(hostport string) (ret HostMaybePort)
func (HostMaybePort) String ¶
func (me HostMaybePort) String() string
type HostPort ¶
type HostPort struct {
Host string // Just the host, with no port.
Port string // May be empty if no port was given.
Err error // The error returned from net.SplitHostPort.
}
func ParseHostPort ¶
Parse a "hostport" string, a concept that floats around the stdlib a lot and is painful to work with. If no port is present, what's usually present is just the host.
type IndentMap ¶
func NewExpvarIndentMap ¶
type ReaderFromStatusResponseWriter ¶
type ReaderFromStatusResponseWriter struct {
StatusResponseWriter
io.ReaderFrom
}
func NewReaderFromStatusResponseWriter ¶
func NewReaderFromStatusResponseWriter(w http.ResponseWriter) *ReaderFromStatusResponseWriter
type RunLengthEncoder ¶
type RunLengthEncoder interface {
// Add a series of identical elements to the stream.
Append(element interface{}, count uint64)
// Emit the current element and its count if non-zero without waiting for
// the element to change.
Flush()
}
A RunLengthEncoder counts successive duplicate elements and emits the element and the run length when the element changes or the encoder is flushed.
func NewRunLengthEncoder ¶
func NewRunLengthEncoder(eachRun func(element interface{}, count uint64)) RunLengthEncoder
Creates a new RunLengthEncoder. eachRun is called when an element and its count is emitted, per the RunLengthEncoder interface.
type SingleFlight ¶
type SingleFlight struct {
// contains filtered or unexported fields
}
func (*SingleFlight) Lock ¶
func (me *SingleFlight) Lock(id string)
func (*SingleFlight) Unlock ¶
func (me *SingleFlight) Unlock(id string)
type StatWriter ¶
type StatWriter struct {
Written int64
// contains filtered or unexported fields
}
func NewStatWriter ¶
func NewStatWriter(w io.Writer) *StatWriter
type StatusResponseWriter ¶
type StatusResponseWriter struct {
RW http.ResponseWriter
Code int
BytesWritten int64
}
A http.ResponseWriter that tracks the status of the response. The status code, and number of bytes written for example.
func (*StatusResponseWriter) CloseNotify ¶
func (me *StatusResponseWriter) CloseNotify() <-chan bool
func (*StatusResponseWriter) Flush ¶
func (me *StatusResponseWriter) Flush()
func (*StatusResponseWriter) Header ¶
func (me *StatusResponseWriter) Header() http.Header
func (*StatusResponseWriter) Hijack ¶
func (me *StatusResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
func (*StatusResponseWriter) Write ¶
func (me *StatusResponseWriter) Write(b []byte) (n int, err error)
func (*StatusResponseWriter) WriteHeader ¶
func (me *StatusResponseWriter) WriteHeader(code int)
type Wolf ¶
type Wolf struct {
// contains filtered or unexported fields
}
A Wolf represents some event that becomes less and less interesting as it occurs. Call CryHeard to see if we should pay attention this time.
type ZeroReader ¶
type ZeroReader struct{}