 Documentation
      ¶
      Documentation
      ¶
    
    
  
    
      Overview ¶
Package missinggo contains miscellaneous helpers used in many of anacrolix' projects.
Index ¶
- 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 PathSplitExt(p string) (ret struct{ ... })
- func RequestedURL(r *http.Request) (ret *url.URL)
- func Unchomp(s string) string
- type HTTPBytesContentRange
- type HostMaybePort
- type HostPort
- type IndentMap
- type RWLocker
- type ReaderFromStatusResponseWriter
- type RunLengthEncoder
- type SingleFlight
- 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
Examples ¶
Constants ¶
This section is empty.
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 PathSplitExt ¶
Splits the pathname p into Root and Ext, such that Root+Ext==p.
Example ¶
fmt.Printf("%q\n", PathSplitExt(".cshrc"))
fmt.Printf("%q\n", PathSplitExt("dir/a.ext"))
fmt.Printf("%q\n", PathSplitExt("dir/.rc"))
fmt.Printf("%q\n", PathSplitExt("home/.secret/file"))
Output: {"" ".cshrc"} {"dir/a" ".ext"} {"dir/" ".rc"} {"home/.secret/file" ""}
func RequestedURL ¶
Reconstructs the URL that would have produced the given Request. Request.URLs are not fully populated in http.Server handlers.
Types ¶
type HTTPBytesContentRange ¶
type HTTPBytesContentRange struct {
	First, Last, Length int64
}
    func ParseHTTPBytesContentRange ¶
func ParseHTTPBytesContentRange(s string) (ret HTTPBytesContentRange, 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.
Example ¶
package main
import (
	"fmt"
	"github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/anacrolix/missinggo"
)
func main() {
	var s string
	rle := missinggo.NewRunLengthEncoder(func(e interface{}, count uint64) {
		s += fmt.Sprintf("%d%c", count, e)
	})
	for _, e := range "WWWWWWWWWWWWBWWWWWWWWWWWWBBBWWWWWWWWWWWWWWWWWWWWWWWWBWWWWWWWWWWWWWW" {
		rle.Append(e, 1)
	}
	rle.Flush()
	fmt.Println(s)
}
Output: 12W1B12W3B24W1B14W
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 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)