id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
26,800
golang/leveldb
bloom/bloom.go
hash
func hash(b []byte) uint32 { const ( seed = 0xbc9f1d34 m = 0xc6a4a793 ) h := uint32(seed) ^ uint32(len(b)*m) for ; len(b) >= 4; b = b[4:] { h += uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 h *= m h ^= h >> 16 } switch len(b) { case 3: h += uint32(b[2]) << 16 fallthrough ...
go
func hash(b []byte) uint32 { const ( seed = 0xbc9f1d34 m = 0xc6a4a793 ) h := uint32(seed) ^ uint32(len(b)*m) for ; len(b) >= 4; b = b[4:] { h += uint32(b[0]) | uint32(b[1])<<8 | uint32(b[2])<<16 | uint32(b[3])<<24 h *= m h ^= h >> 16 } switch len(b) { case 3: h += uint32(b[2]) << 16 fallthrough ...
[ "func", "hash", "(", "b", "[", "]", "byte", ")", "uint32", "{", "const", "(", "seed", "=", "0xbc9f1d34", "\n", "m", "=", "0xc6a4a793", "\n", ")", "\n", "h", ":=", "uint32", "(", "seed", ")", "^", "uint32", "(", "len", "(", "b", ")", "*", "m", ...
// hash implements a hashing algorithm similar to the Murmur hash.
[ "hash", "implements", "a", "hashing", "algorithm", "similar", "to", "the", "Murmur", "hash", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/bloom/bloom.go#L106-L130
26,801
golang/leveldb
bloom/bloom.go
AppendFilter
func (p FilterPolicy) AppendFilter(dst []byte, keys [][]byte) []byte { return appendFilter(dst, keys, int(p)) }
go
func (p FilterPolicy) AppendFilter(dst []byte, keys [][]byte) []byte { return appendFilter(dst, keys, int(p)) }
[ "func", "(", "p", "FilterPolicy", ")", "AppendFilter", "(", "dst", "[", "]", "byte", ",", "keys", "[", "]", "[", "]", "byte", ")", "[", "]", "byte", "{", "return", "appendFilter", "(", "dst", ",", "keys", ",", "int", "(", "p", ")", ")", "\n", "...
// AppendFilter implements the db.FilterPolicy interface.
[ "AppendFilter", "implements", "the", "db", ".", "FilterPolicy", "interface", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/bloom/bloom.go#L151-L153
26,802
golang/leveldb
bloom/bloom.go
MayContain
func (p FilterPolicy) MayContain(filter, key []byte) bool { return Filter(filter).MayContain(key) }
go
func (p FilterPolicy) MayContain(filter, key []byte) bool { return Filter(filter).MayContain(key) }
[ "func", "(", "p", "FilterPolicy", ")", "MayContain", "(", "filter", ",", "key", "[", "]", "byte", ")", "bool", "{", "return", "Filter", "(", "filter", ")", ".", "MayContain", "(", "key", ")", "\n", "}" ]
// MayContain implements the db.FilterPolicy interface.
[ "MayContain", "implements", "the", "db", ".", "FilterPolicy", "interface", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/bloom/bloom.go#L156-L158
26,803
golang/leveldb
table_cache.go
releaseNode
func (c *tableCache) releaseNode(n *tableCacheNode) { delete(c.nodes, n.fileNum) n.next.prev = n.prev n.prev.next = n.next n.refCount-- if n.refCount == 0 { go n.release() } }
go
func (c *tableCache) releaseNode(n *tableCacheNode) { delete(c.nodes, n.fileNum) n.next.prev = n.prev n.prev.next = n.next n.refCount-- if n.refCount == 0 { go n.release() } }
[ "func", "(", "c", "*", "tableCache", ")", "releaseNode", "(", "n", "*", "tableCacheNode", ")", "{", "delete", "(", "c", ".", "nodes", ",", "n", ".", "fileNum", ")", "\n", "n", ".", "next", ".", "prev", "=", "n", ".", "prev", "\n", "n", ".", "pr...
// releaseNode releases a node from the tableCache. // // c.mu must be held when calling this.
[ "releaseNode", "releases", "a", "node", "from", "the", "tableCache", ".", "c", ".", "mu", "must", "be", "held", "when", "calling", "this", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/table_cache.go#L66-L74
26,804
golang/leveldb
table_cache.go
findNode
func (c *tableCache) findNode(fileNum uint64) *tableCacheNode { c.mu.Lock() defer c.mu.Unlock() n := c.nodes[fileNum] if n == nil { n = &tableCacheNode{ fileNum: fileNum, refCount: 1, result: make(chan tableReaderOrError, 1), } c.nodes[fileNum] = n if len(c.nodes) > c.size { // Release the t...
go
func (c *tableCache) findNode(fileNum uint64) *tableCacheNode { c.mu.Lock() defer c.mu.Unlock() n := c.nodes[fileNum] if n == nil { n = &tableCacheNode{ fileNum: fileNum, refCount: 1, result: make(chan tableReaderOrError, 1), } c.nodes[fileNum] = n if len(c.nodes) > c.size { // Release the t...
[ "func", "(", "c", "*", "tableCache", ")", "findNode", "(", "fileNum", "uint64", ")", "*", "tableCacheNode", "{", "c", ".", "mu", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "mu", ".", "Unlock", "(", ")", "\n\n", "n", ":=", "c", ".", "nodes", ...
// findNode returns the node for the table with the given file number, creating // that node if it didn't already exist. The caller is responsible for // decrementing the returned node's refCount.
[ "findNode", "returns", "the", "node", "for", "the", "table", "with", "the", "given", "file", "number", "creating", "that", "node", "if", "it", "didn", "t", "already", "exist", ".", "The", "caller", "is", "responsible", "for", "decrementing", "the", "returned...
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/table_cache.go#L79-L109
26,805
golang/leveldb
version.go
totalSize
func totalSize(f []fileMetadata) (size uint64) { for _, x := range f { size += x.size } return size }
go
func totalSize(f []fileMetadata) (size uint64) { for _, x := range f { size += x.size } return size }
[ "func", "totalSize", "(", "f", "[", "]", "fileMetadata", ")", "(", "size", "uint64", ")", "{", "for", "_", ",", "x", ":=", "range", "f", "{", "size", "+=", "x", ".", "size", "\n", "}", "\n", "return", "size", "\n", "}" ]
// totalSize returns the total size of all the files in f.
[ "totalSize", "returns", "the", "total", "size", "of", "all", "the", "files", "in", "f", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/version.go#L26-L31
26,806
golang/leveldb
version.go
ikeyRange
func ikeyRange(icmp db.Comparer, f0, f1 []fileMetadata) (smallest, largest internalKey) { first := true for _, f := range [2][]fileMetadata{f0, f1} { for _, meta := range f { if first { first = false smallest, largest = meta.smallest, meta.largest continue } if icmp.Compare(meta.smallest, small...
go
func ikeyRange(icmp db.Comparer, f0, f1 []fileMetadata) (smallest, largest internalKey) { first := true for _, f := range [2][]fileMetadata{f0, f1} { for _, meta := range f { if first { first = false smallest, largest = meta.smallest, meta.largest continue } if icmp.Compare(meta.smallest, small...
[ "func", "ikeyRange", "(", "icmp", "db", ".", "Comparer", ",", "f0", ",", "f1", "[", "]", "fileMetadata", ")", "(", "smallest", ",", "largest", "internalKey", ")", "{", "first", ":=", "true", "\n", "for", "_", ",", "f", ":=", "range", "[", "2", "]",...
// ikeyRange returns the minimum smallest and maximum largest internalKey for // all the fileMetadata in f0 and f1.
[ "ikeyRange", "returns", "the", "minimum", "smallest", "and", "maximum", "largest", "internalKey", "for", "all", "the", "fileMetadata", "in", "f0", "and", "f1", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/version.go#L35-L53
26,807
golang/leveldb
version.go
updateCompactionScore
func (v *version) updateCompactionScore() { // We treat level-0 specially by bounding the number of files instead of // number of bytes for two reasons: // // (1) With larger write-buffer sizes, it is nice not to do too many // level-0 compactions. // // (2) The files in level-0 are merged on every read and ther...
go
func (v *version) updateCompactionScore() { // We treat level-0 specially by bounding the number of files instead of // number of bytes for two reasons: // // (1) With larger write-buffer sizes, it is nice not to do too many // level-0 compactions. // // (2) The files in level-0 are merged on every read and ther...
[ "func", "(", "v", "*", "version", ")", "updateCompactionScore", "(", ")", "{", "// We treat level-0 specially by bounding the number of files instead of", "// number of bytes for two reasons:", "//", "// (1) With larger write-buffer sizes, it is nice not to do too many", "// level-0 comp...
// updateCompactionScore updates v's compaction score and level.
[ "updateCompactionScore", "updates", "v", "s", "compaction", "score", "and", "level", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/version.go#L108-L131
26,808
golang/leveldb
version.go
get
func (v *version) get(ikey internalKey, tiFinder tableIkeyFinder, ucmp db.Comparer, ro *db.ReadOptions) ([]byte, error) { ukey := ikey.ukey() // Iterate through v's tables, calling internalGet if the table's bounds // might contain ikey. Due to the order in which we search the tables, and // the internalKeyComparer...
go
func (v *version) get(ikey internalKey, tiFinder tableIkeyFinder, ucmp db.Comparer, ro *db.ReadOptions) ([]byte, error) { ukey := ikey.ukey() // Iterate through v's tables, calling internalGet if the table's bounds // might contain ikey. Due to the order in which we search the tables, and // the internalKeyComparer...
[ "func", "(", "v", "*", "version", ")", "get", "(", "ikey", "internalKey", ",", "tiFinder", "tableIkeyFinder", ",", "ucmp", "db", ".", "Comparer", ",", "ro", "*", "db", ".", "ReadOptions", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "ukey", ...
// get looks up the internal key ikey0 in v's tables such that ikey and ikey0 // have the same user key, and ikey0's sequence number is the highest such // sequence number that is less than or equal to ikey's sequence number. // // If ikey0's kind is set, the value for that previous set action is returned. // If ikey0'...
[ "get", "looks", "up", "the", "internal", "key", "ikey0", "in", "v", "s", "tables", "such", "that", "ikey", "and", "ikey0", "have", "the", "same", "user", "key", "and", "ikey0", "s", "sequence", "number", "is", "the", "highest", "such", "sequence", "numbe...
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/version.go#L219-L280
26,809
golang/leveldb
ikey.go
valid
func (k internalKey) valid() bool { i := len(k) - 8 return i >= 0 && internalKeyKind(k[i]) <= internalKeyKindMax }
go
func (k internalKey) valid() bool { i := len(k) - 8 return i >= 0 && internalKeyKind(k[i]) <= internalKeyKindMax }
[ "func", "(", "k", "internalKey", ")", "valid", "(", ")", "bool", "{", "i", ":=", "len", "(", "k", ")", "-", "8", "\n", "return", "i", ">=", "0", "&&", "internalKeyKind", "(", "k", "[", "i", "]", ")", "<=", "internalKeyKindMax", "\n", "}" ]
// valid returns whether k is a valid internal key.
[ "valid", "returns", "whether", "k", "is", "a", "valid", "internal", "key", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/ikey.go#L69-L72
26,810
golang/leveldb
ikey.go
seqNum
func (k internalKey) seqNum() uint64 { i := len(k) - 7 n := uint64(k[i+0]) n |= uint64(k[i+1]) << 8 n |= uint64(k[i+2]) << 16 n |= uint64(k[i+3]) << 24 n |= uint64(k[i+4]) << 32 n |= uint64(k[i+5]) << 40 n |= uint64(k[i+6]) << 48 return n }
go
func (k internalKey) seqNum() uint64 { i := len(k) - 7 n := uint64(k[i+0]) n |= uint64(k[i+1]) << 8 n |= uint64(k[i+2]) << 16 n |= uint64(k[i+3]) << 24 n |= uint64(k[i+4]) << 32 n |= uint64(k[i+5]) << 40 n |= uint64(k[i+6]) << 48 return n }
[ "func", "(", "k", "internalKey", ")", "seqNum", "(", ")", "uint64", "{", "i", ":=", "len", "(", "k", ")", "-", "7", "\n", "n", ":=", "uint64", "(", "k", "[", "i", "+", "0", "]", ")", "\n", "n", "|=", "uint64", "(", "k", "[", "i", "+", "1"...
// seqNum returns the sequence number of an internal key. // seqNum may panic if k is not valid.
[ "seqNum", "returns", "the", "sequence", "number", "of", "an", "internal", "key", ".", "seqNum", "may", "panic", "if", "k", "is", "not", "valid", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/ikey.go#L88-L98
26,811
golang/leveldb
ikey.go
clone
func (k internalKey) clone() internalKey { x := make(internalKey, len(k)) copy(x, k) return x }
go
func (k internalKey) clone() internalKey { x := make(internalKey, len(k)) copy(x, k) return x }
[ "func", "(", "k", "internalKey", ")", "clone", "(", ")", "internalKey", "{", "x", ":=", "make", "(", "internalKey", ",", "len", "(", "k", ")", ")", "\n", "copy", "(", "x", ",", "k", ")", "\n", "return", "x", "\n", "}" ]
// clone returns an internalKey that has the same contents but is backed by a // different array.
[ "clone", "returns", "an", "internalKey", "that", "has", "the", "same", "contents", "but", "is", "backed", "by", "a", "different", "array", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/ikey.go#L102-L106
26,812
golang/leveldb
record/record.go
Next
func (r *Reader) Next() (io.Reader, error) { r.seq++ if r.err != nil { return nil, r.err } r.i = r.j r.err = r.nextChunk(true) if r.err != nil { return nil, r.err } r.started = true return singleReader{r, r.seq}, nil }
go
func (r *Reader) Next() (io.Reader, error) { r.seq++ if r.err != nil { return nil, r.err } r.i = r.j r.err = r.nextChunk(true) if r.err != nil { return nil, r.err } r.started = true return singleReader{r, r.seq}, nil }
[ "func", "(", "r", "*", "Reader", ")", "Next", "(", ")", "(", "io", ".", "Reader", ",", "error", ")", "{", "r", ".", "seq", "++", "\n", "if", "r", ".", "err", "!=", "nil", "{", "return", "nil", ",", "r", ".", "err", "\n", "}", "\n", "r", "...
// Next returns a reader for the next record. It returns io.EOF if there are no // more records. The reader returned becomes stale after the next Next call, // and should no longer be used.
[ "Next", "returns", "a", "reader", "for", "the", "next", "record", ".", "It", "returns", "io", ".", "EOF", "if", "there", "are", "no", "more", "records", ".", "The", "reader", "returned", "becomes", "stale", "after", "the", "next", "Next", "call", "and", ...
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/record/record.go#L213-L225
26,813
golang/leveldb
record/record.go
Recover
func (r *Reader) Recover() { if r.err == nil { return } r.recovering = true r.err = nil // Discard the rest of the current block. r.i, r.j, r.last = r.n, r.n, false // Invalidate any outstanding singleReader. r.seq++ return }
go
func (r *Reader) Recover() { if r.err == nil { return } r.recovering = true r.err = nil // Discard the rest of the current block. r.i, r.j, r.last = r.n, r.n, false // Invalidate any outstanding singleReader. r.seq++ return }
[ "func", "(", "r", "*", "Reader", ")", "Recover", "(", ")", "{", "if", "r", ".", "err", "==", "nil", "{", "return", "\n", "}", "\n", "r", ".", "recovering", "=", "true", "\n", "r", ".", "err", "=", "nil", "\n", "// Discard the rest of the current bloc...
// Recover clears any errors read so far, so that calling Next will start // reading from the next good 32KiB block. If there are no such blocks, Next // will return io.EOF. Recover also marks the current reader, the one most // recently returned by Next, as stale. If Recover is called without any // prior error, then ...
[ "Recover", "clears", "any", "errors", "read", "so", "far", "so", "that", "calling", "Next", "will", "start", "reading", "from", "the", "next", "good", "32KiB", "block", ".", "If", "there", "are", "no", "such", "blocks", "Next", "will", "return", "io", "....
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/record/record.go#L232-L243
26,814
golang/leveldb
record/record.go
SeekRecord
func (r *Reader) SeekRecord(offset int64) error { r.seq++ if r.err != nil { return r.err } s, ok := r.r.(io.Seeker) if !ok { return ErrNotAnIOSeeker } // Only seek to an exact block offset. c := int(offset & blockSizeMask) if _, r.err = s.Seek(offset&^blockSizeMask, io.SeekStart); r.err != nil { return...
go
func (r *Reader) SeekRecord(offset int64) error { r.seq++ if r.err != nil { return r.err } s, ok := r.r.(io.Seeker) if !ok { return ErrNotAnIOSeeker } // Only seek to an exact block offset. c := int(offset & blockSizeMask) if _, r.err = s.Seek(offset&^blockSizeMask, io.SeekStart); r.err != nil { return...
[ "func", "(", "r", "*", "Reader", ")", "SeekRecord", "(", "offset", "int64", ")", "error", "{", "r", ".", "seq", "++", "\n", "if", "r", ".", "err", "!=", "nil", "{", "return", "r", ".", "err", "\n", "}", "\n\n", "s", ",", "ok", ":=", "r", ".",...
// SeekRecord seeks in the underlying io.Reader such that calling r.Next // returns the record whose first chunk header starts at the provided offset. // Its behavior is undefined if the argument given is not such an offset, as // the bytes at that offset may coincidentally appear to be a valid header. // // It returns...
[ "SeekRecord", "seeks", "in", "the", "underlying", "io", ".", "Reader", "such", "that", "calling", "r", ".", "Next", "returns", "the", "record", "whose", "first", "chunk", "header", "starts", "at", "the", "provided", "offset", ".", "Its", "behavior", "is", ...
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/record/record.go#L263-L292
26,815
golang/leveldb
record/record.go
Next
func (w *Writer) Next() (io.Writer, error) { w.seq++ if w.err != nil { return nil, w.err } if w.pending { w.fillHeader(true) } w.i = w.j w.j = w.j + headerSize // Check if there is room in the block for the header. if w.j > blockSize { // Fill in the rest of the block with zeroes. for k := w.i; k < blo...
go
func (w *Writer) Next() (io.Writer, error) { w.seq++ if w.err != nil { return nil, w.err } if w.pending { w.fillHeader(true) } w.i = w.j w.j = w.j + headerSize // Check if there is room in the block for the header. if w.j > blockSize { // Fill in the rest of the block with zeroes. for k := w.i; k < blo...
[ "func", "(", "w", "*", "Writer", ")", "Next", "(", ")", "(", "io", ".", "Writer", ",", "error", ")", "{", "w", ".", "seq", "++", "\n", "if", "w", ".", "err", "!=", "nil", "{", "return", "nil", ",", "w", ".", "err", "\n", "}", "\n", "if", ...
// Next returns a writer for the next record. The writer returned becomes stale // after the next Close, Flush or Next call, and should no longer be used.
[ "Next", "returns", "a", "writer", "for", "the", "next", "record", ".", "The", "writer", "returned", "becomes", "stale", "after", "the", "next", "Close", "Flush", "or", "Next", "call", "and", "should", "no", "longer", "be", "used", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/record/record.go#L447-L472
26,816
golang/leveldb
record/record.go
LastRecordOffset
func (w *Writer) LastRecordOffset() (int64, error) { if w.err != nil { return 0, w.err } if w.lastRecordOffset < 0 { return 0, ErrNoLastRecord } return w.lastRecordOffset, nil }
go
func (w *Writer) LastRecordOffset() (int64, error) { if w.err != nil { return 0, w.err } if w.lastRecordOffset < 0 { return 0, ErrNoLastRecord } return w.lastRecordOffset, nil }
[ "func", "(", "w", "*", "Writer", ")", "LastRecordOffset", "(", ")", "(", "int64", ",", "error", ")", "{", "if", "w", ".", "err", "!=", "nil", "{", "return", "0", ",", "w", ".", "err", "\n", "}", "\n", "if", "w", ".", "lastRecordOffset", "<", "0...
// LastRecordOffset returns the offset in the underlying io.Writer of the last // record so far - the one created by the most recent Next call. It is the // offset of the first chunk header, suitable to pass to Reader.SeekRecord. // // If that io.Writer also implements io.Seeker, the return value is an absolute // offs...
[ "LastRecordOffset", "returns", "the", "offset", "in", "the", "underlying", "io", ".", "Writer", "of", "the", "last", "record", "so", "far", "-", "the", "one", "created", "by", "the", "most", "recent", "Next", "call", ".", "It", "is", "the", "offset", "of...
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/record/record.go#L486-L494
26,817
golang/leveldb
table/writer.go
Get
func (w *Writer) Get(key []byte, o *db.ReadOptions) ([]byte, error) { return nil, errors.New("leveldb/table: cannot Get from a write-only table") }
go
func (w *Writer) Get(key []byte, o *db.ReadOptions) ([]byte, error) { return nil, errors.New("leveldb/table: cannot Get from a write-only table") }
[ "func", "(", "w", "*", "Writer", ")", "Get", "(", "key", "[", "]", "byte", ",", "o", "*", "db", ".", "ReadOptions", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "return", "nil", ",", "errors", ".", "New", "(", "\"", "\"", ")", "\n", ...
// Get is provided to implement the DB interface, but returns an error, as a // Writer cannot read from a table.
[ "Get", "is", "provided", "to", "implement", "the", "DB", "interface", "but", "returns", "an", "error", "as", "a", "Writer", "cannot", "read", "from", "a", "table", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/table/writer.go#L170-L172
26,818
golang/leveldb
table/writer.go
Find
func (w *Writer) Find(key []byte, o *db.ReadOptions) db.Iterator { return &tableIter{ err: errors.New("leveldb/table: cannot Find from a write-only table"), } }
go
func (w *Writer) Find(key []byte, o *db.ReadOptions) db.Iterator { return &tableIter{ err: errors.New("leveldb/table: cannot Find from a write-only table"), } }
[ "func", "(", "w", "*", "Writer", ")", "Find", "(", "key", "[", "]", "byte", ",", "o", "*", "db", ".", "ReadOptions", ")", "db", ".", "Iterator", "{", "return", "&", "tableIter", "{", "err", ":", "errors", ".", "New", "(", "\"", "\"", ")", ",", ...
// Find is provided to implement the DB interface, but returns an error, as a // Writer cannot read from a table.
[ "Find", "is", "provided", "to", "implement", "the", "DB", "interface", "but", "returns", "an", "error", "as", "a", "Writer", "cannot", "read", "from", "a", "table", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/table/writer.go#L182-L186
26,819
golang/leveldb
table/writer.go
flushPendingBH
func (w *Writer) flushPendingBH(key []byte) { if w.pendingBH.length == 0 { // A valid blockHandle must be non-zero. // In particular, it must have a non-zero length. return } n0 := len(w.indexKeys) w.indexKeys = w.cmp.AppendSeparator(w.indexKeys, w.prevKey, key) n1 := len(w.indexKeys) w.indexEntries = appen...
go
func (w *Writer) flushPendingBH(key []byte) { if w.pendingBH.length == 0 { // A valid blockHandle must be non-zero. // In particular, it must have a non-zero length. return } n0 := len(w.indexKeys) w.indexKeys = w.cmp.AppendSeparator(w.indexKeys, w.prevKey, key) n1 := len(w.indexKeys) w.indexEntries = appen...
[ "func", "(", "w", "*", "Writer", ")", "flushPendingBH", "(", "key", "[", "]", "byte", ")", "{", "if", "w", ".", "pendingBH", ".", "length", "==", "0", "{", "// A valid blockHandle must be non-zero.", "// In particular, it must have a non-zero length.", "return", "...
// flushPendingBH adds any pending block handle to the index entries.
[ "flushPendingBH", "adds", "any", "pending", "block", "handle", "to", "the", "index", "entries", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/table/writer.go#L216-L227
26,820
golang/leveldb
table/writer.go
finishBlock
func (w *Writer) finishBlock() (blockHandle, error) { // Write the restart points to the buffer. if w.nEntries == 0 { // Every block must have at least one restart point. w.restarts = w.restarts[:1] w.restarts[0] = 0 } tmp4 := w.tmp[:4] for _, x := range w.restarts { binary.LittleEndian.PutUint32(tmp4, x) ...
go
func (w *Writer) finishBlock() (blockHandle, error) { // Write the restart points to the buffer. if w.nEntries == 0 { // Every block must have at least one restart point. w.restarts = w.restarts[:1] w.restarts[0] = 0 } tmp4 := w.tmp[:4] for _, x := range w.restarts { binary.LittleEndian.PutUint32(tmp4, x) ...
[ "func", "(", "w", "*", "Writer", ")", "finishBlock", "(", ")", "(", "blockHandle", ",", "error", ")", "{", "// Write the restart points to the buffer.", "if", "w", ".", "nEntries", "==", "0", "{", "// Every block must have at least one restart point.", "w", ".", "...
// finishBlock finishes the current block and returns its block handle, which is // its offset and length in the table.
[ "finishBlock", "finishes", "the", "current", "block", "and", "returns", "its", "block", "handle", "which", "is", "its", "offset", "and", "length", "in", "the", "table", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/table/writer.go#L249-L289
26,821
golang/leveldb
table/writer.go
NewWriter
func NewWriter(f db.File, o *db.Options) *Writer { w := &Writer{ closer: f, blockRestartInterval: o.GetBlockRestartInterval(), blockSize: o.GetBlockSize(), cmp: o.GetComparer(), compression: o.GetCompression(), filter: filterWriter{ policy: o.GetFilterP...
go
func NewWriter(f db.File, o *db.Options) *Writer { w := &Writer{ closer: f, blockRestartInterval: o.GetBlockRestartInterval(), blockSize: o.GetBlockSize(), cmp: o.GetComparer(), compression: o.GetCompression(), filter: filterWriter{ policy: o.GetFilterP...
[ "func", "NewWriter", "(", "f", "db", ".", "File", ",", "o", "*", "db", ".", "Options", ")", "*", "Writer", "{", "w", ":=", "&", "Writer", "{", "closer", ":", "f", ",", "blockRestartInterval", ":", "o", ".", "GetBlockRestartInterval", "(", ")", ",", ...
// NewWriter returns a new table writer for the file. Closing the writer will // close the file.
[ "NewWriter", "returns", "a", "new", "table", "writer", "for", "the", "file", ".", "Closing", "the", "writer", "will", "close", "the", "file", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/table/writer.go#L409-L437
26,822
golang/leveldb
memdb/memdb.go
ApproximateMemoryUsage
func (m *MemDB) ApproximateMemoryUsage() int { m.mutex.RLock() defer m.mutex.RUnlock() return len(m.kvData) }
go
func (m *MemDB) ApproximateMemoryUsage() int { m.mutex.RLock() defer m.mutex.RUnlock() return len(m.kvData) }
[ "func", "(", "m", "*", "MemDB", ")", "ApproximateMemoryUsage", "(", ")", "int", "{", "m", ".", "mutex", ".", "RLock", "(", ")", "\n", "defer", "m", ".", "mutex", ".", "RUnlock", "(", ")", "\n", "return", "len", "(", "m", ".", "kvData", ")", "\n",...
// ApproximateMemoryUsage returns the approximate memory usage of the MemDB.
[ "ApproximateMemoryUsage", "returns", "the", "approximate", "memory", "usage", "of", "the", "MemDB", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/memdb/memdb.go#L223-L227
26,823
golang/leveldb
memdb/memdb.go
New
func New(o *db.Options) *MemDB { return &MemDB{ height: 1, cmp: o.GetComparer(), kvData: make([]byte, 0, 4096), // The first maxHeight values of nodeData are the next nodes after the // head node at each possible height. Their initial value is zeroNode. nodeData: make([]int, maxHeight, 256), } }
go
func New(o *db.Options) *MemDB { return &MemDB{ height: 1, cmp: o.GetComparer(), kvData: make([]byte, 0, 4096), // The first maxHeight values of nodeData are the next nodes after the // head node at each possible height. Their initial value is zeroNode. nodeData: make([]int, maxHeight, 256), } }
[ "func", "New", "(", "o", "*", "db", ".", "Options", ")", "*", "MemDB", "{", "return", "&", "MemDB", "{", "height", ":", "1", ",", "cmp", ":", "o", ".", "GetComparer", "(", ")", ",", "kvData", ":", "make", "(", "[", "]", "byte", ",", "0", ",",...
// New returns a new MemDB.
[ "New", "returns", "a", "new", "MemDB", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/memdb/memdb.go#L237-L246
26,824
golang/leveldb
version_set.go
createManifest
func (vs *versionSet) createManifest(dirname string) (err error) { var ( filename = dbFilename(dirname, fileTypeManifest, vs.manifestFileNumber) manifestFile db.File manifest *record.Writer ) defer func() { if manifest != nil { manifest.Close() } if manifestFile != nil { manifestFile.Close(...
go
func (vs *versionSet) createManifest(dirname string) (err error) { var ( filename = dbFilename(dirname, fileTypeManifest, vs.manifestFileNumber) manifestFile db.File manifest *record.Writer ) defer func() { if manifest != nil { manifest.Close() } if manifestFile != nil { manifestFile.Close(...
[ "func", "(", "vs", "*", "versionSet", ")", "createManifest", "(", "dirname", "string", ")", "(", "err", "error", ")", "{", "var", "(", "filename", "=", "dbFilename", "(", "dirname", ",", "fileTypeManifest", ",", "vs", ".", "manifestFileNumber", ")", "\n", ...
// createManifest creates a manifest file that contains a snapshot of vs.
[ "createManifest", "creates", "a", "manifest", "file", "that", "contains", "a", "snapshot", "of", "vs", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/version_set.go#L193-L241
26,825
golang/leveldb
leveldb.go
replayLogFile
func (d *DB) replayLogFile(ve *versionEdit, fs db.FileSystem, filename string) (maxSeqNum uint64, err error) { file, err := fs.Open(filename) if err != nil { return 0, err } defer file.Close() var ( mem *memdb.MemDB batchBuf = new(bytes.Buffer) ikey = make(internalKey, 512) rr = record.Ne...
go
func (d *DB) replayLogFile(ve *versionEdit, fs db.FileSystem, filename string) (maxSeqNum uint64, err error) { file, err := fs.Open(filename) if err != nil { return 0, err } defer file.Close() var ( mem *memdb.MemDB batchBuf = new(bytes.Buffer) ikey = make(internalKey, 512) rr = record.Ne...
[ "func", "(", "d", "*", "DB", ")", "replayLogFile", "(", "ve", "*", "versionEdit", ",", "fs", "db", ".", "FileSystem", ",", "filename", "string", ")", "(", "maxSeqNum", "uint64", ",", "err", "error", ")", "{", "file", ",", "err", ":=", "fs", ".", "O...
// replayLogFile replays the edits in the named log file. // // d.mu must be held when calling this, but the mutex may be dropped and // re-acquired during the course of this method.
[ "replayLogFile", "replays", "the", "edits", "in", "the", "named", "log", "file", ".", "d", ".", "mu", "must", "be", "held", "when", "calling", "this", "but", "the", "mutex", "may", "be", "dropped", "and", "re", "-", "acquired", "during", "the", "course",...
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/leveldb.go#L358-L445
26,826
golang/leveldb
leveldb.go
makeRoomForWrite
func (d *DB) makeRoomForWrite(force bool) error { allowDelay := !force for { // TODO: check any previous sticky error, if the paranoid option is set. if allowDelay && len(d.versions.currentVersion().files[0]) > l0SlowdownWritesTrigger { // We are getting close to hitting a hard limit on the number of // L0...
go
func (d *DB) makeRoomForWrite(force bool) error { allowDelay := !force for { // TODO: check any previous sticky error, if the paranoid option is set. if allowDelay && len(d.versions.currentVersion().files[0]) > l0SlowdownWritesTrigger { // We are getting close to hitting a hard limit on the number of // L0...
[ "func", "(", "d", "*", "DB", ")", "makeRoomForWrite", "(", "force", "bool", ")", "error", "{", "allowDelay", ":=", "!", "force", "\n", "for", "{", "// TODO: check any previous sticky error, if the paranoid option is set.", "if", "allowDelay", "&&", "len", "(", "d"...
// makeRoomForWrite ensures that there is room in d.mem for the next write. // // d.mu must be held when calling this, but the mutex may be dropped and // re-acquired during the course of this method.
[ "makeRoomForWrite", "ensures", "that", "there", "is", "room", "in", "d", ".", "mem", "for", "the", "next", "write", ".", "d", ".", "mu", "must", "be", "held", "when", "calling", "this", "but", "the", "mutex", "may", "be", "dropped", "and", "re", "-", ...
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/leveldb.go#L564-L623
26,827
golang/leveldb
leveldb.go
deleteObsoleteFiles
func (d *DB) deleteObsoleteFiles() { liveFileNums := map[uint64]struct{}{} for fileNum := range d.pendingOutputs { liveFileNums[fileNum] = struct{}{} } d.versions.addLiveFileNums(liveFileNums) logNumber := d.versions.logNumber manifestFileNumber := d.versions.manifestFileNumber // Release the d.mu lock while ...
go
func (d *DB) deleteObsoleteFiles() { liveFileNums := map[uint64]struct{}{} for fileNum := range d.pendingOutputs { liveFileNums[fileNum] = struct{}{} } d.versions.addLiveFileNums(liveFileNums) logNumber := d.versions.logNumber manifestFileNumber := d.versions.manifestFileNumber // Release the d.mu lock while ...
[ "func", "(", "d", "*", "DB", ")", "deleteObsoleteFiles", "(", ")", "{", "liveFileNums", ":=", "map", "[", "uint64", "]", "struct", "{", "}", "{", "}", "\n", "for", "fileNum", ":=", "range", "d", ".", "pendingOutputs", "{", "liveFileNums", "[", "fileNum...
// deleteObsoleteFiles deletes those files that are no longer needed. // // d.mu must be held when calling this, but the mutex may be dropped and // re-acquired during the course of this method.
[ "deleteObsoleteFiles", "deletes", "those", "files", "that", "are", "no", "longer", "needed", ".", "d", ".", "mu", "must", "be", "held", "when", "calling", "this", "but", "the", "mutex", "may", "be", "dropped", "and", "re", "-", "acquired", "during", "the",...
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/leveldb.go#L629-L673
26,828
golang/leveldb
memfs/memfs.go
New
func New() db.FileSystem { return &fileSystem{ root: &node{ children: make(map[string]*node), isDir: true, }, } }
go
func New() db.FileSystem { return &fileSystem{ root: &node{ children: make(map[string]*node), isDir: true, }, } }
[ "func", "New", "(", ")", "db", ".", "FileSystem", "{", "return", "&", "fileSystem", "{", "root", ":", "&", "node", "{", "children", ":", "make", "(", "map", "[", "string", "]", "*", "node", ")", ",", "isDir", ":", "true", ",", "}", ",", "}", "\...
// New returns a new memory-backed db.FileSystem implementation.
[ "New", "returns", "a", "new", "memory", "-", "backed", "db", ".", "FileSystem", "implementation", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/memfs/memfs.go#L34-L41
26,829
golang/leveldb
version_edit.go
apply
func (b *bulkVersionEdit) apply(base *version, icmp db.Comparer) (*version, error) { v := new(version) for level := range v.files { combined := [2][]fileMetadata{ nil, b.added[level], } if base != nil { combined[0] = base.files[level] } n := len(combined[0]) + len(combined[1]) if n == 0 { cont...
go
func (b *bulkVersionEdit) apply(base *version, icmp db.Comparer) (*version, error) { v := new(version) for level := range v.files { combined := [2][]fileMetadata{ nil, b.added[level], } if base != nil { combined[0] = base.files[level] } n := len(combined[0]) + len(combined[1]) if n == 0 { cont...
[ "func", "(", "b", "*", "bulkVersionEdit", ")", "apply", "(", "base", "*", "version", ",", "icmp", "db", ".", "Comparer", ")", "(", "*", "version", ",", "error", ")", "{", "v", ":=", "new", "(", "version", ")", "\n", "for", "level", ":=", "range", ...
// apply applies the delta b to a base version to produce a new version. The // new version is consistent with respect to the internal key comparer icmp. // // base may be nil, which is equivalent to a pointer to a zero version.
[ "apply", "applies", "the", "delta", "b", "to", "a", "base", "version", "to", "produce", "a", "new", "version", ".", "The", "new", "version", "is", "consistent", "with", "respect", "to", "the", "internal", "key", "comparer", "icmp", ".", "base", "may", "b...
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/version_edit.go#L324-L364
26,830
golang/leveldb
batch.go
Set
func (b *Batch) Set(key, value []byte) { if len(b.data) == 0 { b.init(len(key) + len(value) + 2*binary.MaxVarintLen64 + batchHeaderLen) } if b.increment() { b.data = append(b.data, byte(internalKeyKindSet)) b.appendStr(key) b.appendStr(value) } }
go
func (b *Batch) Set(key, value []byte) { if len(b.data) == 0 { b.init(len(key) + len(value) + 2*binary.MaxVarintLen64 + batchHeaderLen) } if b.increment() { b.data = append(b.data, byte(internalKeyKindSet)) b.appendStr(key) b.appendStr(value) } }
[ "func", "(", "b", "*", "Batch", ")", "Set", "(", "key", ",", "value", "[", "]", "byte", ")", "{", "if", "len", "(", "b", ".", "data", ")", "==", "0", "{", "b", ".", "init", "(", "len", "(", "key", ")", "+", "len", "(", "value", ")", "+", ...
// Set adds an action to the batch that sets the key to map to the value.
[ "Set", "adds", "an", "action", "to", "the", "batch", "that", "sets", "the", "key", "to", "map", "to", "the", "value", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/batch.go#L31-L40
26,831
golang/leveldb
batch.go
Delete
func (b *Batch) Delete(key []byte) { if len(b.data) == 0 { b.init(len(key) + binary.MaxVarintLen64 + batchHeaderLen) } if b.increment() { b.data = append(b.data, byte(internalKeyKindDelete)) b.appendStr(key) } }
go
func (b *Batch) Delete(key []byte) { if len(b.data) == 0 { b.init(len(key) + binary.MaxVarintLen64 + batchHeaderLen) } if b.increment() { b.data = append(b.data, byte(internalKeyKindDelete)) b.appendStr(key) } }
[ "func", "(", "b", "*", "Batch", ")", "Delete", "(", "key", "[", "]", "byte", ")", "{", "if", "len", "(", "b", ".", "data", ")", "==", "0", "{", "b", ".", "init", "(", "len", "(", "key", ")", "+", "binary", ".", "MaxVarintLen64", "+", "batchHe...
// Delete adds an action to the batch that deletes the entry for key.
[ "Delete", "adds", "an", "action", "to", "the", "batch", "that", "deletes", "the", "entry", "for", "key", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/batch.go#L43-L51
26,832
golang/leveldb
batch.go
next
func (t *batchIter) next() (kind internalKeyKind, ukey []byte, value []byte, ok bool) { p := *t if len(p) == 0 { return 0, nil, nil, false } kind, *t = internalKeyKind(p[0]), p[1:] if kind > internalKeyKindMax { return 0, nil, nil, false } ukey, ok = t.nextStr() if !ok { return 0, nil, nil, false } if k...
go
func (t *batchIter) next() (kind internalKeyKind, ukey []byte, value []byte, ok bool) { p := *t if len(p) == 0 { return 0, nil, nil, false } kind, *t = internalKeyKind(p[0]), p[1:] if kind > internalKeyKindMax { return 0, nil, nil, false } ukey, ok = t.nextStr() if !ok { return 0, nil, nil, false } if k...
[ "func", "(", "t", "*", "batchIter", ")", "next", "(", ")", "(", "kind", "internalKeyKind", ",", "ukey", "[", "]", "byte", ",", "value", "[", "]", "byte", ",", "ok", "bool", ")", "{", "p", ":=", "*", "t", "\n", "if", "len", "(", "p", ")", "=="...
// next returns the next operation in this batch. // The final return value is false if the batch is corrupt.
[ "next", "returns", "the", "next", "operation", "in", "this", "batch", ".", "The", "final", "return", "value", "is", "false", "if", "the", "batch", "is", "corrupt", "." ]
259d9253d71996b7778a3efb4144fe4892342b18
https://github.com/golang/leveldb/blob/259d9253d71996b7778a3efb4144fe4892342b18/batch.go#L116-L136
26,833
chzyer/readline
rawreader_windows.go
Read
func (r *RawReader) Read(buf []byte) (int, error) { ir := new(_INPUT_RECORD) var read int var err error next: err = kernel.ReadConsoleInputW(stdin, uintptr(unsafe.Pointer(ir)), 1, uintptr(unsafe.Pointer(&read)), ) if err != nil { return 0, err } if ir.EventType != EVENT_KEY { goto next } ker := (*_K...
go
func (r *RawReader) Read(buf []byte) (int, error) { ir := new(_INPUT_RECORD) var read int var err error next: err = kernel.ReadConsoleInputW(stdin, uintptr(unsafe.Pointer(ir)), 1, uintptr(unsafe.Pointer(&read)), ) if err != nil { return 0, err } if ir.EventType != EVENT_KEY { goto next } ker := (*_K...
[ "func", "(", "r", "*", "RawReader", ")", "Read", "(", "buf", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "ir", ":=", "new", "(", "_INPUT_RECORD", ")", "\n", "var", "read", "int", "\n", "var", "err", "error", "\n", "next", ":", "e...
// only process one action in one read
[ "only", "process", "one", "action", "in", "one", "read" ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/rawreader_windows.go#L40-L110
26,834
chzyer/readline
example/readline-pass-strength/readline-pass-strength.go
Colorize
func Colorize(msg string, color int) string { return ColorEscape(color) + msg + ColorResetEscape }
go
func Colorize(msg string, color int) string { return ColorEscape(color) + msg + ColorResetEscape }
[ "func", "Colorize", "(", "msg", "string", ",", "color", "int", ")", "string", "{", "return", "ColorEscape", "(", "color", ")", "+", "msg", "+", "ColorResetEscape", "\n", "}" ]
// Colorize the msg using ANSI color escapes
[ "Colorize", "the", "msg", "using", "ANSI", "color", "escapes" ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/example/readline-pass-strength/readline-pass-strength.go#L47-L49
26,835
chzyer/readline
history.go
historyUpdatePath
func (o *opHistory) historyUpdatePath(path string) { o.fdLock.Lock() defer o.fdLock.Unlock() f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666) if err != nil { return } o.fd = f r := bufio.NewReader(o.fd) total := 0 for ; ; total++ { line, err := r.ReadString('\n') if err != nil { br...
go
func (o *opHistory) historyUpdatePath(path string) { o.fdLock.Lock() defer o.fdLock.Unlock() f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_RDWR, 0666) if err != nil { return } o.fd = f r := bufio.NewReader(o.fd) total := 0 for ; ; total++ { line, err := r.ReadString('\n') if err != nil { br...
[ "func", "(", "o", "*", "opHistory", ")", "historyUpdatePath", "(", "path", "string", ")", "{", "o", ".", "fdLock", ".", "Lock", "(", ")", "\n", "defer", "o", ".", "fdLock", ".", "Unlock", "(", ")", "\n", "f", ",", "err", ":=", "os", ".", "OpenFil...
// only called by newOpHistory
[ "only", "called", "by", "newOpHistory" ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/history.go#L66-L95
26,836
chzyer/readline
utils_unix.go
SuspendMe
func SuspendMe() { p, _ := os.FindProcess(os.Getppid()) p.Signal(syscall.SIGTSTP) p, _ = os.FindProcess(os.Getpid()) p.Signal(syscall.SIGTSTP) }
go
func SuspendMe() { p, _ := os.FindProcess(os.Getppid()) p.Signal(syscall.SIGTSTP) p, _ = os.FindProcess(os.Getpid()) p.Signal(syscall.SIGTSTP) }
[ "func", "SuspendMe", "(", ")", "{", "p", ",", "_", ":=", "os", ".", "FindProcess", "(", "os", ".", "Getppid", "(", ")", ")", "\n", "p", ".", "Signal", "(", "syscall", ".", "SIGTSTP", ")", "\n", "p", ",", "_", "=", "os", ".", "FindProcess", "(",...
// SuspendMe use to send suspend signal to myself, when we in the raw mode. // For OSX it need to send to parent's pid // For Linux it need to send to myself
[ "SuspendMe", "use", "to", "send", "suspend", "signal", "to", "myself", "when", "we", "in", "the", "raw", "mode", ".", "For", "OSX", "it", "need", "to", "send", "to", "parent", "s", "pid", "For", "Linux", "it", "need", "to", "send", "to", "myself" ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/utils_unix.go#L23-L28
26,837
chzyer/readline
example/readline-demo/readline-demo.go
listFiles
func listFiles(path string) func(string) []string { return func(line string) []string { names := make([]string, 0) files, _ := ioutil.ReadDir(path) for _, f := range files { names = append(names, f.Name()) } return names } }
go
func listFiles(path string) func(string) []string { return func(line string) []string { names := make([]string, 0) files, _ := ioutil.ReadDir(path) for _, f := range files { names = append(names, f.Name()) } return names } }
[ "func", "listFiles", "(", "path", "string", ")", "func", "(", "string", ")", "[", "]", "string", "{", "return", "func", "(", "line", "string", ")", "[", "]", "string", "{", "names", ":=", "make", "(", "[", "]", "string", ",", "0", ")", "\n", "fil...
// Function constructor - constructs new function for listing given directory
[ "Function", "constructor", "-", "constructs", "new", "function", "for", "listing", "given", "directory" ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/example/readline-demo/readline-demo.go#L21-L30
26,838
chzyer/readline
terminal.go
SleepToResume
func (t *Terminal) SleepToResume() { if !atomic.CompareAndSwapInt32(&t.sleeping, 0, 1) { return } defer atomic.StoreInt32(&t.sleeping, 0) t.ExitRawMode() ch := WaitForResume() SuspendMe() <-ch t.EnterRawMode() }
go
func (t *Terminal) SleepToResume() { if !atomic.CompareAndSwapInt32(&t.sleeping, 0, 1) { return } defer atomic.StoreInt32(&t.sleeping, 0) t.ExitRawMode() ch := WaitForResume() SuspendMe() <-ch t.EnterRawMode() }
[ "func", "(", "t", "*", "Terminal", ")", "SleepToResume", "(", ")", "{", "if", "!", "atomic", ".", "CompareAndSwapInt32", "(", "&", "t", ".", "sleeping", ",", "0", ",", "1", ")", "{", "return", "\n", "}", "\n", "defer", "atomic", ".", "StoreInt32", ...
// SleepToResume will sleep myself, and return only if I'm resumed.
[ "SleepToResume", "will", "sleep", "myself", "and", "return", "only", "if", "I", "m", "resumed", "." ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/terminal.go#L43-L54
26,839
chzyer/readline
operation.go
SaveHistory
func (o *Operation) SaveHistory(content string) error { return o.history.New([]rune(content)) }
go
func (o *Operation) SaveHistory(content string) error { return o.history.New([]rune(content)) }
[ "func", "(", "o", "*", "Operation", ")", "SaveHistory", "(", "content", "string", ")", "error", "{", "return", "o", ".", "history", ".", "New", "(", "[", "]", "rune", "(", "content", ")", ")", "\n", "}" ]
// if err is not nil, it just mean it fail to write to file // other things goes fine.
[ "if", "err", "is", "not", "nil", "it", "just", "mean", "it", "fail", "to", "write", "to", "file", "other", "things", "goes", "fine", "." ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/operation.go#L493-L495
26,840
chzyer/readline
std.go
getInstance
func getInstance() *Instance { stdOnce.Do(func() { std, _ = NewEx(&Config{ DisableAutoSaveHistory: true, }) }) return std }
go
func getInstance() *Instance { stdOnce.Do(func() { std, _ = NewEx(&Config{ DisableAutoSaveHistory: true, }) }) return std }
[ "func", "getInstance", "(", ")", "*", "Instance", "{", "stdOnce", ".", "Do", "(", "func", "(", ")", "{", "std", ",", "_", "=", "NewEx", "(", "&", "Config", "{", "DisableAutoSaveHistory", ":", "true", ",", "}", ")", "\n", "}", ")", "\n", "return", ...
// global instance will not submit history automatic
[ "global", "instance", "will", "not", "submit", "history", "automatic" ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/std.go#L22-L29
26,841
chzyer/readline
std.go
SetHistoryPath
func SetHistoryPath(fp string) { ins := getInstance() cfg := ins.Config.Clone() cfg.HistoryFile = fp ins.SetConfig(cfg) }
go
func SetHistoryPath(fp string) { ins := getInstance() cfg := ins.Config.Clone() cfg.HistoryFile = fp ins.SetConfig(cfg) }
[ "func", "SetHistoryPath", "(", "fp", "string", ")", "{", "ins", ":=", "getInstance", "(", ")", "\n", "cfg", ":=", "ins", ".", "Config", ".", "Clone", "(", ")", "\n", "cfg", ".", "HistoryFile", "=", "fp", "\n", "ins", ".", "SetConfig", "(", "cfg", "...
// let readline load history from filepath // and try to persist history into disk // set fp to "" to prevent readline persisting history to disk // so the `AddHistory` will return nil error forever.
[ "let", "readline", "load", "history", "from", "filepath", "and", "try", "to", "persist", "history", "into", "disk", "set", "fp", "to", "to", "prevent", "readline", "persisting", "history", "to", "disk", "so", "the", "AddHistory", "will", "return", "nil", "er...
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/std.go#L35-L40
26,842
chzyer/readline
std.go
SetAutoComplete
func SetAutoComplete(completer AutoCompleter) { ins := getInstance() cfg := ins.Config.Clone() cfg.AutoComplete = completer ins.SetConfig(cfg) }
go
func SetAutoComplete(completer AutoCompleter) { ins := getInstance() cfg := ins.Config.Clone() cfg.AutoComplete = completer ins.SetConfig(cfg) }
[ "func", "SetAutoComplete", "(", "completer", "AutoCompleter", ")", "{", "ins", ":=", "getInstance", "(", ")", "\n", "cfg", ":=", "ins", ".", "Config", ".", "Clone", "(", ")", "\n", "cfg", ".", "AutoComplete", "=", "completer", "\n", "ins", ".", "SetConfi...
// set auto completer to global instance
[ "set", "auto", "completer", "to", "global", "instance" ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/std.go#L43-L48
26,843
chzyer/readline
std.go
Line
func Line(prompt string) (string, error) { ins := getInstance() ins.SetPrompt(prompt) return ins.Readline() }
go
func Line(prompt string) (string, error) { ins := getInstance() ins.SetPrompt(prompt) return ins.Readline() }
[ "func", "Line", "(", "prompt", "string", ")", "(", "string", ",", "error", ")", "{", "ins", ":=", "getInstance", "(", ")", "\n", "ins", ".", "SetPrompt", "(", "prompt", ")", "\n", "return", "ins", ".", "Readline", "(", ")", "\n", "}" ]
// readline with global configs
[ "readline", "with", "global", "configs" ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/std.go#L63-L67
26,844
chzyer/readline
std.go
NewFillableStdin
func NewFillableStdin(stdin io.Reader) (io.ReadCloser, io.Writer) { r, w := io.Pipe() s := &FillableStdin{ stdinBuffer: r, stdin: stdin, } s.ioloop() return s, w }
go
func NewFillableStdin(stdin io.Reader) (io.ReadCloser, io.Writer) { r, w := io.Pipe() s := &FillableStdin{ stdinBuffer: r, stdin: stdin, } s.ioloop() return s, w }
[ "func", "NewFillableStdin", "(", "stdin", "io", ".", "Reader", ")", "(", "io", ".", "ReadCloser", ",", "io", ".", "Writer", ")", "{", "r", ",", "w", ":=", "io", ".", "Pipe", "(", ")", "\n", "s", ":=", "&", "FillableStdin", "{", "stdinBuffer", ":", ...
// NewFillableStdin gives you FillableStdin
[ "NewFillableStdin", "gives", "you", "FillableStdin" ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/std.go#L146-L154
26,845
chzyer/readline
std.go
Read
func (s *FillableStdin) Read(p []byte) (n int, err error) { s.Lock() i := len(s.buf) if len(p) < i { i = len(p) } if i > 0 { n := copy(p, s.buf) s.buf = s.buf[:0] cerr := s.bufErr s.bufErr = nil s.Unlock() return n, cerr } s.Unlock() n, err = s.stdin.Read(p) return n, err }
go
func (s *FillableStdin) Read(p []byte) (n int, err error) { s.Lock() i := len(s.buf) if len(p) < i { i = len(p) } if i > 0 { n := copy(p, s.buf) s.buf = s.buf[:0] cerr := s.bufErr s.bufErr = nil s.Unlock() return n, cerr } s.Unlock() n, err = s.stdin.Read(p) return n, err }
[ "func", "(", "s", "*", "FillableStdin", ")", "Read", "(", "p", "[", "]", "byte", ")", "(", "n", "int", ",", "err", "error", ")", "{", "s", ".", "Lock", "(", ")", "\n", "i", ":=", "len", "(", "s", ".", "buf", ")", "\n", "if", "len", "(", "...
// Read will read from the local buffer and if no data, read from stdin
[ "Read", "will", "read", "from", "the", "local", "buffer", "and", "if", "no", "data", "read", "from", "stdin" ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/std.go#L175-L192
26,846
chzyer/readline
runes.go
IndexAll
func (rs Runes) IndexAll(r, sub []rune) int { return rs.IndexAllEx(r, sub, false) }
go
func (rs Runes) IndexAll(r, sub []rune) int { return rs.IndexAllEx(r, sub, false) }
[ "func", "(", "rs", "Runes", ")", "IndexAll", "(", "r", ",", "sub", "[", "]", "rune", ")", "int", "{", "return", "rs", ".", "IndexAllEx", "(", "r", ",", "sub", ",", "false", ")", "\n", "}" ]
// Search in runes from front to end
[ "Search", "in", "runes", "from", "front", "to", "end" ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/runes.go#L84-L86
26,847
chzyer/readline
utils.go
WaitForResume
func WaitForResume() chan struct{} { ch := make(chan struct{}) var wg sync.WaitGroup wg.Add(1) go func() { ticker := time.NewTicker(10 * time.Millisecond) t := time.Now() wg.Done() for { now := <-ticker.C if now.Sub(t) > 100*time.Millisecond { break } t = now } ticker.Stop() ch <- stru...
go
func WaitForResume() chan struct{} { ch := make(chan struct{}) var wg sync.WaitGroup wg.Add(1) go func() { ticker := time.NewTicker(10 * time.Millisecond) t := time.Now() wg.Done() for { now := <-ticker.C if now.Sub(t) > 100*time.Millisecond { break } t = now } ticker.Stop() ch <- stru...
[ "func", "WaitForResume", "(", ")", "chan", "struct", "{", "}", "{", "ch", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "var", "wg", "sync", ".", "WaitGroup", "\n", "wg", ".", "Add", "(", "1", ")", "\n", "go", "func", "(", ")", "{",...
// WaitForResume need to call before current process got suspend. // It will run a ticker until a long duration is occurs, // which means this process is resumed.
[ "WaitForResume", "need", "to", "call", "before", "current", "process", "got", "suspend", ".", "It", "will", "run", "a", "ticker", "until", "a", "long", "duration", "is", "occurs", "which", "means", "this", "process", "is", "resumed", "." ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/utils.go#L59-L79
26,848
chzyer/readline
utils.go
escapeExKey
func escapeExKey(key *escapeKeyPair) rune { var r rune switch key.typ { case 'D': r = CharBackward case 'C': r = CharForward case 'A': r = CharPrev case 'B': r = CharNext case 'H': r = CharLineStart case 'F': r = CharLineEnd case '~': if key.attr == "3" { r = CharDelete } default: } retur...
go
func escapeExKey(key *escapeKeyPair) rune { var r rune switch key.typ { case 'D': r = CharBackward case 'C': r = CharForward case 'A': r = CharPrev case 'B': r = CharNext case 'H': r = CharLineStart case 'F': r = CharLineEnd case '~': if key.attr == "3" { r = CharDelete } default: } retur...
[ "func", "escapeExKey", "(", "key", "*", "escapeKeyPair", ")", "rune", "{", "var", "r", "rune", "\n", "switch", "key", ".", "typ", "{", "case", "'D'", ":", "r", "=", "CharBackward", "\n", "case", "'C'", ":", "r", "=", "CharForward", "\n", "case", "'A'...
// translate Esc[X
[ "translate", "Esc", "[", "X" ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/utils.go#L100-L122
26,849
chzyer/readline
utils.go
escapeKey
func escapeKey(r rune, reader *bufio.Reader) rune { switch r { case 'b': r = MetaBackward case 'f': r = MetaForward case 'd': r = MetaDelete case CharTranspose: r = MetaTranspose case CharBackspace: r = MetaBackspace case 'O': d, _, _ := reader.ReadRune() switch d { case 'H': r = CharLineStart...
go
func escapeKey(r rune, reader *bufio.Reader) rune { switch r { case 'b': r = MetaBackward case 'f': r = MetaForward case 'd': r = MetaDelete case CharTranspose: r = MetaTranspose case CharBackspace: r = MetaBackspace case 'O': d, _, _ := reader.ReadRune() switch d { case 'H': r = CharLineStart...
[ "func", "escapeKey", "(", "r", "rune", ",", "reader", "*", "bufio", ".", "Reader", ")", "rune", "{", "switch", "r", "{", "case", "'b'", ":", "r", "=", "MetaBackward", "\n", "case", "'f'", ":", "r", "=", "MetaForward", "\n", "case", "'d'", ":", "r",...
// translate EscX to Meta+X
[ "translate", "EscX", "to", "Meta", "+", "X" ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/utils.go#L163-L189
26,850
chzyer/readline
utils.go
LineCount
func LineCount(screenWidth, w int) int { r := w / screenWidth if w%screenWidth != 0 { r++ } return r }
go
func LineCount(screenWidth, w int) int { r := w / screenWidth if w%screenWidth != 0 { r++ } return r }
[ "func", "LineCount", "(", "screenWidth", ",", "w", "int", ")", "int", "{", "r", ":=", "w", "/", "screenWidth", "\n", "if", "w", "%", "screenWidth", "!=", "0", "{", "r", "++", "\n", "}", "\n", "return", "r", "\n", "}" ]
// calculate how many lines for N character
[ "calculate", "how", "many", "lines", "for", "N", "character" ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/utils.go#L210-L216
26,851
chzyer/readline
utils.go
Debug
func Debug(o ...interface{}) { f, _ := os.OpenFile("debug.tmp", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) fmt.Fprintln(f, o...) f.Close() }
go
func Debug(o ...interface{}) { f, _ := os.OpenFile("debug.tmp", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666) fmt.Fprintln(f, o...) f.Close() }
[ "func", "Debug", "(", "o", "...", "interface", "{", "}", ")", "{", "f", ",", "_", ":=", "os", ".", "OpenFile", "(", "\"", "\"", ",", "os", ".", "O_RDWR", "|", "os", ".", "O_CREATE", "|", "os", ".", "O_APPEND", ",", "0666", ")", "\n", "fmt", "...
// append log info to another file
[ "append", "log", "info", "to", "another", "file" ]
2972be24d48e78746da79ba8e24e8b488c9880de
https://github.com/chzyer/readline/blob/2972be24d48e78746da79ba8e24e8b488c9880de/utils.go#L273-L277
26,852
hoisie/web
web.go
SetCookie
func (ctx *Context) SetCookie(cookie *http.Cookie) { ctx.SetHeader("Set-Cookie", cookie.String(), false) }
go
func (ctx *Context) SetCookie(cookie *http.Cookie) { ctx.SetHeader("Set-Cookie", cookie.String(), false) }
[ "func", "(", "ctx", "*", "Context", ")", "SetCookie", "(", "cookie", "*", "http", ".", "Cookie", ")", "{", "ctx", ".", "SetHeader", "(", "\"", "\"", ",", "cookie", ".", "String", "(", ")", ",", "false", ")", "\n", "}" ]
// SetCookie adds a cookie header to the response.
[ "SetCookie", "adds", "a", "cookie", "header", "to", "the", "response", "." ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/web.go#L108-L110
26,853
hoisie/web
web.go
Process
func Process(c http.ResponseWriter, req *http.Request) { mainServer.Process(c, req) }
go
func Process(c http.ResponseWriter, req *http.Request) { mainServer.Process(c, req) }
[ "func", "Process", "(", "c", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "mainServer", ".", "Process", "(", "c", ",", "req", ")", "\n", "}" ]
// Process invokes the main server's routing system.
[ "Process", "invokes", "the", "main", "server", "s", "routing", "system", "." ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/web.go#L136-L138
26,854
hoisie/web
web.go
RunTLS
func RunTLS(addr string, config *tls.Config) { mainServer.RunTLS(addr, config) }
go
func RunTLS(addr string, config *tls.Config) { mainServer.RunTLS(addr, config) }
[ "func", "RunTLS", "(", "addr", "string", ",", "config", "*", "tls", ".", "Config", ")", "{", "mainServer", ".", "RunTLS", "(", "addr", ",", "config", ")", "\n", "}" ]
// RunTLS starts the web application and serves HTTPS requests for the main server.
[ "RunTLS", "starts", "the", "web", "application", "and", "serves", "HTTPS", "requests", "for", "the", "main", "server", "." ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/web.go#L146-L148
26,855
hoisie/web
web.go
Match
func Match(method string, route string, handler interface{}) { mainServer.addRoute(route, method, handler) }
go
func Match(method string, route string, handler interface{}) { mainServer.addRoute(route, method, handler) }
[ "func", "Match", "(", "method", "string", ",", "route", "string", ",", "handler", "interface", "{", "}", ")", "{", "mainServer", ".", "addRoute", "(", "route", ",", "method", ",", "handler", ")", "\n", "}" ]
// Match adds a handler for an arbitrary http method in the main server.
[ "Match", "adds", "a", "handler", "for", "an", "arbitrary", "http", "method", "in", "the", "main", "server", "." ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/web.go#L186-L188
26,856
hoisie/web
server.go
ServeHTTP
func (s *Server) ServeHTTP(c http.ResponseWriter, req *http.Request) { s.Process(c, req) }
go
func (s *Server) ServeHTTP(c http.ResponseWriter, req *http.Request) { s.Process(c, req) }
[ "func", "(", "s", "*", "Server", ")", "ServeHTTP", "(", "c", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "s", ".", "Process", "(", "c", ",", "req", ")", "\n", "}" ]
// ServeHTTP is the interface method for Go's http server package
[ "ServeHTTP", "is", "the", "interface", "method", "for", "Go", "s", "http", "server", "package" ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/server.go#L97-L99
26,857
hoisie/web
server.go
Process
func (s *Server) Process(c http.ResponseWriter, req *http.Request) { route := s.routeHandler(req, c) if route != nil { route.httpHandler.ServeHTTP(c, req) } }
go
func (s *Server) Process(c http.ResponseWriter, req *http.Request) { route := s.routeHandler(req, c) if route != nil { route.httpHandler.ServeHTTP(c, req) } }
[ "func", "(", "s", "*", "Server", ")", "Process", "(", "c", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "route", ":=", "s", ".", "routeHandler", "(", "req", ",", "c", ")", "\n", "if", "route", "!=", "nil", "{"...
// Process invokes the routing system for server s
[ "Process", "invokes", "the", "routing", "system", "for", "server", "s" ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/server.go#L102-L107
26,858
hoisie/web
server.go
Get
func (s *Server) Get(route string, handler interface{}) { s.addRoute(route, "GET", handler) }
go
func (s *Server) Get(route string, handler interface{}) { s.addRoute(route, "GET", handler) }
[ "func", "(", "s", "*", "Server", ")", "Get", "(", "route", "string", ",", "handler", "interface", "{", "}", ")", "{", "s", ".", "addRoute", "(", "route", ",", "\"", "\"", ",", "handler", ")", "\n", "}" ]
// Get adds a handler for the 'GET' http method for server s.
[ "Get", "adds", "a", "handler", "for", "the", "GET", "http", "method", "for", "server", "s", "." ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/server.go#L110-L112
26,859
hoisie/web
server.go
Post
func (s *Server) Post(route string, handler interface{}) { s.addRoute(route, "POST", handler) }
go
func (s *Server) Post(route string, handler interface{}) { s.addRoute(route, "POST", handler) }
[ "func", "(", "s", "*", "Server", ")", "Post", "(", "route", "string", ",", "handler", "interface", "{", "}", ")", "{", "s", ".", "addRoute", "(", "route", ",", "\"", "\"", ",", "handler", ")", "\n", "}" ]
// Post adds a handler for the 'POST' http method for server s.
[ "Post", "adds", "a", "handler", "for", "the", "POST", "http", "method", "for", "server", "s", "." ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/server.go#L115-L117
26,860
hoisie/web
server.go
Put
func (s *Server) Put(route string, handler interface{}) { s.addRoute(route, "PUT", handler) }
go
func (s *Server) Put(route string, handler interface{}) { s.addRoute(route, "PUT", handler) }
[ "func", "(", "s", "*", "Server", ")", "Put", "(", "route", "string", ",", "handler", "interface", "{", "}", ")", "{", "s", ".", "addRoute", "(", "route", ",", "\"", "\"", ",", "handler", ")", "\n", "}" ]
// Put adds a handler for the 'PUT' http method for server s.
[ "Put", "adds", "a", "handler", "for", "the", "PUT", "http", "method", "for", "server", "s", "." ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/server.go#L120-L122
26,861
hoisie/web
server.go
Delete
func (s *Server) Delete(route string, handler interface{}) { s.addRoute(route, "DELETE", handler) }
go
func (s *Server) Delete(route string, handler interface{}) { s.addRoute(route, "DELETE", handler) }
[ "func", "(", "s", "*", "Server", ")", "Delete", "(", "route", "string", ",", "handler", "interface", "{", "}", ")", "{", "s", ".", "addRoute", "(", "route", ",", "\"", "\"", ",", "handler", ")", "\n", "}" ]
// Delete adds a handler for the 'DELETE' http method for server s.
[ "Delete", "adds", "a", "handler", "for", "the", "DELETE", "http", "method", "for", "server", "s", "." ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/server.go#L125-L127
26,862
hoisie/web
server.go
Match
func (s *Server) Match(method string, route string, handler interface{}) { s.addRoute(route, method, handler) }
go
func (s *Server) Match(method string, route string, handler interface{}) { s.addRoute(route, method, handler) }
[ "func", "(", "s", "*", "Server", ")", "Match", "(", "method", "string", ",", "route", "string", ",", "handler", "interface", "{", "}", ")", "{", "s", ".", "addRoute", "(", "route", ",", "method", ",", "handler", ")", "\n", "}" ]
// Match adds a handler for an arbitrary http method for server s.
[ "Match", "adds", "a", "handler", "for", "an", "arbitrary", "http", "method", "for", "server", "s", "." ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/server.go#L130-L132
26,863
hoisie/web
server.go
Run
func (s *Server) Run(addr string) { s.initServer() mux := http.NewServeMux() if s.Config.Profiler { mux.Handle("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline)) mux.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile)) mux.Handle("/debug/pprof/heap", pprof.Handler("heap")) mux.Handle("/debu...
go
func (s *Server) Run(addr string) { s.initServer() mux := http.NewServeMux() if s.Config.Profiler { mux.Handle("/debug/pprof/cmdline", http.HandlerFunc(pprof.Cmdline)) mux.Handle("/debug/pprof/profile", http.HandlerFunc(pprof.Profile)) mux.Handle("/debug/pprof/heap", pprof.Handler("heap")) mux.Handle("/debu...
[ "func", "(", "s", "*", "Server", ")", "Run", "(", "addr", "string", ")", "{", "s", ".", "initServer", "(", ")", "\n\n", "mux", ":=", "http", ".", "NewServeMux", "(", ")", "\n", "if", "s", ".", "Config", ".", "Profiler", "{", "mux", ".", "Handle",...
// Run starts the web application and serves HTTP requests for s
[ "Run", "starts", "the", "web", "application", "and", "serves", "HTTP", "requests", "for", "s" ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/server.go#L145-L167
26,864
hoisie/web
server.go
RunFcgi
func (s *Server) RunFcgi(addr string) { s.initServer() s.Logger.Printf("web.go serving fcgi %s\n", addr) s.listenAndServeFcgi(addr) }
go
func (s *Server) RunFcgi(addr string) { s.initServer() s.Logger.Printf("web.go serving fcgi %s\n", addr) s.listenAndServeFcgi(addr) }
[ "func", "(", "s", "*", "Server", ")", "RunFcgi", "(", "addr", "string", ")", "{", "s", ".", "initServer", "(", ")", "\n", "s", ".", "Logger", ".", "Printf", "(", "\"", "\\n", "\"", ",", "addr", ")", "\n", "s", ".", "listenAndServeFcgi", "(", "add...
// RunFcgi starts the web application and serves FastCGI requests for s.
[ "RunFcgi", "starts", "the", "web", "application", "and", "serves", "FastCGI", "requests", "for", "s", "." ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/server.go#L170-L174
26,865
hoisie/web
server.go
RunScgi
func (s *Server) RunScgi(addr string) { s.initServer() s.Logger.Printf("web.go serving scgi %s\n", addr) s.listenAndServeScgi(addr) }
go
func (s *Server) RunScgi(addr string) { s.initServer() s.Logger.Printf("web.go serving scgi %s\n", addr) s.listenAndServeScgi(addr) }
[ "func", "(", "s", "*", "Server", ")", "RunScgi", "(", "addr", "string", ")", "{", "s", ".", "initServer", "(", ")", "\n", "s", ".", "Logger", ".", "Printf", "(", "\"", "\\n", "\"", ",", "addr", ")", "\n", "s", ".", "listenAndServeScgi", "(", "add...
// RunScgi starts the web application and serves SCGI requests for s.
[ "RunScgi", "starts", "the", "web", "application", "and", "serves", "SCGI", "requests", "for", "s", "." ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/server.go#L177-L181
26,866
hoisie/web
server.go
RunTLS
func (s *Server) RunTLS(addr string, config *tls.Config) error { s.initServer() mux := http.NewServeMux() mux.Handle("/", s) l, err := tls.Listen("tcp", addr, config) if err != nil { log.Fatal("Listen:", err) return err } s.Logger.Printf("web.go serving %s\n", l.Addr()) s.l = l return http.Serve(s.l, mux...
go
func (s *Server) RunTLS(addr string, config *tls.Config) error { s.initServer() mux := http.NewServeMux() mux.Handle("/", s) l, err := tls.Listen("tcp", addr, config) if err != nil { log.Fatal("Listen:", err) return err } s.Logger.Printf("web.go serving %s\n", l.Addr()) s.l = l return http.Serve(s.l, mux...
[ "func", "(", "s", "*", "Server", ")", "RunTLS", "(", "addr", "string", ",", "config", "*", "tls", ".", "Config", ")", "error", "{", "s", ".", "initServer", "(", ")", "\n", "mux", ":=", "http", ".", "NewServeMux", "(", ")", "\n", "mux", ".", "Hand...
// RunTLS starts the web application and serves HTTPS requests for s.
[ "RunTLS", "starts", "the", "web", "application", "and", "serves", "HTTPS", "requests", "for", "s", "." ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/server.go#L184-L198
26,867
hoisie/web
server.go
requiresContext
func requiresContext(handlerType reflect.Type) bool { //if the method doesn't take arguments, no if handlerType.NumIn() == 0 { return false } //if the first argument is not a pointer, no a0 := handlerType.In(0) if a0.Kind() != reflect.Ptr { return false } //if the first argument is a context, yes if a0.El...
go
func requiresContext(handlerType reflect.Type) bool { //if the method doesn't take arguments, no if handlerType.NumIn() == 0 { return false } //if the first argument is not a pointer, no a0 := handlerType.In(0) if a0.Kind() != reflect.Ptr { return false } //if the first argument is a context, yes if a0.El...
[ "func", "requiresContext", "(", "handlerType", "reflect", ".", "Type", ")", "bool", "{", "//if the method doesn't take arguments, no", "if", "handlerType", ".", "NumIn", "(", ")", "==", "0", "{", "return", "false", "\n", "}", "\n\n", "//if the first argument is not ...
// requiresContext determines whether 'handlerType' contains // an argument to 'web.Ctx' as its first argument
[ "requiresContext", "determines", "whether", "handlerType", "contains", "an", "argument", "to", "web", ".", "Ctx", "as", "its", "first", "argument" ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/server.go#L233-L250
26,868
hoisie/web
helpers.go
webTime
func webTime(t time.Time) string { ftime := t.Format(time.RFC1123) if strings.HasSuffix(ftime, "UTC") { ftime = ftime[0:len(ftime)-3] + "GMT" } return ftime }
go
func webTime(t time.Time) string { ftime := t.Format(time.RFC1123) if strings.HasSuffix(ftime, "UTC") { ftime = ftime[0:len(ftime)-3] + "GMT" } return ftime }
[ "func", "webTime", "(", "t", "time", ".", "Time", ")", "string", "{", "ftime", ":=", "t", ".", "Format", "(", "time", ".", "RFC1123", ")", "\n", "if", "strings", ".", "HasSuffix", "(", "ftime", ",", "\"", "\"", ")", "{", "ftime", "=", "ftime", "[...
// internal utility methods
[ "internal", "utility", "methods" ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/helpers.go#L16-L22
26,869
hoisie/web
helpers.go
Urlencode
func Urlencode(data map[string]string) string { var buf bytes.Buffer for k, v := range data { buf.WriteString(url.QueryEscape(k)) buf.WriteByte('=') buf.WriteString(url.QueryEscape(v)) buf.WriteByte('&') } s := buf.String() return s[0 : len(s)-1] }
go
func Urlencode(data map[string]string) string { var buf bytes.Buffer for k, v := range data { buf.WriteString(url.QueryEscape(k)) buf.WriteByte('=') buf.WriteString(url.QueryEscape(v)) buf.WriteByte('&') } s := buf.String() return s[0 : len(s)-1] }
[ "func", "Urlencode", "(", "data", "map", "[", "string", "]", "string", ")", "string", "{", "var", "buf", "bytes", ".", "Buffer", "\n", "for", "k", ",", "v", ":=", "range", "data", "{", "buf", ".", "WriteString", "(", "url", ".", "QueryEscape", "(", ...
// Urlencode is a helper method that converts a map into URL-encoded form data. // It is a useful when constructing HTTP POST requests.
[ "Urlencode", "is", "a", "helper", "method", "that", "converts", "a", "map", "into", "URL", "-", "encoded", "form", "data", ".", "It", "is", "a", "useful", "when", "constructing", "HTTP", "POST", "requests", "." ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/helpers.go#L47-L57
26,870
hoisie/web
helpers.go
Slug
func Slug(s string, sep string) string { if s == "" { return "" } slug := slugRegex.ReplaceAllString(s, sep) if slug == "" { return "" } quoted := regexp.QuoteMeta(sep) sepRegex := regexp.MustCompile("(" + quoted + "){2,}") slug = sepRegex.ReplaceAllString(slug, sep) sepEnds := regexp.MustCompile("^" + quo...
go
func Slug(s string, sep string) string { if s == "" { return "" } slug := slugRegex.ReplaceAllString(s, sep) if slug == "" { return "" } quoted := regexp.QuoteMeta(sep) sepRegex := regexp.MustCompile("(" + quoted + "){2,}") slug = sepRegex.ReplaceAllString(slug, sep) sepEnds := regexp.MustCompile("^" + quo...
[ "func", "Slug", "(", "s", "string", ",", "sep", "string", ")", "string", "{", "if", "s", "==", "\"", "\"", "{", "return", "\"", "\"", "\n", "}", "\n", "slug", ":=", "slugRegex", ".", "ReplaceAllString", "(", "s", ",", "sep", ")", "\n", "if", "slu...
// Slug is a helper function that returns the URL slug for string s. // It's used to return clean, URL-friendly strings that can be // used in routing.
[ "Slug", "is", "a", "helper", "function", "that", "returns", "the", "URL", "slug", "for", "string", "s", ".", "It", "s", "used", "to", "return", "clean", "URL", "-", "friendly", "strings", "that", "can", "be", "used", "in", "routing", "." ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/helpers.go#L64-L78
26,871
hoisie/web
helpers.go
GetBasicAuth
func (ctx *Context) GetBasicAuth() (string, string, error) { if len(ctx.Request.Header["Authorization"]) == 0 { return "", "", errors.New("No Authorization header provided") } authHeader := ctx.Request.Header["Authorization"][0] authString := strings.Split(string(authHeader), " ") if authString[0] != "Basic" { ...
go
func (ctx *Context) GetBasicAuth() (string, string, error) { if len(ctx.Request.Header["Authorization"]) == 0 { return "", "", errors.New("No Authorization header provided") } authHeader := ctx.Request.Header["Authorization"][0] authString := strings.Split(string(authHeader), " ") if authString[0] != "Basic" { ...
[ "func", "(", "ctx", "*", "Context", ")", "GetBasicAuth", "(", ")", "(", "string", ",", "string", ",", "error", ")", "{", "if", "len", "(", "ctx", ".", "Request", ".", "Header", "[", "\"", "\"", "]", ")", "==", "0", "{", "return", "\"", "\"", ",...
// GetBasicAuth returns the decoded user and password from the context's // 'Authorization' header.
[ "GetBasicAuth", "returns", "the", "decoded", "user", "and", "password", "from", "the", "context", "s", "Authorization", "header", "." ]
a498c022b2c0babab2bf9c0400754190b24c8c39
https://github.com/hoisie/web/blob/a498c022b2c0babab2bf9c0400754190b24c8c39/helpers.go#L96-L114
26,872
magefile/mage
sh/helpers.go
Rm
func Rm(path string) error { err := os.RemoveAll(path) if err == nil || os.IsNotExist(err) { return nil } return fmt.Errorf(`failed to remove %s: %v`, path, err) }
go
func Rm(path string) error { err := os.RemoveAll(path) if err == nil || os.IsNotExist(err) { return nil } return fmt.Errorf(`failed to remove %s: %v`, path, err) }
[ "func", "Rm", "(", "path", "string", ")", "error", "{", "err", ":=", "os", ".", "RemoveAll", "(", "path", ")", "\n", "if", "err", "==", "nil", "||", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "nil", "\n", "}", "\n", "return", "fmt",...
// Rm removes the given file or directory even if non-empty. It will not return // an error if the target doesn't exist, only if the target cannot be removed.
[ "Rm", "removes", "the", "given", "file", "or", "directory", "even", "if", "non", "-", "empty", ".", "It", "will", "not", "return", "an", "error", "if", "the", "target", "doesn", "t", "exist", "only", "if", "the", "target", "cannot", "be", "removed", "....
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/sh/helpers.go#L11-L17
26,873
magefile/mage
sh/helpers.go
Copy
func Copy(dst string, src string) error { from, err := os.Open(src) if err != nil { return fmt.Errorf(`can't copy %s: %v`, src, err) } defer from.Close() finfo, err := from.Stat() if err != nil { return fmt.Errorf(`can't stat %s: %v`, src, err) } to, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY|os.O_TRUN...
go
func Copy(dst string, src string) error { from, err := os.Open(src) if err != nil { return fmt.Errorf(`can't copy %s: %v`, src, err) } defer from.Close() finfo, err := from.Stat() if err != nil { return fmt.Errorf(`can't stat %s: %v`, src, err) } to, err := os.OpenFile(dst, os.O_CREATE|os.O_WRONLY|os.O_TRUN...
[ "func", "Copy", "(", "dst", "string", ",", "src", "string", ")", "error", "{", "from", ",", "err", ":=", "os", ".", "Open", "(", "src", ")", "\n", "if", "err", "!=", "nil", "{", "return", "fmt", ".", "Errorf", "(", "`can't copy %s: %v`", ",", "src"...
// Copy robustly copies the source file to the destination, overwriting the destination if necessary.
[ "Copy", "robustly", "copies", "the", "source", "file", "to", "the", "destination", "overwriting", "the", "destination", "if", "necessary", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/sh/helpers.go#L20-L40
26,874
magefile/mage
internal/run.go
EnvWithCurrentGOOS
func EnvWithCurrentGOOS() ([]string, error) { vals, err := splitEnv(os.Environ()) if err != nil { return nil, err } vals["GOOS"] = runtime.GOOS vals["GOARCH"] = runtime.GOARCH return joinEnv(vals), nil }
go
func EnvWithCurrentGOOS() ([]string, error) { vals, err := splitEnv(os.Environ()) if err != nil { return nil, err } vals["GOOS"] = runtime.GOOS vals["GOARCH"] = runtime.GOARCH return joinEnv(vals), nil }
[ "func", "EnvWithCurrentGOOS", "(", ")", "(", "[", "]", "string", ",", "error", ")", "{", "vals", ",", "err", ":=", "splitEnv", "(", "os", ".", "Environ", "(", ")", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", ...
// EnvWithCurrentGOOS returns a copy of os.Environ with the GOOS and GOARCH set // to runtime.GOOS and runtime.GOARCH.
[ "EnvWithCurrentGOOS", "returns", "a", "copy", "of", "os", ".", "Environ", "with", "the", "GOOS", "and", "GOARCH", "set", "to", "runtime", ".", "GOOS", "and", "runtime", ".", "GOARCH", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/internal/run.go#L86-L94
26,875
magefile/mage
mg/runtime.go
Verbose
func Verbose() bool { b, _ := strconv.ParseBool(os.Getenv(VerboseEnv)) return b }
go
func Verbose() bool { b, _ := strconv.ParseBool(os.Getenv(VerboseEnv)) return b }
[ "func", "Verbose", "(", ")", "bool", "{", "b", ",", "_", ":=", "strconv", ".", "ParseBool", "(", "os", ".", "Getenv", "(", "VerboseEnv", ")", ")", "\n", "return", "b", "\n", "}" ]
// Verbose reports whether a magefile was run with the verbose flag.
[ "Verbose", "reports", "whether", "a", "magefile", "was", "run", "with", "the", "verbose", "flag", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mg/runtime.go#L31-L34
26,876
magefile/mage
mg/runtime.go
Debug
func Debug() bool { b, _ := strconv.ParseBool(os.Getenv(DebugEnv)) return b }
go
func Debug() bool { b, _ := strconv.ParseBool(os.Getenv(DebugEnv)) return b }
[ "func", "Debug", "(", ")", "bool", "{", "b", ",", "_", ":=", "strconv", ".", "ParseBool", "(", "os", ".", "Getenv", "(", "DebugEnv", ")", ")", "\n", "return", "b", "\n", "}" ]
// Debug reports whether a magefile was run with the verbose flag.
[ "Debug", "reports", "whether", "a", "magefile", "was", "run", "with", "the", "verbose", "flag", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mg/runtime.go#L37-L40
26,877
magefile/mage
mg/runtime.go
IgnoreDefault
func IgnoreDefault() bool { b, _ := strconv.ParseBool(os.Getenv(IgnoreDefaultEnv)) return b }
go
func IgnoreDefault() bool { b, _ := strconv.ParseBool(os.Getenv(IgnoreDefaultEnv)) return b }
[ "func", "IgnoreDefault", "(", ")", "bool", "{", "b", ",", "_", ":=", "strconv", ".", "ParseBool", "(", "os", ".", "Getenv", "(", "IgnoreDefaultEnv", ")", ")", "\n", "return", "b", "\n", "}" ]
// IgnoreDefault reports whether the user has requested to ignore the default target // in the magefile.
[ "IgnoreDefault", "reports", "whether", "the", "user", "has", "requested", "to", "ignore", "the", "default", "target", "in", "the", "magefile", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mg/runtime.go#L53-L56
26,878
magefile/mage
mg/deps.go
SerialDeps
func SerialDeps(fns ...interface{}) { types := checkFns(fns) ctx := context.Background() for i := range fns { runDeps(ctx, types[i:i+1], fns[i:i+1]) } }
go
func SerialDeps(fns ...interface{}) { types := checkFns(fns) ctx := context.Background() for i := range fns { runDeps(ctx, types[i:i+1], fns[i:i+1]) } }
[ "func", "SerialDeps", "(", "fns", "...", "interface", "{", "}", ")", "{", "types", ":=", "checkFns", "(", "fns", ")", "\n", "ctx", ":=", "context", ".", "Background", "(", ")", "\n", "for", "i", ":=", "range", "fns", "{", "runDeps", "(", "ctx", ","...
// SerialDeps is like Deps except it runs each dependency serially, instead of // in parallel. This can be useful for resource intensive dependencies that // shouldn't be run at the same time.
[ "SerialDeps", "is", "like", "Deps", "except", "it", "runs", "each", "dependency", "serially", "instead", "of", "in", "parallel", ".", "This", "can", "be", "useful", "for", "resource", "intensive", "dependencies", "that", "shouldn", "t", "be", "run", "at", "t...
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mg/deps.go#L57-L63
26,879
magefile/mage
mg/deps.go
SerialCtxDeps
func SerialCtxDeps(ctx context.Context, fns ...interface{}) { types := checkFns(fns) for i := range fns { runDeps(ctx, types[i:i+1], fns[i:i+1]) } }
go
func SerialCtxDeps(ctx context.Context, fns ...interface{}) { types := checkFns(fns) for i := range fns { runDeps(ctx, types[i:i+1], fns[i:i+1]) } }
[ "func", "SerialCtxDeps", "(", "ctx", "context", ".", "Context", ",", "fns", "...", "interface", "{", "}", ")", "{", "types", ":=", "checkFns", "(", "fns", ")", "\n", "for", "i", ":=", "range", "fns", "{", "runDeps", "(", "ctx", ",", "types", "[", "...
// SerialCtxDeps is like CtxDeps except it runs each dependency serially, // instead of in parallel. This can be useful for resource intensive // dependencies that shouldn't be run at the same time.
[ "SerialCtxDeps", "is", "like", "CtxDeps", "except", "it", "runs", "each", "dependency", "serially", "instead", "of", "in", "parallel", ".", "This", "can", "be", "useful", "for", "resource", "intensive", "dependencies", "that", "shouldn", "t", "be", "run", "at"...
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mg/deps.go#L68-L73
26,880
magefile/mage
mg/deps.go
runDeps
func runDeps(ctx context.Context, types []funcType, fns []interface{}) { mu := &sync.Mutex{} var errs []string var exit int wg := &sync.WaitGroup{} for i, f := range fns { fn := addDep(ctx, types[i], f) wg.Add(1) go func() { defer func() { if v := recover(); v != nil { mu.Lock() if err, ok :...
go
func runDeps(ctx context.Context, types []funcType, fns []interface{}) { mu := &sync.Mutex{} var errs []string var exit int wg := &sync.WaitGroup{} for i, f := range fns { fn := addDep(ctx, types[i], f) wg.Add(1) go func() { defer func() { if v := recover(); v != nil { mu.Lock() if err, ok :...
[ "func", "runDeps", "(", "ctx", "context", ".", "Context", ",", "types", "[", "]", "funcType", ",", "fns", "[", "]", "interface", "{", "}", ")", "{", "mu", ":=", "&", "sync", ".", "Mutex", "{", "}", "\n", "var", "errs", "[", "]", "string", "\n", ...
// runDeps assumes you've already called checkFns.
[ "runDeps", "assumes", "you", "ve", "already", "called", "checkFns", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mg/deps.go#L94-L129
26,881
magefile/mage
mg/deps.go
funcCheck
func funcCheck(fn interface{}) (funcType, error) { switch fn.(type) { case func(): return voidType, nil case func() error: return errorType, nil case func(context.Context): return contextVoidType, nil case func(context.Context) error: return contextErrorType, nil } err := fmt.Errorf("Invalid type for de...
go
func funcCheck(fn interface{}) (funcType, error) { switch fn.(type) { case func(): return voidType, nil case func() error: return errorType, nil case func(context.Context): return contextVoidType, nil case func(context.Context) error: return contextErrorType, nil } err := fmt.Errorf("Invalid type for de...
[ "func", "funcCheck", "(", "fn", "interface", "{", "}", ")", "(", "funcType", ",", "error", ")", "{", "switch", "fn", ".", "(", "type", ")", "{", "case", "func", "(", ")", ":", "return", "voidType", ",", "nil", "\n", "case", "func", "(", ")", "err...
// funcCheck tests if a function is one of funcType
[ "funcCheck", "tests", "if", "a", "function", "is", "one", "of", "funcType" ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mg/deps.go#L218-L278
26,882
magefile/mage
mg/deps.go
funcTypeWrap
func funcTypeWrap(t funcType, fn interface{}) func(context.Context) error { switch f := fn.(type) { case func(): return func(context.Context) error { f() return nil } case func() error: return func(context.Context) error { return f() } case func(context.Context): return func(ctx context.Context) ...
go
func funcTypeWrap(t funcType, fn interface{}) func(context.Context) error { switch f := fn.(type) { case func(): return func(context.Context) error { f() return nil } case func() error: return func(context.Context) error { return f() } case func(context.Context): return func(ctx context.Context) ...
[ "func", "funcTypeWrap", "(", "t", "funcType", ",", "fn", "interface", "{", "}", ")", "func", "(", "context", ".", "Context", ")", "error", "{", "switch", "f", ":=", "fn", ".", "(", "type", ")", "{", "case", "func", "(", ")", ":", "return", "func", ...
// funcTypeWrap wraps a valid FuncType to FuncContextError
[ "funcTypeWrap", "wraps", "a", "valid", "FuncType", "to", "FuncContextError" ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mg/deps.go#L281-L337
26,883
magefile/mage
mage/main.go
Main
func Main() int { return ParseAndRun(os.Stdout, os.Stderr, os.Stdin, os.Args[1:]) }
go
func Main() int { return ParseAndRun(os.Stdout, os.Stderr, os.Stdin, os.Args[1:]) }
[ "func", "Main", "(", ")", "int", "{", "return", "ParseAndRun", "(", "os", ".", "Stdout", ",", "os", ".", "Stderr", ",", "os", ".", "Stdin", ",", "os", ".", "Args", "[", "1", ":", "]", ")", "\n", "}" ]
// Main is the entrypoint for running mage. It exists external to mage's main // function to allow it to be used from other programs, specifically so you can // go run a simple file that run's mage's Main.
[ "Main", "is", "the", "entrypoint", "for", "running", "mage", ".", "It", "exists", "external", "to", "mage", "s", "main", "function", "to", "allow", "it", "to", "be", "used", "from", "other", "programs", "specifically", "so", "you", "can", "go", "run", "a...
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mage/main.go#L90-L92
26,884
magefile/mage
mage/main.go
Magefiles
func Magefiles(magePath, goos, goarch, goCmd string, stderr io.Writer, isDebug bool) ([]string, error) { start := time.Now() defer func() { debug.Println("time to scan for Magefiles:", time.Since(start)) }() fail := func(err error) ([]string, error) { return nil, err } env, err := internal.EnvWithGOOS(goos, ...
go
func Magefiles(magePath, goos, goarch, goCmd string, stderr io.Writer, isDebug bool) ([]string, error) { start := time.Now() defer func() { debug.Println("time to scan for Magefiles:", time.Since(start)) }() fail := func(err error) ([]string, error) { return nil, err } env, err := internal.EnvWithGOOS(goos, ...
[ "func", "Magefiles", "(", "magePath", ",", "goos", ",", "goarch", ",", "goCmd", "string", ",", "stderr", "io", ".", "Writer", ",", "isDebug", "bool", ")", "(", "[", "]", "string", ",", "error", ")", "{", "start", ":=", "time", ".", "Now", "(", ")",...
// Magefiles returns the list of magefiles in dir.
[ "Magefiles", "returns", "the", "list", "of", "magefiles", "in", "dir", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mage/main.go#L411-L471
26,885
magefile/mage
mage/main.go
Compile
func Compile(goos, goarch, magePath, goCmd, compileTo string, gofiles []string, isDebug bool, stderr, stdout io.Writer) error { debug.Println("compiling to", compileTo) debug.Println("compiling using gocmd:", goCmd) if isDebug { internal.RunDebug(goCmd, "version") internal.RunDebug(goCmd, "env") } environ, err...
go
func Compile(goos, goarch, magePath, goCmd, compileTo string, gofiles []string, isDebug bool, stderr, stdout io.Writer) error { debug.Println("compiling to", compileTo) debug.Println("compiling using gocmd:", goCmd) if isDebug { internal.RunDebug(goCmd, "version") internal.RunDebug(goCmd, "env") } environ, err...
[ "func", "Compile", "(", "goos", ",", "goarch", ",", "magePath", ",", "goCmd", ",", "compileTo", "string", ",", "gofiles", "[", "]", "string", ",", "isDebug", "bool", ",", "stderr", ",", "stdout", "io", ".", "Writer", ")", "error", "{", "debug", ".", ...
// Compile uses the go tool to compile the files into an executable at path.
[ "Compile", "uses", "the", "go", "tool", "to", "compile", "the", "files", "into", "an", "executable", "at", "path", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mage/main.go#L474-L502
26,886
magefile/mage
mage/main.go
GenerateMainfile
func GenerateMainfile(binaryName, path string, info *parse.PkgInfo) error { debug.Println("Creating mainfile at", path) f, err := os.Create(path) if err != nil { return fmt.Errorf("error creating generated mainfile: %v", err) } defer f.Close() data := mainfileTemplateData{ Description: info.Description, Fu...
go
func GenerateMainfile(binaryName, path string, info *parse.PkgInfo) error { debug.Println("Creating mainfile at", path) f, err := os.Create(path) if err != nil { return fmt.Errorf("error creating generated mainfile: %v", err) } defer f.Close() data := mainfileTemplateData{ Description: info.Description, Fu...
[ "func", "GenerateMainfile", "(", "binaryName", ",", "path", "string", ",", "info", "*", "parse", ".", "PkgInfo", ")", "error", "{", "debug", ".", "Println", "(", "\"", "\"", ",", "path", ")", "\n\n", "f", ",", "err", ":=", "os", ".", "Create", "(", ...
// GenerateMainfile generates the mage mainfile at path.
[ "GenerateMainfile", "generates", "the", "mage", "mainfile", "at", "path", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mage/main.go#L505-L539
26,887
magefile/mage
mage/main.go
ExeName
func ExeName(goCmd, cacheDir string, files []string) (string, error) { var hashes []string for _, s := range files { h, err := hashFile(s) if err != nil { return "", err } hashes = append(hashes, h) } // hash the mainfile template to ensure if it gets updated, we make a new // binary. hashes = append(h...
go
func ExeName(goCmd, cacheDir string, files []string) (string, error) { var hashes []string for _, s := range files { h, err := hashFile(s) if err != nil { return "", err } hashes = append(hashes, h) } // hash the mainfile template to ensure if it gets updated, we make a new // binary. hashes = append(h...
[ "func", "ExeName", "(", "goCmd", ",", "cacheDir", "string", ",", "files", "[", "]", "string", ")", "(", "string", ",", "error", ")", "{", "var", "hashes", "[", "]", "string", "\n", "for", "_", ",", "s", ":=", "range", "files", "{", "h", ",", "err...
// ExeName reports the executable filename that this version of Mage would // create for the given magefiles.
[ "ExeName", "reports", "the", "executable", "filename", "that", "this", "version", "of", "Mage", "would", "create", "for", "the", "given", "magefiles", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mage/main.go#L543-L568
26,888
magefile/mage
mage/main.go
RunCompiled
func RunCompiled(inv Invocation, exePath string, errlog *log.Logger) int { debug.Println("running binary", exePath) c := exec.Command(exePath, inv.Args...) c.Stderr = inv.Stderr c.Stdout = inv.Stdout c.Stdin = inv.Stdin c.Dir = inv.Dir // intentionally pass through unaltered os.Environ here.. your magefile has ...
go
func RunCompiled(inv Invocation, exePath string, errlog *log.Logger) int { debug.Println("running binary", exePath) c := exec.Command(exePath, inv.Args...) c.Stderr = inv.Stderr c.Stdout = inv.Stdout c.Stdin = inv.Stdin c.Dir = inv.Dir // intentionally pass through unaltered os.Environ here.. your magefile has ...
[ "func", "RunCompiled", "(", "inv", "Invocation", ",", "exePath", "string", ",", "errlog", "*", "log", ".", "Logger", ")", "int", "{", "debug", ".", "Println", "(", "\"", "\"", ",", "exePath", ")", "\n", "c", ":=", "exec", ".", "Command", "(", "exePat...
// RunCompiled runs an already-compiled mage command with the given args,
[ "RunCompiled", "runs", "an", "already", "-", "compiled", "mage", "command", "with", "the", "given", "args" ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mage/main.go#L600-L634
26,889
magefile/mage
mage/main.go
removeContents
func removeContents(dir string) error { debug.Println("removing all files in", dir) files, err := ioutil.ReadDir(dir) if err != nil { if os.IsNotExist(err) { return nil } return err } for _, f := range files { if f.IsDir() { continue } err = os.Remove(filepath.Join(dir, f.Name())) if err != nil...
go
func removeContents(dir string) error { debug.Println("removing all files in", dir) files, err := ioutil.ReadDir(dir) if err != nil { if os.IsNotExist(err) { return nil } return err } for _, f := range files { if f.IsDir() { continue } err = os.Remove(filepath.Join(dir, f.Name())) if err != nil...
[ "func", "removeContents", "(", "dir", "string", ")", "error", "{", "debug", ".", "Println", "(", "\"", "\"", ",", "dir", ")", "\n", "files", ",", "err", ":=", "ioutil", ".", "ReadDir", "(", "dir", ")", "\n", "if", "err", "!=", "nil", "{", "if", "...
// removeContents removes all files but not any subdirectories in the given // directory.
[ "removeContents", "removes", "all", "files", "but", "not", "any", "subdirectories", "in", "the", "given", "directory", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mage/main.go#L648-L668
26,890
magefile/mage
magefile.go
Install
func Install() error { name := "mage" if runtime.GOOS == "windows" { name += ".exe" } gocmd := mg.GoCmd() // use GOBIN if set in the environment, otherwise fall back to first path // in GOPATH environment string bin, err := sh.Output(gocmd, "env", "GOBIN") if err != nil { return fmt.Errorf("can't determine...
go
func Install() error { name := "mage" if runtime.GOOS == "windows" { name += ".exe" } gocmd := mg.GoCmd() // use GOBIN if set in the environment, otherwise fall back to first path // in GOPATH environment string bin, err := sh.Output(gocmd, "env", "GOBIN") if err != nil { return fmt.Errorf("can't determine...
[ "func", "Install", "(", ")", "error", "{", "name", ":=", "\"", "\"", "\n", "if", "runtime", ".", "GOOS", "==", "\"", "\"", "{", "name", "+=", "\"", "\"", "\n", "}", "\n\n", "gocmd", ":=", "mg", ".", "GoCmd", "(", ")", "\n", "// use GOBIN if set in ...
// Runs "go install" for mage. This generates the version info the binary.
[ "Runs", "go", "install", "for", "mage", ".", "This", "generates", "the", "version", "info", "the", "binary", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/magefile.go#L23-L56
26,891
magefile/mage
magefile.go
Release
func Release() (err error) { tag := os.Getenv("TAG") if !releaseTag.MatchString(tag) { return errors.New("TAG environment variable must be in semver v1.x.x format, but was " + tag) } if err := sh.RunV("git", "tag", "-a", tag, "-m", tag); err != nil { return err } if err := sh.RunV("git", "push", "origin", ta...
go
func Release() (err error) { tag := os.Getenv("TAG") if !releaseTag.MatchString(tag) { return errors.New("TAG environment variable must be in semver v1.x.x format, but was " + tag) } if err := sh.RunV("git", "tag", "-a", tag, "-m", tag); err != nil { return err } if err := sh.RunV("git", "push", "origin", ta...
[ "func", "Release", "(", ")", "(", "err", "error", ")", "{", "tag", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "!", "releaseTag", ".", "MatchString", "(", "tag", ")", "{", "return", "errors", ".", "New", "(", "\"", "\"", "+", "...
// Generates a new release. Expects the TAG environment variable to be set, // which will create a new tag with that name.
[ "Generates", "a", "new", "release", ".", "Expects", "the", "TAG", "environment", "variable", "to", "be", "set", "which", "will", "create", "a", "new", "tag", "with", "that", "name", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/magefile.go#L62-L81
26,892
magefile/mage
parse/parse.go
ID
func (f Function) ID() string { path := "<current>" if f.ImportPath != "" { path = f.ImportPath } receiver := "" if f.Receiver != "" { receiver = f.Receiver + "." } return fmt.Sprintf("%s.%s%s", path, receiver, f.Name) }
go
func (f Function) ID() string { path := "<current>" if f.ImportPath != "" { path = f.ImportPath } receiver := "" if f.Receiver != "" { receiver = f.Receiver + "." } return fmt.Sprintf("%s.%s%s", path, receiver, f.Name) }
[ "func", "(", "f", "Function", ")", "ID", "(", ")", "string", "{", "path", ":=", "\"", "\"", "\n", "if", "f", ".", "ImportPath", "!=", "\"", "\"", "{", "path", "=", "f", ".", "ImportPath", "\n", "}", "\n", "receiver", ":=", "\"", "\"", "\n", "if...
// ID returns user-readable information about where this function is defined.
[ "ID", "returns", "user", "-", "readable", "information", "about", "where", "this", "function", "is", "defined", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/parse/parse.go#L54-L64
26,893
magefile/mage
parse/parse.go
TargetName
func (f Function) TargetName() string { var names []string for _, s := range []string{f.PkgAlias, f.Receiver, f.Name} { if s != "" { names = append(names, s) } } return strings.Join(names, ":") }
go
func (f Function) TargetName() string { var names []string for _, s := range []string{f.PkgAlias, f.Receiver, f.Name} { if s != "" { names = append(names, s) } } return strings.Join(names, ":") }
[ "func", "(", "f", "Function", ")", "TargetName", "(", ")", "string", "{", "var", "names", "[", "]", "string", "\n\n", "for", "_", ",", "s", ":=", "range", "[", "]", "string", "{", "f", ".", "PkgAlias", ",", "f", ".", "Receiver", ",", "f", ".", ...
// TargetName returns the name of the target as it should appear when used from // the mage cli. It is always lowercase.
[ "TargetName", "returns", "the", "name", "of", "the", "target", "as", "it", "should", "appear", "when", "used", "from", "the", "mage", "cli", ".", "It", "is", "always", "lowercase", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/parse/parse.go#L68-L77
26,894
magefile/mage
parse/parse.go
PrimaryPackage
func PrimaryPackage(gocmd, path string, files []string) (*PkgInfo, error) { info, err := Package(path, files) if err != nil { return nil, err } if err := setImports(gocmd, info); err != nil { return nil, err } setDefault(info) setAliases(info) return info, nil }
go
func PrimaryPackage(gocmd, path string, files []string) (*PkgInfo, error) { info, err := Package(path, files) if err != nil { return nil, err } if err := setImports(gocmd, info); err != nil { return nil, err } setDefault(info) setAliases(info) return info, nil }
[ "func", "PrimaryPackage", "(", "gocmd", ",", "path", "string", ",", "files", "[", "]", "string", ")", "(", "*", "PkgInfo", ",", "error", ")", "{", "info", ",", "err", ":=", "Package", "(", "path", ",", "files", ")", "\n", "if", "err", "!=", "nil", ...
// PrimaryPackage parses a package. If files is non-empty, it will only parse the files given.
[ "PrimaryPackage", "parses", "a", "package", ".", "If", "files", "is", "non", "-", "empty", "it", "will", "only", "parse", "the", "files", "given", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/parse/parse.go#L129-L142
26,895
magefile/mage
parse/parse.go
Package
func Package(path string, files []string) (*PkgInfo, error) { start := time.Now() defer func() { debug.Println("time parse Magefiles:", time.Since(start)) }() fset := token.NewFileSet() pkg, err := getPackage(path, files, fset) if err != nil { return nil, err } p := doc.New(pkg, "./", 0) pi := &PkgInfo{ ...
go
func Package(path string, files []string) (*PkgInfo, error) { start := time.Now() defer func() { debug.Println("time parse Magefiles:", time.Since(start)) }() fset := token.NewFileSet() pkg, err := getPackage(path, files, fset) if err != nil { return nil, err } p := doc.New(pkg, "./", 0) pi := &PkgInfo{ ...
[ "func", "Package", "(", "path", "string", ",", "files", "[", "]", "string", ")", "(", "*", "PkgInfo", ",", "error", ")", "{", "start", ":=", "time", ".", "Now", "(", ")", "\n", "defer", "func", "(", ")", "{", "debug", ".", "Println", "(", "\"", ...
// Package compiles information about a mage package.
[ "Package", "compiles", "information", "about", "a", "mage", "package", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/parse/parse.go#L186-L218
26,896
magefile/mage
parse/parse.go
checkDupeTargets
func checkDupeTargets(info *PkgInfo) (hasDupes bool, names map[string][]string) { names = map[string][]string{} lowers := map[string]bool{} for _, f := range info.Funcs { low := strings.ToLower(f.Name) if f.Receiver != "" { low = strings.ToLower(f.Receiver) + ":" + low } if lowers[low] { hasDupes = tru...
go
func checkDupeTargets(info *PkgInfo) (hasDupes bool, names map[string][]string) { names = map[string][]string{} lowers := map[string]bool{} for _, f := range info.Funcs { low := strings.ToLower(f.Name) if f.Receiver != "" { low = strings.ToLower(f.Receiver) + ":" + low } if lowers[low] { hasDupes = tru...
[ "func", "checkDupeTargets", "(", "info", "*", "PkgInfo", ")", "(", "hasDupes", "bool", ",", "names", "map", "[", "string", "]", "[", "]", "string", ")", "{", "names", "=", "map", "[", "string", "]", "[", "]", "string", "{", "}", "\n", "lowers", ":=...
// checkDupeTargets checks a package for duplicate target names.
[ "checkDupeTargets", "checks", "a", "package", "for", "duplicate", "target", "names", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/parse/parse.go#L463-L478
26,897
magefile/mage
parse/parse.go
sanitizeSynopsis
func sanitizeSynopsis(f *doc.Func) string { synopsis := doc.Synopsis(f.Doc) // If the synopsis begins with the function name, remove it. This is done to // not repeat the text. // From: // clean Clean removes the temporarily generated files // To: // clean removes the temporarily generated files if syns := st...
go
func sanitizeSynopsis(f *doc.Func) string { synopsis := doc.Synopsis(f.Doc) // If the synopsis begins with the function name, remove it. This is done to // not repeat the text. // From: // clean Clean removes the temporarily generated files // To: // clean removes the temporarily generated files if syns := st...
[ "func", "sanitizeSynopsis", "(", "f", "*", "doc", ".", "Func", ")", "string", "{", "synopsis", ":=", "doc", ".", "Synopsis", "(", "f", ".", "Doc", ")", "\n\n", "// If the synopsis begins with the function name, remove it. This is done to", "// not repeat the text.", "...
// sanitizeSynopsis sanitizes function Doc to create a summary.
[ "sanitizeSynopsis", "sanitizes", "function", "Doc", "to", "create", "a", "summary", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/parse/parse.go#L481-L495
26,898
magefile/mage
parse/parse.go
getPackage
func getPackage(path string, files []string, fset *token.FileSet) (*ast.Package, error) { var filter func(f os.FileInfo) bool if len(files) > 0 { fm := make(map[string]bool, len(files)) for _, f := range files { fm[f] = true } filter = func(f os.FileInfo) bool { return fm[f.Name()] } } pkgs, err :...
go
func getPackage(path string, files []string, fset *token.FileSet) (*ast.Package, error) { var filter func(f os.FileInfo) bool if len(files) > 0 { fm := make(map[string]bool, len(files)) for _, f := range files { fm[f] = true } filter = func(f os.FileInfo) bool { return fm[f.Name()] } } pkgs, err :...
[ "func", "getPackage", "(", "path", "string", ",", "files", "[", "]", "string", ",", "fset", "*", "token", ".", "FileSet", ")", "(", "*", "ast", ".", "Package", ",", "error", ")", "{", "var", "filter", "func", "(", "f", "os", ".", "FileInfo", ")", ...
// getPackage returns the non-test package at the given path.
[ "getPackage", "returns", "the", "non", "-", "test", "package", "at", "the", "given", "path", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/parse/parse.go#L657-L681
26,899
magefile/mage
mg/errors.go
Fatal
func Fatal(code int, args ...interface{}) error { return fatalErr{ code: code, error: errors.New(fmt.Sprint(args...)), } }
go
func Fatal(code int, args ...interface{}) error { return fatalErr{ code: code, error: errors.New(fmt.Sprint(args...)), } }
[ "func", "Fatal", "(", "code", "int", ",", "args", "...", "interface", "{", "}", ")", "error", "{", "return", "fatalErr", "{", "code", ":", "code", ",", "error", ":", "errors", ".", "New", "(", "fmt", ".", "Sprint", "(", "args", "...", ")", ")", "...
// Fatal returns an error that will cause mage to print out the // given args and exit with the given exit code.
[ "Fatal", "returns", "an", "error", "that", "will", "cause", "mage", "to", "print", "out", "the", "given", "args", "and", "exit", "with", "the", "given", "exit", "code", "." ]
5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed
https://github.com/magefile/mage/blob/5bc3a8ab86d5a23d6eb3bdbcd60e79ac4d9ad0ed/mg/errors.go#L23-L28