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
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
24,800
dropbox/godropbox
container/bitvector/bitvector.go
NewBitVector
func NewBitVector(data []byte, length int) *BitVector { return &BitVector{ data: data, length: length, } }
go
func NewBitVector(data []byte, length int) *BitVector { return &BitVector{ data: data, length: length, } }
[ "func", "NewBitVector", "(", "data", "[", "]", "byte", ",", "length", "int", ")", "*", "BitVector", "{", "return", "&", "BitVector", "{", "data", ":", "data", ",", "length", ":", "length", ",", "}", "\n", "}" ]
// NewBitVector creates and initializes a new bit vector with length // elements, using data as its initial contents.
[ "NewBitVector", "creates", "and", "initializes", "a", "new", "bit", "vector", "with", "length", "elements", "using", "data", "as", "its", "initial", "contents", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/container/bitvector/bitvector.go#L16-L21
24,801
dropbox/godropbox
container/bitvector/bitvector.go
bytesLength
func (vector *BitVector) bytesLength() int { lastBitIndex := vector.length - 1 lastByteIndex := lastBitIndex >> 3 return lastByteIndex + 1 }
go
func (vector *BitVector) bytesLength() int { lastBitIndex := vector.length - 1 lastByteIndex := lastBitIndex >> 3 return lastByteIndex + 1 }
[ "func", "(", "vector", "*", "BitVector", ")", "bytesLength", "(", ")", "int", "{", "lastBitIndex", ":=", "vector", ".", "length", "-", "1", "\n", "lastByteIndex", ":=", "lastBitIndex", ">>", "3", "\n", "return", "lastByteIndex", "+", "1", "\n", "}" ]
// Returns the minimum number of bytes needed for storing the bit vector.
[ "Returns", "the", "minimum", "number", "of", "bytes", "needed", "for", "storing", "the", "bit", "vector", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/container/bitvector/bitvector.go#L64-L68
24,802
dropbox/godropbox
container/bitvector/bitvector.go
indexAssert
func (vector *BitVector) indexAssert(i int) { if i < 0 || i >= vector.length { panic("Attempted to access element outside buffer") } }
go
func (vector *BitVector) indexAssert(i int) { if i < 0 || i >= vector.length { panic("Attempted to access element outside buffer") } }
[ "func", "(", "vector", "*", "BitVector", ")", "indexAssert", "(", "i", "int", ")", "{", "if", "i", "<", "0", "||", "i", ">=", "vector", ".", "length", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "}" ]
// Panics if the given index is not within the bounds of the bit vector.
[ "Panics", "if", "the", "given", "index", "is", "not", "within", "the", "bounds", "of", "the", "bit", "vector", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/container/bitvector/bitvector.go#L71-L75
24,803
dropbox/godropbox
container/bitvector/bitvector.go
Append
func (vector *BitVector) Append(bit byte) { index := uint32(vector.length) vector.length++ if vector.bytesLength() > len(vector.data) { vector.data = append(vector.data, 0) } byteIndex := index >> 3 byteOffset := index % 8 oldByte := vector.data[byteIndex] var newByte byte if bit == 1 { newByte = oldByte...
go
func (vector *BitVector) Append(bit byte) { index := uint32(vector.length) vector.length++ if vector.bytesLength() > len(vector.data) { vector.data = append(vector.data, 0) } byteIndex := index >> 3 byteOffset := index % 8 oldByte := vector.data[byteIndex] var newByte byte if bit == 1 { newByte = oldByte...
[ "func", "(", "vector", "*", "BitVector", ")", "Append", "(", "bit", "byte", ")", "{", "index", ":=", "uint32", "(", "vector", ".", "length", ")", "\n", "vector", ".", "length", "++", "\n\n", "if", "vector", ".", "bytesLength", "(", ")", ">", "len", ...
// Append adds a bit to the end of a bit vector.
[ "Append", "adds", "a", "bit", "to", "the", "end", "of", "a", "bit", "vector", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/container/bitvector/bitvector.go#L78-L99
24,804
dropbox/godropbox
container/bitvector/bitvector.go
Element
func (vector *BitVector) Element(i int) byte { vector.indexAssert(i) byteIndex := i >> 3 byteOffset := uint32(i % 8) b := vector.data[byteIndex] // Check the offset bit return (b >> byteOffset) & 1 }
go
func (vector *BitVector) Element(i int) byte { vector.indexAssert(i) byteIndex := i >> 3 byteOffset := uint32(i % 8) b := vector.data[byteIndex] // Check the offset bit return (b >> byteOffset) & 1 }
[ "func", "(", "vector", "*", "BitVector", ")", "Element", "(", "i", "int", ")", "byte", "{", "vector", ".", "indexAssert", "(", "i", ")", "\n", "byteIndex", ":=", "i", ">>", "3", "\n", "byteOffset", ":=", "uint32", "(", "i", "%", "8", ")", "\n", "...
// Element returns the bit in the ith index of the bit vector. // Returned value is either 1 or 0.
[ "Element", "returns", "the", "bit", "in", "the", "ith", "index", "of", "the", "bit", "vector", ".", "Returned", "value", "is", "either", "1", "or", "0", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/container/bitvector/bitvector.go#L103-L110
24,805
dropbox/godropbox
container/bitvector/bitvector.go
Set
func (vector *BitVector) Set(bit byte, index int) { vector.indexAssert(index) byteIndex := uint32(index >> 3) byteOffset := uint32(index % 8) oldByte := vector.data[byteIndex] var newByte byte if bit == 1 { // turn on the byteOffset'th bit newByte = oldByte | 1<<byteOffset } else { // turn off the byteOf...
go
func (vector *BitVector) Set(bit byte, index int) { vector.indexAssert(index) byteIndex := uint32(index >> 3) byteOffset := uint32(index % 8) oldByte := vector.data[byteIndex] var newByte byte if bit == 1 { // turn on the byteOffset'th bit newByte = oldByte | 1<<byteOffset } else { // turn off the byteOf...
[ "func", "(", "vector", "*", "BitVector", ")", "Set", "(", "bit", "byte", ",", "index", "int", ")", "{", "vector", ".", "indexAssert", "(", "index", ")", "\n", "byteIndex", ":=", "uint32", "(", "index", ">>", "3", ")", "\n", "byteOffset", ":=", "uint3...
// Set changes the bit in the ith index of the bit vector to the value specified in // bit.
[ "Set", "changes", "the", "bit", "in", "the", "ith", "index", "of", "the", "bit", "vector", "to", "the", "value", "specified", "in", "bit", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/container/bitvector/bitvector.go#L114-L131
24,806
dropbox/godropbox
container/bitvector/bitvector.go
Insert
func (vector *BitVector) Insert(bit byte, index int) { vector.indexAssert(index) vector.length++ // Append an additional byte if necessary. if vector.bytesLength() > len(vector.data) { vector.data = append(vector.data, 0) } byteIndex := uint32(index >> 3) byteOffset := uint32(index % 8) var bitToInsert byte...
go
func (vector *BitVector) Insert(bit byte, index int) { vector.indexAssert(index) vector.length++ // Append an additional byte if necessary. if vector.bytesLength() > len(vector.data) { vector.data = append(vector.data, 0) } byteIndex := uint32(index >> 3) byteOffset := uint32(index % 8) var bitToInsert byte...
[ "func", "(", "vector", "*", "BitVector", ")", "Insert", "(", "bit", "byte", ",", "index", "int", ")", "{", "vector", ".", "indexAssert", "(", "index", ")", "\n", "vector", ".", "length", "++", "\n\n", "// Append an additional byte if necessary.", "if", "vect...
// Insert inserts bit into the supplied index of the bit vector. All // bits in positions greater than or equal to index before the call will // be shifted up by one.
[ "Insert", "inserts", "bit", "into", "the", "supplied", "index", "of", "the", "bit", "vector", ".", "All", "bits", "in", "positions", "greater", "than", "or", "equal", "to", "index", "before", "the", "call", "will", "be", "shifted", "up", "by", "one", "."...
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/container/bitvector/bitvector.go#L136-L167
24,807
dropbox/godropbox
container/bitvector/bitvector.go
Delete
func (vector *BitVector) Delete(index int) { vector.indexAssert(index) vector.length-- byteIndex := uint32(index >> 3) byteOffset := uint32(index % 8) oldByte := vector.data[byteIndex] // Shift all the bytes above the byte we're modifying, return the // leftover bit to include in the byte we're modifying. bit...
go
func (vector *BitVector) Delete(index int) { vector.indexAssert(index) vector.length-- byteIndex := uint32(index >> 3) byteOffset := uint32(index % 8) oldByte := vector.data[byteIndex] // Shift all the bytes above the byte we're modifying, return the // leftover bit to include in the byte we're modifying. bit...
[ "func", "(", "vector", "*", "BitVector", ")", "Delete", "(", "index", "int", ")", "{", "vector", ".", "indexAssert", "(", "index", ")", "\n", "vector", ".", "length", "--", "\n", "byteIndex", ":=", "uint32", "(", "index", ">>", "3", ")", "\n", "byteO...
// Delete removes the bit in the supplied index of the bit vector. All // bits in positions greater than or equal to index before the call will // be shifted down by one.
[ "Delete", "removes", "the", "bit", "in", "the", "supplied", "index", "of", "the", "bit", "vector", ".", "All", "bits", "in", "positions", "greater", "than", "or", "equal", "to", "index", "before", "the", "call", "will", "be", "shifted", "down", "by", "on...
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/container/bitvector/bitvector.go#L172-L206
24,808
dropbox/godropbox
sort2/sort.go
Less
func (s UintSlice) Less(i, j int) bool { return s[i] < s[j] }
go
func (s UintSlice) Less(i, j int) bool { return s[i] < s[j] }
[ "func", "(", "s", "UintSlice", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "s", "[", "i", "]", "<", "s", "[", "j", "]", "\n", "}" ]
// Less reports whether the element with // index i should sort before the element with index j in the UintSlice.
[ "Less", "reports", "whether", "the", "element", "with", "index", "i", "should", "sort", "before", "the", "element", "with", "index", "j", "in", "the", "UintSlice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L23-L25
24,809
dropbox/godropbox
sort2/sort.go
Swap
func (s UintSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
go
func (s UintSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
[ "func", "(", "s", "UintSlice", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "s", "[", "i", "]", ",", "s", "[", "j", "]", "=", "s", "[", "j", "]", ",", "s", "[", "i", "]", "\n", "}" ]
// Swap swaps the positions of the elements indices i and j of the UintSlice.
[ "Swap", "swaps", "the", "positions", "of", "the", "elements", "indices", "i", "and", "j", "of", "the", "UintSlice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L28-L30
24,810
dropbox/godropbox
sort2/sort.go
Less
func (s Uint32Slice) Less(i, j int) bool { return s[i] < s[j] }
go
func (s Uint32Slice) Less(i, j int) bool { return s[i] < s[j] }
[ "func", "(", "s", "Uint32Slice", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "s", "[", "i", "]", "<", "s", "[", "j", "]", "\n", "}" ]
// Less reports whether the element with // index i should sort before the element with index j in the Uint32Slice.
[ "Less", "reports", "whether", "the", "element", "with", "index", "i", "should", "sort", "before", "the", "element", "with", "index", "j", "in", "the", "Uint32Slice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L89-L91
24,811
dropbox/godropbox
sort2/sort.go
Swap
func (s Uint32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
go
func (s Uint32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
[ "func", "(", "s", "Uint32Slice", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "s", "[", "i", "]", ",", "s", "[", "j", "]", "=", "s", "[", "j", "]", ",", "s", "[", "i", "]", "\n", "}" ]
// Swap swaps the positions of the elements indices i and j of the Uint32Slice.
[ "Swap", "swaps", "the", "positions", "of", "the", "elements", "indices", "i", "and", "j", "of", "the", "Uint32Slice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L94-L96
24,812
dropbox/godropbox
sort2/sort.go
Less
func (s Uint16Slice) Less(i, j int) bool { return s[i] < s[j] }
go
func (s Uint16Slice) Less(i, j int) bool { return s[i] < s[j] }
[ "func", "(", "s", "Uint16Slice", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "s", "[", "i", "]", "<", "s", "[", "j", "]", "\n", "}" ]
// Less reports whether the element with // index i should sort before the element with index j in the Uint16Slice.
[ "Less", "reports", "whether", "the", "element", "with", "index", "i", "should", "sort", "before", "the", "element", "with", "index", "j", "in", "the", "Uint16Slice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L122-L124
24,813
dropbox/godropbox
sort2/sort.go
Swap
func (s Uint16Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
go
func (s Uint16Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
[ "func", "(", "s", "Uint16Slice", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "s", "[", "i", "]", ",", "s", "[", "j", "]", "=", "s", "[", "j", "]", ",", "s", "[", "i", "]", "\n", "}" ]
// Swap swaps the positions of the elements indices i and j of the Uint16Slice.
[ "Swap", "swaps", "the", "positions", "of", "the", "elements", "indices", "i", "and", "j", "of", "the", "Uint16Slice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L127-L129
24,814
dropbox/godropbox
sort2/sort.go
Less
func (s Uint8Slice) Less(i, j int) bool { return s[i] < s[j] }
go
func (s Uint8Slice) Less(i, j int) bool { return s[i] < s[j] }
[ "func", "(", "s", "Uint8Slice", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "s", "[", "i", "]", "<", "s", "[", "j", "]", "\n", "}" ]
// Less reports whether the element with // index i should sort before the element with index j in the Uint8Slice.
[ "Less", "reports", "whether", "the", "element", "with", "index", "i", "should", "sort", "before", "the", "element", "with", "index", "j", "in", "the", "Uint8Slice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L155-L157
24,815
dropbox/godropbox
sort2/sort.go
Swap
func (s Uint8Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
go
func (s Uint8Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
[ "func", "(", "s", "Uint8Slice", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "s", "[", "i", "]", ",", "s", "[", "j", "]", "=", "s", "[", "j", "]", ",", "s", "[", "i", "]", "\n", "}" ]
// Swap swaps the positions of the elements indices i and j of the Uint8Slice
[ "Swap", "swaps", "the", "positions", "of", "the", "elements", "indices", "i", "and", "j", "of", "the", "Uint8Slice" ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L160-L162
24,816
dropbox/godropbox
sort2/sort.go
Less
func (s Int32Slice) Less(i, j int) bool { return s[i] < s[j] }
go
func (s Int32Slice) Less(i, j int) bool { return s[i] < s[j] }
[ "func", "(", "s", "Int32Slice", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "s", "[", "i", "]", "<", "s", "[", "j", "]", "\n", "}" ]
// Less reports whether the element with // index i should sort before the element with index j in the Int32Slice.
[ "Less", "reports", "whether", "the", "element", "with", "index", "i", "should", "sort", "before", "the", "element", "with", "index", "j", "in", "the", "Int32Slice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L221-L223
24,817
dropbox/godropbox
sort2/sort.go
Swap
func (s Int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
go
func (s Int32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
[ "func", "(", "s", "Int32Slice", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "s", "[", "i", "]", ",", "s", "[", "j", "]", "=", "s", "[", "j", "]", ",", "s", "[", "i", "]", "\n", "}" ]
// Swap swaps the positions of the elements indices i and j of the Int32Slice
[ "Swap", "swaps", "the", "positions", "of", "the", "elements", "indices", "i", "and", "j", "of", "the", "Int32Slice" ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L226-L228
24,818
dropbox/godropbox
sort2/sort.go
Less
func (s Int16Slice) Less(i, j int) bool { return s[i] < s[j] }
go
func (s Int16Slice) Less(i, j int) bool { return s[i] < s[j] }
[ "func", "(", "s", "Int16Slice", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "s", "[", "i", "]", "<", "s", "[", "j", "]", "\n", "}" ]
// Less reports whether the element with // index i should sort before the element with index j in the Int16Slice.
[ "Less", "reports", "whether", "the", "element", "with", "index", "i", "should", "sort", "before", "the", "element", "with", "index", "j", "in", "the", "Int16Slice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L254-L256
24,819
dropbox/godropbox
sort2/sort.go
Swap
func (s Int16Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
go
func (s Int16Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
[ "func", "(", "s", "Int16Slice", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "s", "[", "i", "]", ",", "s", "[", "j", "]", "=", "s", "[", "j", "]", ",", "s", "[", "i", "]", "\n", "}" ]
// Swap swaps the positions of the elements indices i and j of the Int16Slice.
[ "Swap", "swaps", "the", "positions", "of", "the", "elements", "indices", "i", "and", "j", "of", "the", "Int16Slice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L259-L261
24,820
dropbox/godropbox
sort2/sort.go
Less
func (s Int8Slice) Less(i, j int) bool { return s[i] < s[j] }
go
func (s Int8Slice) Less(i, j int) bool { return s[i] < s[j] }
[ "func", "(", "s", "Int8Slice", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "s", "[", "i", "]", "<", "s", "[", "j", "]", "\n", "}" ]
// Less reports whether the element with // index i should sort before the element with index j in the Int8Slice.
[ "Less", "reports", "whether", "the", "element", "with", "index", "i", "should", "sort", "before", "the", "element", "with", "index", "j", "in", "the", "Int8Slice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L287-L289
24,821
dropbox/godropbox
sort2/sort.go
Swap
func (s Int8Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
go
func (s Int8Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
[ "func", "(", "s", "Int8Slice", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "s", "[", "i", "]", ",", "s", "[", "j", "]", "=", "s", "[", "j", "]", ",", "s", "[", "i", "]", "\n", "}" ]
// Swap swaps the positions of the elements indices i and j of the Int8Slice.
[ "Swap", "swaps", "the", "positions", "of", "the", "elements", "indices", "i", "and", "j", "of", "the", "Int8Slice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L292-L294
24,822
dropbox/godropbox
sort2/sort.go
Less
func (s Float32Slice) Less(i, j int) bool { return s[i] < s[j] }
go
func (s Float32Slice) Less(i, j int) bool { return s[i] < s[j] }
[ "func", "(", "s", "Float32Slice", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "s", "[", "i", "]", "<", "s", "[", "j", "]", "\n", "}" ]
// Less reports whether the element with // index i should sort before the element with index j in the Float32Slice.
[ "Less", "reports", "whether", "the", "element", "with", "index", "i", "should", "sort", "before", "the", "element", "with", "index", "j", "in", "the", "Float32Slice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L320-L322
24,823
dropbox/godropbox
sort2/sort.go
Swap
func (s Float32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
go
func (s Float32Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
[ "func", "(", "s", "Float32Slice", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "s", "[", "i", "]", ",", "s", "[", "j", "]", "=", "s", "[", "j", "]", ",", "s", "[", "i", "]", "\n", "}" ]
// Swap swaps the positions of the elements indices i and j of the Float32Slice.
[ "Swap", "swaps", "the", "positions", "of", "the", "elements", "indices", "i", "and", "j", "of", "the", "Float32Slice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L325-L327
24,824
dropbox/godropbox
sort2/sort.go
Less
func (s Float64Slice) Less(i, j int) bool { return s[i] < s[j] }
go
func (s Float64Slice) Less(i, j int) bool { return s[i] < s[j] }
[ "func", "(", "s", "Float64Slice", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "s", "[", "i", "]", "<", "s", "[", "j", "]", "\n", "}" ]
// Less reports whether the element with // index i should sort before the element with index j in the Float64Slice.
[ "Less", "reports", "whether", "the", "element", "with", "index", "i", "should", "sort", "before", "the", "element", "with", "index", "j", "in", "the", "Float64Slice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L353-L355
24,825
dropbox/godropbox
sort2/sort.go
Swap
func (s Float64Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
go
func (s Float64Slice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
[ "func", "(", "s", "Float64Slice", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "s", "[", "i", "]", ",", "s", "[", "j", "]", "=", "s", "[", "j", "]", ",", "s", "[", "i", "]", "\n", "}" ]
// Swap swaps the positions of the elements indices i and j of the Float64Slice.
[ "Swap", "swaps", "the", "positions", "of", "the", "elements", "indices", "i", "and", "j", "of", "the", "Float64Slice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L358-L360
24,826
dropbox/godropbox
sort2/sort.go
Swap
func (s ByteArraySlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
go
func (s ByteArraySlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
[ "func", "(", "s", "ByteArraySlice", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "s", "[", "i", "]", ",", "s", "[", "j", "]", "=", "s", "[", "j", "]", ",", "s", "[", "i", "]", "\n", "}" ]
// Swap swaps the positions of the elements indices i and j of the ByteArraySlice.
[ "Swap", "swaps", "the", "positions", "of", "the", "elements", "indices", "i", "and", "j", "of", "the", "ByteArraySlice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L391-L393
24,827
dropbox/godropbox
sort2/sort.go
Less
func (s TimeSlice) Less(i, j int) bool { return s[i].Before(s[j]) }
go
func (s TimeSlice) Less(i, j int) bool { return s[i].Before(s[j]) }
[ "func", "(", "s", "TimeSlice", ")", "Less", "(", "i", ",", "j", "int", ")", "bool", "{", "return", "s", "[", "i", "]", ".", "Before", "(", "s", "[", "j", "]", ")", "\n", "}" ]
// Less reports whether the element with // index i should sort before the element with index j in the TimeSlice.
[ "Less", "reports", "whether", "the", "element", "with", "index", "i", "should", "sort", "before", "the", "element", "with", "index", "j", "in", "the", "TimeSlice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L419-L421
24,828
dropbox/godropbox
sort2/sort.go
Swap
func (s TimeSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
go
func (s TimeSlice) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
[ "func", "(", "s", "TimeSlice", ")", "Swap", "(", "i", ",", "j", "int", ")", "{", "s", "[", "i", "]", ",", "s", "[", "j", "]", "=", "s", "[", "j", "]", ",", "s", "[", "i", "]", "\n", "}" ]
// Swap swaps the positions of the elements indices i and j of the TimeSlice.
[ "Swap", "swaps", "the", "positions", "of", "the", "elements", "indices", "i", "and", "j", "of", "the", "TimeSlice", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/sort2/sort.go#L424-L426
24,829
dropbox/godropbox
hash2/checksum.go
ValidateMd5Checksum
func ValidateMd5Checksum(data []byte, sum []byte) bool { ourSum := ComputeMd5Checksum(data) return bytes.Equal(ourSum, sum) }
go
func ValidateMd5Checksum(data []byte, sum []byte) bool { ourSum := ComputeMd5Checksum(data) return bytes.Equal(ourSum, sum) }
[ "func", "ValidateMd5Checksum", "(", "data", "[", "]", "byte", ",", "sum", "[", "]", "byte", ")", "bool", "{", "ourSum", ":=", "ComputeMd5Checksum", "(", "data", ")", "\n", "return", "bytes", ".", "Equal", "(", "ourSum", ",", "sum", ")", "\n", "}" ]
// This returns true iff the data matches the provided checksum.
[ "This", "returns", "true", "iff", "the", "data", "matches", "the", "provided", "checksum", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/hash2/checksum.go#L20-L23
24,830
dropbox/godropbox
memcache/responses.go
NewGetErrorResponse
func NewGetErrorResponse(key string, err error) GetResponse { resp := &genericResponse{ err: err, allowNotFound: true, } resp.item.Key = key return resp }
go
func NewGetErrorResponse(key string, err error) GetResponse { resp := &genericResponse{ err: err, allowNotFound: true, } resp.item.Key = key return resp }
[ "func", "NewGetErrorResponse", "(", "key", "string", ",", "err", "error", ")", "GetResponse", "{", "resp", ":=", "&", "genericResponse", "{", "err", ":", "err", ",", "allowNotFound", ":", "true", ",", "}", "\n", "resp", ".", "item", ".", "Key", "=", "k...
// This creates a GetResponse from an error.
[ "This", "creates", "a", "GetResponse", "from", "an", "error", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/responses.go#L130-L137
24,831
dropbox/godropbox
memcache/responses.go
NewGetResponse
func NewGetResponse( key string, status ResponseStatus, flags uint32, value []byte, version uint64) GetResponse { resp := &genericResponse{ status: status, allowNotFound: true, } resp.item.Key = key if status == StatusNoError { if value == nil { resp.item.Value = []byte{} } else { resp.it...
go
func NewGetResponse( key string, status ResponseStatus, flags uint32, value []byte, version uint64) GetResponse { resp := &genericResponse{ status: status, allowNotFound: true, } resp.item.Key = key if status == StatusNoError { if value == nil { resp.item.Value = []byte{} } else { resp.it...
[ "func", "NewGetResponse", "(", "key", "string", ",", "status", "ResponseStatus", ",", "flags", "uint32", ",", "value", "[", "]", "byte", ",", "version", "uint64", ")", "GetResponse", "{", "resp", ":=", "&", "genericResponse", "{", "status", ":", "status", ...
// This creates a normal GetResponse.
[ "This", "creates", "a", "normal", "GetResponse", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/responses.go#L140-L162
24,832
dropbox/godropbox
memcache/responses.go
NewMutateErrorResponse
func NewMutateErrorResponse(key string, err error) MutateResponse { resp := &genericResponse{ err: err, } resp.item.Key = key return resp }
go
func NewMutateErrorResponse(key string, err error) MutateResponse { resp := &genericResponse{ err: err, } resp.item.Key = key return resp }
[ "func", "NewMutateErrorResponse", "(", "key", "string", ",", "err", "error", ")", "MutateResponse", "{", "resp", ":=", "&", "genericResponse", "{", "err", ":", "err", ",", "}", "\n", "resp", ".", "item", ".", "Key", "=", "key", "\n", "return", "resp", ...
// This creates a MutateResponse from an error.
[ "This", "creates", "a", "MutateResponse", "from", "an", "error", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/responses.go#L165-L171
24,833
dropbox/godropbox
memcache/responses.go
NewMutateResponse
func NewMutateResponse( key string, status ResponseStatus, version uint64) MutateResponse { resp := &genericResponse{ status: status, } resp.item.Key = key if status == StatusNoError { resp.item.DataVersionId = version } return resp }
go
func NewMutateResponse( key string, status ResponseStatus, version uint64) MutateResponse { resp := &genericResponse{ status: status, } resp.item.Key = key if status == StatusNoError { resp.item.DataVersionId = version } return resp }
[ "func", "NewMutateResponse", "(", "key", "string", ",", "status", "ResponseStatus", ",", "version", "uint64", ")", "MutateResponse", "{", "resp", ":=", "&", "genericResponse", "{", "status", ":", "status", ",", "}", "\n", "resp", ".", "item", ".", "Key", "...
// This creates a normal MutateResponse.
[ "This", "creates", "a", "normal", "MutateResponse", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/responses.go#L174-L187
24,834
dropbox/godropbox
memcache/responses.go
NewCountErrorResponse
func NewCountErrorResponse(key string, err error) CountResponse { resp := &genericResponse{ err: err, } resp.item.Key = key return resp }
go
func NewCountErrorResponse(key string, err error) CountResponse { resp := &genericResponse{ err: err, } resp.item.Key = key return resp }
[ "func", "NewCountErrorResponse", "(", "key", "string", ",", "err", "error", ")", "CountResponse", "{", "resp", ":=", "&", "genericResponse", "{", "err", ":", "err", ",", "}", "\n", "resp", ".", "item", ".", "Key", "=", "key", "\n", "return", "resp", "\...
// This creates a CountResponse from an error.
[ "This", "creates", "a", "CountResponse", "from", "an", "error", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/responses.go#L190-L196
24,835
dropbox/godropbox
memcache/responses.go
NewCountResponse
func NewCountResponse( key string, status ResponseStatus, count uint64) CountResponse { resp := &genericResponse{ status: status, } resp.item.Key = key if status == StatusNoError { resp.count = count } return resp }
go
func NewCountResponse( key string, status ResponseStatus, count uint64) CountResponse { resp := &genericResponse{ status: status, } resp.item.Key = key if status == StatusNoError { resp.count = count } return resp }
[ "func", "NewCountResponse", "(", "key", "string", ",", "status", "ResponseStatus", ",", "count", "uint64", ")", "CountResponse", "{", "resp", ":=", "&", "genericResponse", "{", "status", ":", "status", ",", "}", "\n", "resp", ".", "item", ".", "Key", "=", ...
// This creates a normal CountResponse.
[ "This", "creates", "a", "normal", "CountResponse", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/responses.go#L199-L212
24,836
dropbox/godropbox
memcache/responses.go
NewVersionErrorResponse
func NewVersionErrorResponse( err error, versions map[int]string) VersionResponse { return &genericResponse{ err: err, versions: versions, } }
go
func NewVersionErrorResponse( err error, versions map[int]string) VersionResponse { return &genericResponse{ err: err, versions: versions, } }
[ "func", "NewVersionErrorResponse", "(", "err", "error", ",", "versions", "map", "[", "int", "]", "string", ")", "VersionResponse", "{", "return", "&", "genericResponse", "{", "err", ":", "err", ",", "versions", ":", "versions", ",", "}", "\n", "}" ]
// This creates a VersionResponse from an error.
[ "This", "creates", "a", "VersionResponse", "from", "an", "error", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/responses.go#L215-L222
24,837
dropbox/godropbox
memcache/responses.go
NewVersionResponse
func NewVersionResponse( status ResponseStatus, versions map[int]string) VersionResponse { resp := &genericResponse{ status: status, versions: versions, } return resp }
go
func NewVersionResponse( status ResponseStatus, versions map[int]string) VersionResponse { resp := &genericResponse{ status: status, versions: versions, } return resp }
[ "func", "NewVersionResponse", "(", "status", "ResponseStatus", ",", "versions", "map", "[", "int", "]", "string", ")", "VersionResponse", "{", "resp", ":=", "&", "genericResponse", "{", "status", ":", "status", ",", "versions", ":", "versions", ",", "}", "\n...
// This creates a normal VersionResponse.
[ "This", "creates", "a", "normal", "VersionResponse", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/responses.go#L225-L234
24,838
dropbox/godropbox
memcache/responses.go
NewStatErrorResponse
func NewStatErrorResponse( err error, entries map[int](map[string]string)) StatResponse { return &genericResponse{ err: err, statEntries: entries, } }
go
func NewStatErrorResponse( err error, entries map[int](map[string]string)) StatResponse { return &genericResponse{ err: err, statEntries: entries, } }
[ "func", "NewStatErrorResponse", "(", "err", "error", ",", "entries", "map", "[", "int", "]", "(", "map", "[", "string", "]", "string", ")", ")", "StatResponse", "{", "return", "&", "genericResponse", "{", "err", ":", "err", ",", "statEntries", ":", "entr...
// This creates a StatResponse from an error.
[ "This", "creates", "a", "StatResponse", "from", "an", "error", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/responses.go#L237-L244
24,839
dropbox/godropbox
memcache/responses.go
NewStatResponse
func NewStatResponse( status ResponseStatus, entries map[int](map[string]string)) StatResponse { resp := &genericResponse{ status: status, statEntries: entries, } return resp }
go
func NewStatResponse( status ResponseStatus, entries map[int](map[string]string)) StatResponse { resp := &genericResponse{ status: status, statEntries: entries, } return resp }
[ "func", "NewStatResponse", "(", "status", "ResponseStatus", ",", "entries", "map", "[", "int", "]", "(", "map", "[", "string", "]", "string", ")", ")", "StatResponse", "{", "resp", ":=", "&", "genericResponse", "{", "status", ":", "status", ",", "statEntri...
// This creates a normal StatResponse.
[ "This", "creates", "a", "normal", "StatResponse", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/responses.go#L247-L256
24,840
dropbox/godropbox
memcache/base_shard_manager.go
Init
func (m *BaseShardManager) Init( shardFunc func(key string, numShard int) (shard int), logError func(err error), logInfo func(v ...interface{}), options net2.ConnectionOptions) { m.InitWithPool( shardFunc, logError, logInfo, net2.NewMultiConnectionPool(options)) }
go
func (m *BaseShardManager) Init( shardFunc func(key string, numShard int) (shard int), logError func(err error), logInfo func(v ...interface{}), options net2.ConnectionOptions) { m.InitWithPool( shardFunc, logError, logInfo, net2.NewMultiConnectionPool(options)) }
[ "func", "(", "m", "*", "BaseShardManager", ")", "Init", "(", "shardFunc", "func", "(", "key", "string", ",", "numShard", "int", ")", "(", "shard", "int", ")", ",", "logError", "func", "(", "err", "error", ")", ",", "logInfo", "func", "(", "v", "...",...
// Initializes the BaseShardManager.
[ "Initializes", "the", "BaseShardManager", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/base_shard_manager.go#L48-L59
24,841
dropbox/godropbox
memcache/base_shard_manager.go
UpdateShardStates
func (m *BaseShardManager) UpdateShardStates(shardStates []ShardState) { newAddrs := set.NewSet() for _, state := range shardStates { newAddrs.Add(state.Address) } m.rwMutex.Lock() defer m.rwMutex.Unlock() oldAddrs := set.NewSet() for _, state := range m.shardStates { oldAddrs.Add(state.Address) } for a...
go
func (m *BaseShardManager) UpdateShardStates(shardStates []ShardState) { newAddrs := set.NewSet() for _, state := range shardStates { newAddrs.Add(state.Address) } m.rwMutex.Lock() defer m.rwMutex.Unlock() oldAddrs := set.NewSet() for _, state := range m.shardStates { oldAddrs.Add(state.Address) } for a...
[ "func", "(", "m", "*", "BaseShardManager", ")", "UpdateShardStates", "(", "shardStates", "[", "]", "ShardState", ")", "{", "newAddrs", ":=", "set", ".", "NewSet", "(", ")", "\n", "for", "_", ",", "state", ":=", "range", "shardStates", "{", "newAddrs", "....
// This updates the shard manager to use new shard states.
[ "This", "updates", "the", "shard", "manager", "to", "use", "new", "shard", "states", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/base_shard_manager.go#L76-L103
24,842
dropbox/godropbox
memcache/base_shard_manager.go
getShardsForSentinelsLocked
func (m *BaseShardManager) getShardsForSentinelsLocked( keys []string) map[int]*ShardMapping { numShards := len(m.shardStates) results := make(map[int]*ShardMapping) for _, key := range keys { shardId := m.getShardId(key, numShards) entry, inMap := results[shardId] if !inMap { entry = &ShardMapping{} ...
go
func (m *BaseShardManager) getShardsForSentinelsLocked( keys []string) map[int]*ShardMapping { numShards := len(m.shardStates) results := make(map[int]*ShardMapping) for _, key := range keys { shardId := m.getShardId(key, numShards) entry, inMap := results[shardId] if !inMap { entry = &ShardMapping{} ...
[ "func", "(", "m", "*", "BaseShardManager", ")", "getShardsForSentinelsLocked", "(", "keys", "[", "]", "string", ")", "map", "[", "int", "]", "*", "ShardMapping", "{", "numShards", ":=", "len", "(", "m", ".", "shardStates", ")", "\n", "results", ":=", "ma...
// This method assumes that m.rwMutex is locked.
[ "This", "method", "assumes", "that", "m", ".", "rwMutex", "is", "locked", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/memcache/base_shard_manager.go#L213-L251
24,843
dropbox/godropbox
cinterop/buffered_work.go
readBuffer
func readBuffer(copyTo chan<- []byte, socketRead io.ReadCloser, batchSize int, workSize int) { defer close(copyTo) for { batch := make([]byte, batchSize) size, err := socketRead.Read(batch) if err == nil && workSize != 0 && size%workSize != 0 { var lsize int lsize, err = io.ReadFull( socketRead, b...
go
func readBuffer(copyTo chan<- []byte, socketRead io.ReadCloser, batchSize int, workSize int) { defer close(copyTo) for { batch := make([]byte, batchSize) size, err := socketRead.Read(batch) if err == nil && workSize != 0 && size%workSize != 0 { var lsize int lsize, err = io.ReadFull( socketRead, b...
[ "func", "readBuffer", "(", "copyTo", "chan", "<-", "[", "]", "byte", ",", "socketRead", "io", ".", "ReadCloser", ",", "batchSize", "int", ",", "workSize", "int", ")", "{", "defer", "close", "(", "copyTo", ")", "\n", "for", "{", "batch", ":=", "make", ...
// this reads in a loop from socketRead putting batchSize bytes of work to copyTo until // the socketRead is empty. Will always block until a full workSize of units have been copied
[ "this", "reads", "in", "a", "loop", "from", "socketRead", "putting", "batchSize", "bytes", "of", "work", "to", "copyTo", "until", "the", "socketRead", "is", "empty", ".", "Will", "always", "block", "until", "a", "full", "workSize", "of", "units", "have", "...
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/cinterop/buffered_work.go#L11-L36
24,844
dropbox/godropbox
cinterop/buffered_work.go
writeBuffer
func writeBuffer(copyFrom <-chan []byte, socketWrite io.Writer) { for buf := range copyFrom { if len(buf) > 0 { size, err := socketWrite.Write(buf) if err != nil { log.Print("Error encountered in writeBuffer:", err) return } else if size != len(buf) { panic(errors.New("Short Write: io.Writer not...
go
func writeBuffer(copyFrom <-chan []byte, socketWrite io.Writer) { for buf := range copyFrom { if len(buf) > 0 { size, err := socketWrite.Write(buf) if err != nil { log.Print("Error encountered in writeBuffer:", err) return } else if size != len(buf) { panic(errors.New("Short Write: io.Writer not...
[ "func", "writeBuffer", "(", "copyFrom", "<-", "chan", "[", "]", "byte", ",", "socketWrite", "io", ".", "Writer", ")", "{", "for", "buf", ":=", "range", "copyFrom", "{", "if", "len", "(", "buf", ")", ">", "0", "{", "size", ",", "err", ":=", "socketW...
// this simply copies data from the chan to the socketWrite writer
[ "this", "simply", "copies", "data", "from", "the", "chan", "to", "the", "socketWrite", "writer" ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/cinterop/buffered_work.go#L39-L51
24,845
dropbox/godropbox
time2/time2.go
TimeToFloat
func TimeToFloat(t time.Time) float64 { return float64(t.Unix()) + (float64(t.Nanosecond()) / 1e9) }
go
func TimeToFloat(t time.Time) float64 { return float64(t.Unix()) + (float64(t.Nanosecond()) / 1e9) }
[ "func", "TimeToFloat", "(", "t", "time", ".", "Time", ")", "float64", "{", "return", "float64", "(", "t", ".", "Unix", "(", ")", ")", "+", "(", "float64", "(", "t", ".", "Nanosecond", "(", ")", ")", "/", "1e9", ")", "\n", "}" ]
// Convert Time to epoch seconds with subsecond precision.
[ "Convert", "Time", "to", "epoch", "seconds", "with", "subsecond", "precision", "." ]
5749d3b71cbefd8eacc316df3f0a6fcb9991bb51
https://github.com/dropbox/godropbox/blob/5749d3b71cbefd8eacc316df3f0a6fcb9991bb51/time2/time2.go#L11-L13
24,846
gopherjs/gopherjs
nosync/mutex.go
Lock
func (rw *RWMutex) Lock() { if rw.readLockCounter != 0 || rw.writeLocked { panic("nosync: mutex is already locked") } rw.writeLocked = true }
go
func (rw *RWMutex) Lock() { if rw.readLockCounter != 0 || rw.writeLocked { panic("nosync: mutex is already locked") } rw.writeLocked = true }
[ "func", "(", "rw", "*", "RWMutex", ")", "Lock", "(", ")", "{", "if", "rw", ".", "readLockCounter", "!=", "0", "||", "rw", ".", "writeLocked", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "rw", ".", "writeLocked", "=", "true", "\n", "}" ]
// Lock locks m for writing. It is a run-time error if rw is already locked for reading or writing.
[ "Lock", "locks", "m", "for", "writing", ".", "It", "is", "a", "run", "-", "time", "error", "if", "rw", "is", "already", "locked", "for", "reading", "or", "writing", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/nosync/mutex.go#L31-L36
24,847
gopherjs/gopherjs
nosync/mutex.go
Add
func (wg *WaitGroup) Add(delta int) { wg.counter += delta if wg.counter < 0 { panic("sync: negative WaitGroup counter") } }
go
func (wg *WaitGroup) Add(delta int) { wg.counter += delta if wg.counter < 0 { panic("sync: negative WaitGroup counter") } }
[ "func", "(", "wg", "*", "WaitGroup", ")", "Add", "(", "delta", "int", ")", "{", "wg", ".", "counter", "+=", "delta", "\n", "if", "wg", ".", "counter", "<", "0", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n", "}" ]
// Add adds delta, which may be negative, to the WaitGroup If the counter goes negative, Add panics.
[ "Add", "adds", "delta", "which", "may", "be", "negative", "to", "the", "WaitGroup", "If", "the", "counter", "goes", "negative", "Add", "panics", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/nosync/mutex.go#L68-L73
24,848
gopherjs/gopherjs
compiler/natives/src/sync/sync.go
runtime_nanotime
func runtime_nanotime() int64 { const millisecond = 1000000 return js.Global.Get("Date").New().Call("getTime").Int64() * millisecond }
go
func runtime_nanotime() int64 { const millisecond = 1000000 return js.Global.Get("Date").New().Call("getTime").Int64() * millisecond }
[ "func", "runtime_nanotime", "(", ")", "int64", "{", "const", "millisecond", "=", "1000000", "\n", "return", "js", ".", "Global", ".", "Get", "(", "\"", "\"", ")", ".", "New", "(", ")", ".", "Call", "(", "\"", "\"", ")", ".", "Int64", "(", ")", "*...
// Copy of time.runtimeNano.
[ "Copy", "of", "time", ".", "runtimeNano", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/compiler/natives/src/sync/sync.go#L72-L75
24,849
gopherjs/gopherjs
nosync/map.go
Load
func (m *Map) Load(key interface{}) (value interface{}, ok bool) { value, ok = m.m[key] return value, ok }
go
func (m *Map) Load(key interface{}) (value interface{}, ok bool) { value, ok = m.m[key] return value, ok }
[ "func", "(", "m", "*", "Map", ")", "Load", "(", "key", "interface", "{", "}", ")", "(", "value", "interface", "{", "}", ",", "ok", "bool", ")", "{", "value", ",", "ok", "=", "m", ".", "m", "[", "key", "]", "\n", "return", "value", ",", "ok", ...
// Load returns the value stored in the map for a key, or nil if no // value is present. // The ok result indicates whether value was found in the map.
[ "Load", "returns", "the", "value", "stored", "in", "the", "map", "for", "a", "key", "or", "nil", "if", "no", "value", "is", "present", ".", "The", "ok", "result", "indicates", "whether", "value", "was", "found", "in", "the", "map", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/nosync/map.go#L16-L19
24,850
gopherjs/gopherjs
nosync/map.go
Store
func (m *Map) Store(key, value interface{}) { if m.m == nil { m.m = make(map[interface{}]interface{}) } m.m[key] = value }
go
func (m *Map) Store(key, value interface{}) { if m.m == nil { m.m = make(map[interface{}]interface{}) } m.m[key] = value }
[ "func", "(", "m", "*", "Map", ")", "Store", "(", "key", ",", "value", "interface", "{", "}", ")", "{", "if", "m", ".", "m", "==", "nil", "{", "m", ".", "m", "=", "make", "(", "map", "[", "interface", "{", "}", "]", "interface", "{", "}", ")...
// Store sets the value for a key.
[ "Store", "sets", "the", "value", "for", "a", "key", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/nosync/map.go#L22-L27
24,851
gopherjs/gopherjs
nosync/map.go
LoadOrStore
func (m *Map) LoadOrStore(key, value interface{}) (actual interface{}, loaded bool) { if value, ok := m.m[key]; ok { return value, true } if m.m == nil { m.m = make(map[interface{}]interface{}) } m.m[key] = value return value, false }
go
func (m *Map) LoadOrStore(key, value interface{}) (actual interface{}, loaded bool) { if value, ok := m.m[key]; ok { return value, true } if m.m == nil { m.m = make(map[interface{}]interface{}) } m.m[key] = value return value, false }
[ "func", "(", "m", "*", "Map", ")", "LoadOrStore", "(", "key", ",", "value", "interface", "{", "}", ")", "(", "actual", "interface", "{", "}", ",", "loaded", "bool", ")", "{", "if", "value", ",", "ok", ":=", "m", ".", "m", "[", "key", "]", ";", ...
// LoadOrStore returns the existing value for the key if present. // Otherwise, it stores and returns the given value. // The loaded result is true if the value was loaded, false if stored.
[ "LoadOrStore", "returns", "the", "existing", "value", "for", "the", "key", "if", "present", ".", "Otherwise", "it", "stores", "and", "returns", "the", "given", "value", ".", "The", "loaded", "result", "is", "true", "if", "the", "value", "was", "loaded", "f...
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/nosync/map.go#L32-L41
24,852
gopherjs/gopherjs
js/js.go
MakeFunc
func MakeFunc(fn func(this *Object, arguments []*Object) interface{}) *Object { return Global.Call("$makeFunc", InternalObject(fn)) }
go
func MakeFunc(fn func(this *Object, arguments []*Object) interface{}) *Object { return Global.Call("$makeFunc", InternalObject(fn)) }
[ "func", "MakeFunc", "(", "fn", "func", "(", "this", "*", "Object", ",", "arguments", "[", "]", "*", "Object", ")", "interface", "{", "}", ")", "*", "Object", "{", "return", "Global", ".", "Call", "(", "\"", "\"", ",", "InternalObject", "(", "fn", "...
// MakeFunc wraps a function and gives access to the values of JavaScript's "this" and "arguments" keywords.
[ "MakeFunc", "wraps", "a", "function", "and", "gives", "access", "to", "the", "values", "of", "JavaScript", "s", "this", "and", "arguments", "keywords", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/js/js.go#L115-L117
24,853
gopherjs/gopherjs
js/js.go
Keys
func Keys(o *Object) []string { if o == nil || o == Undefined { return nil } a := Global.Get("Object").Call("keys", o) s := make([]string, a.Length()) for i := 0; i < a.Length(); i++ { s[i] = a.Index(i).String() } return s }
go
func Keys(o *Object) []string { if o == nil || o == Undefined { return nil } a := Global.Get("Object").Call("keys", o) s := make([]string, a.Length()) for i := 0; i < a.Length(); i++ { s[i] = a.Index(i).String() } return s }
[ "func", "Keys", "(", "o", "*", "Object", ")", "[", "]", "string", "{", "if", "o", "==", "nil", "||", "o", "==", "Undefined", "{", "return", "nil", "\n", "}", "\n", "a", ":=", "Global", ".", "Get", "(", "\"", "\"", ")", ".", "Call", "(", "\"",...
// Keys returns the keys of the given JavaScript object.
[ "Keys", "returns", "the", "keys", "of", "the", "given", "JavaScript", "object", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/js/js.go#L120-L130
24,854
gopherjs/gopherjs
js/js.go
MakeWrapper
func MakeWrapper(i interface{}) *Object { v := InternalObject(i) o := Global.Get("Object").New() o.Set("__internal_object__", v) methods := v.Get("constructor").Get("methods") for i := 0; i < methods.Length(); i++ { m := methods.Index(i) if m.Get("pkg").String() != "" { // not exported continue } o.Set(...
go
func MakeWrapper(i interface{}) *Object { v := InternalObject(i) o := Global.Get("Object").New() o.Set("__internal_object__", v) methods := v.Get("constructor").Get("methods") for i := 0; i < methods.Length(); i++ { m := methods.Index(i) if m.Get("pkg").String() != "" { // not exported continue } o.Set(...
[ "func", "MakeWrapper", "(", "i", "interface", "{", "}", ")", "*", "Object", "{", "v", ":=", "InternalObject", "(", "i", ")", "\n", "o", ":=", "Global", ".", "Get", "(", "\"", "\"", ")", ".", "New", "(", ")", "\n", "o", ".", "Set", "(", "\"", ...
// MakeWrapper creates a JavaScript object which has wrappers for the exported methods of i. Use explicit getter and setter methods to expose struct fields to JavaScript.
[ "MakeWrapper", "creates", "a", "JavaScript", "object", "which", "has", "wrappers", "for", "the", "exported", "methods", "of", "i", ".", "Use", "explicit", "getter", "and", "setter", "methods", "to", "expose", "struct", "fields", "to", "JavaScript", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/js/js.go#L133-L148
24,855
gopherjs/gopherjs
js/js.go
NewArrayBuffer
func NewArrayBuffer(b []byte) *Object { slice := InternalObject(b) offset := slice.Get("$offset").Int() length := slice.Get("$length").Int() return slice.Get("$array").Get("buffer").Call("slice", offset, offset+length) }
go
func NewArrayBuffer(b []byte) *Object { slice := InternalObject(b) offset := slice.Get("$offset").Int() length := slice.Get("$length").Int() return slice.Get("$array").Get("buffer").Call("slice", offset, offset+length) }
[ "func", "NewArrayBuffer", "(", "b", "[", "]", "byte", ")", "*", "Object", "{", "slice", ":=", "InternalObject", "(", "b", ")", "\n", "offset", ":=", "slice", ".", "Get", "(", "\"", "\"", ")", ".", "Int", "(", ")", "\n", "length", ":=", "slice", "...
// NewArrayBuffer creates a JavaScript ArrayBuffer from a byte slice.
[ "NewArrayBuffer", "creates", "a", "JavaScript", "ArrayBuffer", "from", "a", "byte", "slice", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/js/js.go#L151-L156
24,856
gopherjs/gopherjs
compiler/natives/src/internal/poll/fd_poll.go
runtime_Semacquire
func runtime_Semacquire(s *uint32) { if *s == 0 { ch := make(chan bool) semWaiters[s] = append(semWaiters[s], ch) <-ch } *s-- }
go
func runtime_Semacquire(s *uint32) { if *s == 0 { ch := make(chan bool) semWaiters[s] = append(semWaiters[s], ch) <-ch } *s-- }
[ "func", "runtime_Semacquire", "(", "s", "*", "uint32", ")", "{", "if", "*", "s", "==", "0", "{", "ch", ":=", "make", "(", "chan", "bool", ")", "\n", "semWaiters", "[", "s", "]", "=", "append", "(", "semWaiters", "[", "s", "]", ",", "ch", ")", "...
// Copy of sync.runtime_Semacquire.
[ "Copy", "of", "sync", ".", "runtime_Semacquire", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/compiler/natives/src/internal/poll/fd_poll.go#L60-L67
24,857
gopherjs/gopherjs
compiler/natives/src/internal/poll/fd_poll.go
runtime_Semrelease
func runtime_Semrelease(s *uint32) { *s++ w := semWaiters[s] if len(w) == 0 { return } ch := w[0] w = w[1:] semWaiters[s] = w if len(w) == 0 { delete(semWaiters, s) } ch <- true }
go
func runtime_Semrelease(s *uint32) { *s++ w := semWaiters[s] if len(w) == 0 { return } ch := w[0] w = w[1:] semWaiters[s] = w if len(w) == 0 { delete(semWaiters, s) } ch <- true }
[ "func", "runtime_Semrelease", "(", "s", "*", "uint32", ")", "{", "*", "s", "++", "\n\n", "w", ":=", "semWaiters", "[", "s", "]", "\n", "if", "len", "(", "w", ")", "==", "0", "{", "return", "\n", "}", "\n\n", "ch", ":=", "w", "[", "0", "]", "\...
// Copy of sync.runtime_Semrelease.
[ "Copy", "of", "sync", ".", "runtime_Semrelease", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/compiler/natives/src/internal/poll/fd_poll.go#L70-L86
24,858
gopherjs/gopherjs
build/build.go
excludeExecutable
func excludeExecutable(goFiles []string) []string { var s []string for _, f := range goFiles { if strings.HasPrefix(f, "executable_") { continue } s = append(s, f) } return s }
go
func excludeExecutable(goFiles []string) []string { var s []string for _, f := range goFiles { if strings.HasPrefix(f, "executable_") { continue } s = append(s, f) } return s }
[ "func", "excludeExecutable", "(", "goFiles", "[", "]", "string", ")", "[", "]", "string", "{", "var", "s", "[", "]", "string", "\n", "for", "_", ",", "f", ":=", "range", "goFiles", "{", "if", "strings", ".", "HasPrefix", "(", "f", ",", "\"", "\"", ...
// excludeExecutable excludes all executable implementation .go files. // They have "executable_" prefix.
[ "excludeExecutable", "excludes", "all", "executable", "implementation", ".", "go", "files", ".", "They", "have", "executable_", "prefix", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/build/build.go#L205-L214
24,859
gopherjs/gopherjs
build/build.go
exclude
func exclude(files []string, exclude ...string) []string { var s []string Outer: for _, f := range files { for _, e := range exclude { if f == e { continue Outer } } s = append(s, f) } return s }
go
func exclude(files []string, exclude ...string) []string { var s []string Outer: for _, f := range files { for _, e := range exclude { if f == e { continue Outer } } s = append(s, f) } return s }
[ "func", "exclude", "(", "files", "[", "]", "string", ",", "exclude", "...", "string", ")", "[", "]", "string", "{", "var", "s", "[", "]", "string", "\n", "Outer", ":", "for", "_", ",", "f", ":=", "range", "files", "{", "for", "_", ",", "e", ":=...
// exclude returns files, excluding specified files.
[ "exclude", "returns", "files", "excluding", "specified", "files", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/build/build.go#L217-L229
24,860
gopherjs/gopherjs
build/build.go
ImportDir
func ImportDir(dir string, mode build.ImportMode, installSuffix string, buildTags []string) (*PackageData, error) { bctx := NewBuildContext(installSuffix, buildTags) pkg, err := bctx.ImportDir(dir, mode) if err != nil { return nil, err } jsFiles, err := jsFilesFromDir(bctx, pkg.Dir) if err != nil { return ni...
go
func ImportDir(dir string, mode build.ImportMode, installSuffix string, buildTags []string) (*PackageData, error) { bctx := NewBuildContext(installSuffix, buildTags) pkg, err := bctx.ImportDir(dir, mode) if err != nil { return nil, err } jsFiles, err := jsFilesFromDir(bctx, pkg.Dir) if err != nil { return ni...
[ "func", "ImportDir", "(", "dir", "string", ",", "mode", "build", ".", "ImportMode", ",", "installSuffix", "string", ",", "buildTags", "[", "]", "string", ")", "(", "*", "PackageData", ",", "error", ")", "{", "bctx", ":=", "NewBuildContext", "(", "installSu...
// ImportDir is like Import but processes the Go package found in the named // directory.
[ "ImportDir", "is", "like", "Import", "but", "processes", "the", "Go", "package", "found", "in", "the", "named", "directory", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/build/build.go#L233-L246
24,861
gopherjs/gopherjs
build/build.go
hasGopathPrefix
func hasGopathPrefix(file, gopath string) (hasGopathPrefix bool, prefixLen int) { gopathWorkspaces := filepath.SplitList(gopath) for _, gopathWorkspace := range gopathWorkspaces { gopathWorkspace = filepath.Clean(gopathWorkspace) if strings.HasPrefix(file, gopathWorkspace) { return true, len(gopathWorkspace) ...
go
func hasGopathPrefix(file, gopath string) (hasGopathPrefix bool, prefixLen int) { gopathWorkspaces := filepath.SplitList(gopath) for _, gopathWorkspace := range gopathWorkspaces { gopathWorkspace = filepath.Clean(gopathWorkspace) if strings.HasPrefix(file, gopathWorkspace) { return true, len(gopathWorkspace) ...
[ "func", "hasGopathPrefix", "(", "file", ",", "gopath", "string", ")", "(", "hasGopathPrefix", "bool", ",", "prefixLen", "int", ")", "{", "gopathWorkspaces", ":=", "filepath", ".", "SplitList", "(", "gopath", ")", "\n", "for", "_", ",", "gopathWorkspace", ":=...
// hasGopathPrefix returns true and the length of the matched GOPATH workspace, // iff file has a prefix that matches one of the GOPATH workspaces.
[ "hasGopathPrefix", "returns", "true", "and", "the", "length", "of", "the", "matched", "GOPATH", "workspace", "iff", "file", "has", "a", "prefix", "that", "matches", "one", "of", "the", "GOPATH", "workspaces", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/build/build.go#L843-L852
24,862
gopherjs/gopherjs
internal/sysutil/sysutil.go
RlimitStack
func RlimitStack() (cur uint64, err error) { var r unix.Rlimit err = unix.Getrlimit(unix.RLIMIT_STACK, &r) return uint64(r.Cur), err // Type conversion because Cur is one of uint64, int64 depending on unix flavor. }
go
func RlimitStack() (cur uint64, err error) { var r unix.Rlimit err = unix.Getrlimit(unix.RLIMIT_STACK, &r) return uint64(r.Cur), err // Type conversion because Cur is one of uint64, int64 depending on unix flavor. }
[ "func", "RlimitStack", "(", ")", "(", "cur", "uint64", ",", "err", "error", ")", "{", "var", "r", "unix", ".", "Rlimit", "\n", "err", "=", "unix", ".", "Getrlimit", "(", "unix", ".", "RLIMIT_STACK", ",", "&", "r", ")", "\n", "return", "uint64", "("...
// RlimitStack reports the current stack size limit in bytes.
[ "RlimitStack", "reports", "the", "current", "stack", "size", "limit", "in", "bytes", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/internal/sysutil/sysutil.go#L9-L13
24,863
gopherjs/gopherjs
compiler/natives/src/syscall/js/js.go
convertArgs
func convertArgs(args ...interface{}) []interface{} { newArgs := []interface{}{} for _, arg := range args { v := ValueOf(arg) newArgs = append(newArgs, v.internal()) } return newArgs }
go
func convertArgs(args ...interface{}) []interface{} { newArgs := []interface{}{} for _, arg := range args { v := ValueOf(arg) newArgs = append(newArgs, v.internal()) } return newArgs }
[ "func", "convertArgs", "(", "args", "...", "interface", "{", "}", ")", "[", "]", "interface", "{", "}", "{", "newArgs", ":=", "[", "]", "interface", "{", "}", "{", "}", "\n", "for", "_", ",", "arg", ":=", "range", "args", "{", "v", ":=", "ValueOf...
// convertArgs converts arguments into values for GopherJS arguments.
[ "convertArgs", "converts", "arguments", "into", "values", "for", "GopherJS", "arguments", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/compiler/natives/src/syscall/js/js.go#L171-L178
24,864
gopherjs/gopherjs
compiler/natives/src/net/net.go
bytesEqual
func bytesEqual(x, y []byte) bool { if len(x) != len(y) { return false } for i, b := range x { if b != y[i] { return false } } return true }
go
func bytesEqual(x, y []byte) bool { if len(x) != len(y) { return false } for i, b := range x { if b != y[i] { return false } } return true }
[ "func", "bytesEqual", "(", "x", ",", "y", "[", "]", "byte", ")", "bool", "{", "if", "len", "(", "x", ")", "!=", "len", "(", "y", ")", "{", "return", "false", "\n", "}", "\n", "for", "i", ",", "b", ":=", "range", "x", "{", "if", "b", "!=", ...
// Copy of bytes.Equal.
[ "Copy", "of", "bytes", ".", "Equal", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/compiler/natives/src/net/net.go#L45-L55
24,865
gopherjs/gopherjs
compiler/natives/src/net/net.go
bytesIndexByte
func bytesIndexByte(s []byte, c byte) int { for i, b := range s { if b == c { return i } } return -1 }
go
func bytesIndexByte(s []byte, c byte) int { for i, b := range s { if b == c { return i } } return -1 }
[ "func", "bytesIndexByte", "(", "s", "[", "]", "byte", ",", "c", "byte", ")", "int", "{", "for", "i", ",", "b", ":=", "range", "s", "{", "if", "b", "==", "c", "{", "return", "i", "\n", "}", "\n", "}", "\n", "return", "-", "1", "\n", "}" ]
// Copy of bytes.IndexByte.
[ "Copy", "of", "bytes", ".", "IndexByte", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/compiler/natives/src/net/net.go#L58-L65
24,866
gopherjs/gopherjs
tool.go
handleError
func handleError(err error, options *gbuild.Options, browserErrors *bytes.Buffer) int { switch err := err.(type) { case nil: return 0 case compiler.ErrorList: for _, entry := range err { printError(entry, options, browserErrors) } return 1 case *exec.ExitError: return err.Sys().(syscall.WaitStatus).Exi...
go
func handleError(err error, options *gbuild.Options, browserErrors *bytes.Buffer) int { switch err := err.(type) { case nil: return 0 case compiler.ErrorList: for _, entry := range err { printError(entry, options, browserErrors) } return 1 case *exec.ExitError: return err.Sys().(syscall.WaitStatus).Exi...
[ "func", "handleError", "(", "err", "error", ",", "options", "*", "gbuild", ".", "Options", ",", "browserErrors", "*", "bytes", ".", "Buffer", ")", "int", "{", "switch", "err", ":=", "err", ".", "(", "type", ")", "{", "case", "nil", ":", "return", "0"...
// handleError handles err and returns an appropriate exit code. // If browserErrors is non-nil, errors are written for presentation in browser.
[ "handleError", "handles", "err", "and", "returns", "an", "appropriate", "exit", "code", ".", "If", "browserErrors", "is", "non", "-", "nil", "errors", "are", "written", "for", "presentation", "in", "browser", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/tool.go#L698-L713
24,867
gopherjs/gopherjs
tool.go
printError
func printError(err error, options *gbuild.Options, browserErrors *bytes.Buffer) { e := sprintError(err) options.PrintError("%s\n", e) if browserErrors != nil { fmt.Fprintln(browserErrors, `console.error("`+template.JSEscapeString(e)+`");`) } }
go
func printError(err error, options *gbuild.Options, browserErrors *bytes.Buffer) { e := sprintError(err) options.PrintError("%s\n", e) if browserErrors != nil { fmt.Fprintln(browserErrors, `console.error("`+template.JSEscapeString(e)+`");`) } }
[ "func", "printError", "(", "err", "error", ",", "options", "*", "gbuild", ".", "Options", ",", "browserErrors", "*", "bytes", ".", "Buffer", ")", "{", "e", ":=", "sprintError", "(", "err", ")", "\n", "options", ".", "PrintError", "(", "\"", "\\n", "\""...
// printError prints err to Stderr with options. If browserErrors is non-nil, errors are also written for presentation in browser.
[ "printError", "prints", "err", "to", "Stderr", "with", "options", ".", "If", "browserErrors", "is", "non", "-", "nil", "errors", "are", "also", "written", "for", "presentation", "in", "browser", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/tool.go#L716-L722
24,868
gopherjs/gopherjs
tool.go
sprintError
func sprintError(err error) string { makeRel := func(name string) string { if relname, err := filepath.Rel(currentDirectory, name); err == nil { return relname } return name } switch e := err.(type) { case *scanner.Error: return fmt.Sprintf("%s:%d:%d: %s", makeRel(e.Pos.Filename), e.Pos.Line, e.Pos.Colu...
go
func sprintError(err error) string { makeRel := func(name string) string { if relname, err := filepath.Rel(currentDirectory, name); err == nil { return relname } return name } switch e := err.(type) { case *scanner.Error: return fmt.Sprintf("%s:%d:%d: %s", makeRel(e.Pos.Filename), e.Pos.Line, e.Pos.Colu...
[ "func", "sprintError", "(", "err", "error", ")", "string", "{", "makeRel", ":=", "func", "(", "name", "string", ")", "string", "{", "if", "relname", ",", "err", ":=", "filepath", ".", "Rel", "(", "currentDirectory", ",", "name", ")", ";", "err", "==", ...
// sprintError returns an annotated error string without trailing newline.
[ "sprintError", "returns", "an", "annotated", "error", "string", "without", "trailing", "newline", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/tool.go#L725-L742
24,869
gopherjs/gopherjs
tool.go
runNode
func runNode(script string, args []string, dir string, quiet bool) error { var allArgs []string if b, _ := strconv.ParseBool(os.Getenv("SOURCE_MAP_SUPPORT")); os.Getenv("SOURCE_MAP_SUPPORT") == "" || b { allArgs = []string{"--require", "source-map-support/register"} if err := exec.Command("node", "--require", "so...
go
func runNode(script string, args []string, dir string, quiet bool) error { var allArgs []string if b, _ := strconv.ParseBool(os.Getenv("SOURCE_MAP_SUPPORT")); os.Getenv("SOURCE_MAP_SUPPORT") == "" || b { allArgs = []string{"--require", "source-map-support/register"} if err := exec.Command("node", "--require", "so...
[ "func", "runNode", "(", "script", "string", ",", "args", "[", "]", "string", ",", "dir", "string", ",", "quiet", "bool", ")", "error", "{", "var", "allArgs", "[", "]", "string", "\n", "if", "b", ",", "_", ":=", "strconv", ".", "ParseBool", "(", "os...
// runNode runs script with args using Node.js in directory dir. // If dir is empty string, current directory is used.
[ "runNode", "runs", "script", "with", "args", "using", "Node", ".", "js", "in", "directory", "dir", ".", "If", "dir", "is", "empty", "string", "current", "directory", "is", "used", "." ]
3e4dfb77656c424b6d1196a4d5fed0fcf63677cc
https://github.com/gopherjs/gopherjs/blob/3e4dfb77656c424b6d1196a4d5fed0fcf63677cc/tool.go#L746-L794
24,870
disintegration/imaging
tools.go
New
func New(width, height int, fillColor color.Color) *image.NRGBA { if width <= 0 || height <= 0 { return &image.NRGBA{} } c := color.NRGBAModel.Convert(fillColor).(color.NRGBA) if (c == color.NRGBA{0, 0, 0, 0}) { return image.NewNRGBA(image.Rect(0, 0, width, height)) } return &image.NRGBA{ Pix: bytes.Re...
go
func New(width, height int, fillColor color.Color) *image.NRGBA { if width <= 0 || height <= 0 { return &image.NRGBA{} } c := color.NRGBAModel.Convert(fillColor).(color.NRGBA) if (c == color.NRGBA{0, 0, 0, 0}) { return image.NewNRGBA(image.Rect(0, 0, width, height)) } return &image.NRGBA{ Pix: bytes.Re...
[ "func", "New", "(", "width", ",", "height", "int", ",", "fillColor", "color", ".", "Color", ")", "*", "image", ".", "NRGBA", "{", "if", "width", "<=", "0", "||", "height", "<=", "0", "{", "return", "&", "image", ".", "NRGBA", "{", "}", "\n", "}",...
// New creates a new image with the specified width and height, and fills it with the specified color.
[ "New", "creates", "a", "new", "image", "with", "the", "specified", "width", "and", "height", "and", "fills", "it", "with", "the", "specified", "color", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/tools.go#L11-L26
24,871
disintegration/imaging
tools.go
Clone
func Clone(img image.Image) *image.NRGBA { src := newScanner(img) dst := image.NewNRGBA(image.Rect(0, 0, src.w, src.h)) size := src.w * 4 parallel(0, src.h, func(ys <-chan int) { for y := range ys { i := y * dst.Stride src.scan(0, y, src.w, y+1, dst.Pix[i:i+size]) } }) return dst }
go
func Clone(img image.Image) *image.NRGBA { src := newScanner(img) dst := image.NewNRGBA(image.Rect(0, 0, src.w, src.h)) size := src.w * 4 parallel(0, src.h, func(ys <-chan int) { for y := range ys { i := y * dst.Stride src.scan(0, y, src.w, y+1, dst.Pix[i:i+size]) } }) return dst }
[ "func", "Clone", "(", "img", "image", ".", "Image", ")", "*", "image", ".", "NRGBA", "{", "src", ":=", "newScanner", "(", "img", ")", "\n", "dst", ":=", "image", ".", "NewNRGBA", "(", "image", ".", "Rect", "(", "0", ",", "0", ",", "src", ".", "...
// Clone returns a copy of the given image.
[ "Clone", "returns", "a", "copy", "of", "the", "given", "image", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/tools.go#L29-L40
24,872
disintegration/imaging
tools.go
Crop
func Crop(img image.Image, rect image.Rectangle) *image.NRGBA { r := rect.Intersect(img.Bounds()).Sub(img.Bounds().Min) if r.Empty() { return &image.NRGBA{} } src := newScanner(img) dst := image.NewNRGBA(image.Rect(0, 0, r.Dx(), r.Dy())) rowSize := r.Dx() * 4 parallel(r.Min.Y, r.Max.Y, func(ys <-chan int) { ...
go
func Crop(img image.Image, rect image.Rectangle) *image.NRGBA { r := rect.Intersect(img.Bounds()).Sub(img.Bounds().Min) if r.Empty() { return &image.NRGBA{} } src := newScanner(img) dst := image.NewNRGBA(image.Rect(0, 0, r.Dx(), r.Dy())) rowSize := r.Dx() * 4 parallel(r.Min.Y, r.Max.Y, func(ys <-chan int) { ...
[ "func", "Crop", "(", "img", "image", ".", "Image", ",", "rect", "image", ".", "Rectangle", ")", "*", "image", ".", "NRGBA", "{", "r", ":=", "rect", ".", "Intersect", "(", "img", ".", "Bounds", "(", ")", ")", ".", "Sub", "(", "img", ".", "Bounds",...
// Crop cuts out a rectangular region with the specified bounds // from the image and returns the cropped image.
[ "Crop", "cuts", "out", "a", "rectangular", "region", "with", "the", "specified", "bounds", "from", "the", "image", "and", "returns", "the", "cropped", "image", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/tools.go#L94-L109
24,873
disintegration/imaging
tools.go
CropAnchor
func CropAnchor(img image.Image, width, height int, anchor Anchor) *image.NRGBA { srcBounds := img.Bounds() pt := anchorPt(srcBounds, width, height, anchor) r := image.Rect(0, 0, width, height).Add(pt) b := srcBounds.Intersect(r) return Crop(img, b) }
go
func CropAnchor(img image.Image, width, height int, anchor Anchor) *image.NRGBA { srcBounds := img.Bounds() pt := anchorPt(srcBounds, width, height, anchor) r := image.Rect(0, 0, width, height).Add(pt) b := srcBounds.Intersect(r) return Crop(img, b) }
[ "func", "CropAnchor", "(", "img", "image", ".", "Image", ",", "width", ",", "height", "int", ",", "anchor", "Anchor", ")", "*", "image", ".", "NRGBA", "{", "srcBounds", ":=", "img", ".", "Bounds", "(", ")", "\n", "pt", ":=", "anchorPt", "(", "srcBoun...
// CropAnchor cuts out a rectangular region with the specified size // from the image using the specified anchor point and returns the cropped image.
[ "CropAnchor", "cuts", "out", "a", "rectangular", "region", "with", "the", "specified", "size", "from", "the", "image", "using", "the", "specified", "anchor", "point", "and", "returns", "the", "cropped", "image", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/tools.go#L113-L119
24,874
disintegration/imaging
tools.go
CropCenter
func CropCenter(img image.Image, width, height int) *image.NRGBA { return CropAnchor(img, width, height, Center) }
go
func CropCenter(img image.Image, width, height int) *image.NRGBA { return CropAnchor(img, width, height, Center) }
[ "func", "CropCenter", "(", "img", "image", ".", "Image", ",", "width", ",", "height", "int", ")", "*", "image", ".", "NRGBA", "{", "return", "CropAnchor", "(", "img", ",", "width", ",", "height", ",", "Center", ")", "\n", "}" ]
// CropCenter cuts out a rectangular region with the specified size // from the center of the image and returns the cropped image.
[ "CropCenter", "cuts", "out", "a", "rectangular", "region", "with", "the", "specified", "size", "from", "the", "center", "of", "the", "image", "and", "returns", "the", "cropped", "image", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/tools.go#L123-L125
24,875
disintegration/imaging
tools.go
Paste
func Paste(background, img image.Image, pos image.Point) *image.NRGBA { dst := Clone(background) pos = pos.Sub(background.Bounds().Min) pasteRect := image.Rectangle{Min: pos, Max: pos.Add(img.Bounds().Size())} interRect := pasteRect.Intersect(dst.Bounds()) if interRect.Empty() { return dst } src := newScanner(...
go
func Paste(background, img image.Image, pos image.Point) *image.NRGBA { dst := Clone(background) pos = pos.Sub(background.Bounds().Min) pasteRect := image.Rectangle{Min: pos, Max: pos.Add(img.Bounds().Size())} interRect := pasteRect.Intersect(dst.Bounds()) if interRect.Empty() { return dst } src := newScanner(...
[ "func", "Paste", "(", "background", ",", "img", "image", ".", "Image", ",", "pos", "image", ".", "Point", ")", "*", "image", ".", "NRGBA", "{", "dst", ":=", "Clone", "(", "background", ")", "\n", "pos", "=", "pos", ".", "Sub", "(", "background", "....
// Paste pastes the img image to the background image at the specified position and returns the combined image.
[ "Paste", "pastes", "the", "img", "image", "to", "the", "background", "image", "at", "the", "specified", "position", "and", "returns", "the", "combined", "image", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/tools.go#L128-L149
24,876
disintegration/imaging
tools.go
PasteCenter
func PasteCenter(background, img image.Image) *image.NRGBA { bgBounds := background.Bounds() bgW := bgBounds.Dx() bgH := bgBounds.Dy() bgMinX := bgBounds.Min.X bgMinY := bgBounds.Min.Y centerX := bgMinX + bgW/2 centerY := bgMinY + bgH/2 x0 := centerX - img.Bounds().Dx()/2 y0 := centerY - img.Bounds().Dy()/2 ...
go
func PasteCenter(background, img image.Image) *image.NRGBA { bgBounds := background.Bounds() bgW := bgBounds.Dx() bgH := bgBounds.Dy() bgMinX := bgBounds.Min.X bgMinY := bgBounds.Min.Y centerX := bgMinX + bgW/2 centerY := bgMinY + bgH/2 x0 := centerX - img.Bounds().Dx()/2 y0 := centerY - img.Bounds().Dy()/2 ...
[ "func", "PasteCenter", "(", "background", ",", "img", "image", ".", "Image", ")", "*", "image", ".", "NRGBA", "{", "bgBounds", ":=", "background", ".", "Bounds", "(", ")", "\n", "bgW", ":=", "bgBounds", ".", "Dx", "(", ")", "\n", "bgH", ":=", "bgBoun...
// PasteCenter pastes the img image to the center of the background image and returns the combined image.
[ "PasteCenter", "pastes", "the", "img", "image", "to", "the", "center", "of", "the", "background", "image", "and", "returns", "the", "combined", "image", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/tools.go#L152-L166
24,877
disintegration/imaging
tools.go
OverlayCenter
func OverlayCenter(background, img image.Image, opacity float64) *image.NRGBA { bgBounds := background.Bounds() bgW := bgBounds.Dx() bgH := bgBounds.Dy() bgMinX := bgBounds.Min.X bgMinY := bgBounds.Min.Y centerX := bgMinX + bgW/2 centerY := bgMinY + bgH/2 x0 := centerX - img.Bounds().Dx()/2 y0 := centerY - i...
go
func OverlayCenter(background, img image.Image, opacity float64) *image.NRGBA { bgBounds := background.Bounds() bgW := bgBounds.Dx() bgH := bgBounds.Dy() bgMinX := bgBounds.Min.X bgMinY := bgBounds.Min.Y centerX := bgMinX + bgW/2 centerY := bgMinY + bgH/2 x0 := centerX - img.Bounds().Dx()/2 y0 := centerY - i...
[ "func", "OverlayCenter", "(", "background", ",", "img", "image", ".", "Image", ",", "opacity", "float64", ")", "*", "image", ".", "NRGBA", "{", "bgBounds", ":=", "background", ".", "Bounds", "(", ")", "\n", "bgW", ":=", "bgBounds", ".", "Dx", "(", ")",...
// OverlayCenter overlays the img image to the center of the background image and // returns the combined image. Opacity parameter is the opacity of the img // image layer, used to compose the images, it must be from 0.0 to 1.0.
[ "OverlayCenter", "overlays", "the", "img", "image", "to", "the", "center", "of", "the", "background", "image", "and", "returns", "the", "combined", "image", ".", "Opacity", "parameter", "is", "the", "opacity", "of", "the", "img", "image", "layer", "used", "t...
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/tools.go#L235-L249
24,878
disintegration/imaging
transform.go
Rotate
func Rotate(img image.Image, angle float64, bgColor color.Color) *image.NRGBA { angle = angle - math.Floor(angle/360)*360 switch angle { case 0: return Clone(img) case 90: return Rotate90(img) case 180: return Rotate180(img) case 270: return Rotate270(img) } src := toNRGBA(img) srcW := src.Bounds().M...
go
func Rotate(img image.Image, angle float64, bgColor color.Color) *image.NRGBA { angle = angle - math.Floor(angle/360)*360 switch angle { case 0: return Clone(img) case 90: return Rotate90(img) case 180: return Rotate180(img) case 270: return Rotate270(img) } src := toNRGBA(img) srcW := src.Bounds().M...
[ "func", "Rotate", "(", "img", "image", ".", "Image", ",", "angle", "float64", ",", "bgColor", "color", ".", "Color", ")", "*", "image", ".", "NRGBA", "{", "angle", "=", "angle", "-", "math", ".", "Floor", "(", "angle", "/", "360", ")", "*", "360", ...
// Rotate rotates an image by the given angle counter-clockwise . // The angle parameter is the rotation angle in degrees. // The bgColor parameter specifies the color of the uncovered zone after the rotation.
[ "Rotate", "rotates", "an", "image", "by", "the", "given", "angle", "counter", "-", "clockwise", ".", "The", "angle", "parameter", "is", "the", "rotation", "angle", "in", "degrees", ".", "The", "bgColor", "parameter", "specifies", "the", "color", "of", "the",...
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/transform.go#L135-L178
24,879
disintegration/imaging
utils.go
parallel
func parallel(start, stop int, fn func(<-chan int)) { count := stop - start if count < 1 { return } procs := runtime.GOMAXPROCS(0) if procs > count { procs = count } c := make(chan int, count) for i := start; i < stop; i++ { c <- i } close(c) var wg sync.WaitGroup for i := 0; i < procs; i++ { wg....
go
func parallel(start, stop int, fn func(<-chan int)) { count := stop - start if count < 1 { return } procs := runtime.GOMAXPROCS(0) if procs > count { procs = count } c := make(chan int, count) for i := start; i < stop; i++ { c <- i } close(c) var wg sync.WaitGroup for i := 0; i < procs; i++ { wg....
[ "func", "parallel", "(", "start", ",", "stop", "int", ",", "fn", "func", "(", "<-", "chan", "int", ")", ")", "{", "count", ":=", "stop", "-", "start", "\n", "if", "count", "<", "1", "{", "return", "\n", "}", "\n\n", "procs", ":=", "runtime", ".",...
// parallel processes the data in separate goroutines.
[ "parallel", "processes", "the", "data", "in", "separate", "goroutines", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/utils.go#L11-L37
24,880
disintegration/imaging
utils.go
clamp
func clamp(x float64) uint8 { v := int64(x + 0.5) if v > 255 { return 255 } if v > 0 { return uint8(v) } return 0 }
go
func clamp(x float64) uint8 { v := int64(x + 0.5) if v > 255 { return 255 } if v > 0 { return uint8(v) } return 0 }
[ "func", "clamp", "(", "x", "float64", ")", "uint8", "{", "v", ":=", "int64", "(", "x", "+", "0.5", ")", "\n", "if", "v", ">", "255", "{", "return", "255", "\n", "}", "\n", "if", "v", ">", "0", "{", "return", "uint8", "(", "v", ")", "\n", "}...
// clamp rounds and clamps float64 value to fit into uint8.
[ "clamp", "rounds", "and", "clamps", "float64", "value", "to", "fit", "into", "uint8", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/utils.go#L48-L57
24,881
disintegration/imaging
utils.go
rgbToHSL
func rgbToHSL(r, g, b uint8) (float64, float64, float64) { rr := float64(r) / 255 gg := float64(g) / 255 bb := float64(b) / 255 max := math.Max(rr, math.Max(gg, bb)) min := math.Min(rr, math.Min(gg, bb)) l := (max + min) / 2 if max == min { return 0, 0, l } var h, s float64 d := max - min if l > 0.5 { ...
go
func rgbToHSL(r, g, b uint8) (float64, float64, float64) { rr := float64(r) / 255 gg := float64(g) / 255 bb := float64(b) / 255 max := math.Max(rr, math.Max(gg, bb)) min := math.Min(rr, math.Min(gg, bb)) l := (max + min) / 2 if max == min { return 0, 0, l } var h, s float64 d := max - min if l > 0.5 { ...
[ "func", "rgbToHSL", "(", "r", ",", "g", ",", "b", "uint8", ")", "(", "float64", ",", "float64", ",", "float64", ")", "{", "rr", ":=", "float64", "(", "r", ")", "/", "255", "\n", "gg", ":=", "float64", "(", "g", ")", "/", "255", "\n", "bb", ":...
// rgbToHSL converts a color from RGB to HSL.
[ "rgbToHSL", "converts", "a", "color", "from", "RGB", "to", "HSL", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/utils.go#L89-L125
24,882
disintegration/imaging
utils.go
hslToRGB
func hslToRGB(h, s, l float64) (uint8, uint8, uint8) { var r, g, b float64 if s == 0 { v := clamp(l * 255) return v, v, v } var q float64 if l < 0.5 { q = l * (1 + s) } else { q = l + s - l*s } p := 2*l - q r = hueToRGB(p, q, h+1/3.0) g = hueToRGB(p, q, h) b = hueToRGB(p, q, h-1/3.0) return clamp...
go
func hslToRGB(h, s, l float64) (uint8, uint8, uint8) { var r, g, b float64 if s == 0 { v := clamp(l * 255) return v, v, v } var q float64 if l < 0.5 { q = l * (1 + s) } else { q = l + s - l*s } p := 2*l - q r = hueToRGB(p, q, h+1/3.0) g = hueToRGB(p, q, h) b = hueToRGB(p, q, h-1/3.0) return clamp...
[ "func", "hslToRGB", "(", "h", ",", "s", ",", "l", "float64", ")", "(", "uint8", ",", "uint8", ",", "uint8", ")", "{", "var", "r", ",", "g", ",", "b", "float64", "\n", "if", "s", "==", "0", "{", "v", ":=", "clamp", "(", "l", "*", "255", ")",...
// hslToRGB converts a color from HSL to RGB.
[ "hslToRGB", "converts", "a", "color", "from", "HSL", "to", "RGB", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/utils.go#L128-L148
24,883
disintegration/imaging
resize.go
resizeNearest
func resizeNearest(img image.Image, width, height int) *image.NRGBA { dst := image.NewNRGBA(image.Rect(0, 0, width, height)) dx := float64(img.Bounds().Dx()) / float64(width) dy := float64(img.Bounds().Dy()) / float64(height) if dx > 1 && dy > 1 { src := newScanner(img) parallel(0, height, func(ys <-chan int) ...
go
func resizeNearest(img image.Image, width, height int) *image.NRGBA { dst := image.NewNRGBA(image.Rect(0, 0, width, height)) dx := float64(img.Bounds().Dx()) / float64(width) dy := float64(img.Bounds().Dy()) / float64(height) if dx > 1 && dy > 1 { src := newScanner(img) parallel(0, height, func(ys <-chan int) ...
[ "func", "resizeNearest", "(", "img", "image", ".", "Image", ",", "width", ",", "height", "int", ")", "*", "image", ".", "NRGBA", "{", "dst", ":=", "image", ".", "NewNRGBA", "(", "image", ".", "Rect", "(", "0", ",", "0", ",", "width", ",", "height",...
// resizeNearest is a fast nearest-neighbor resize, no filtering.
[ "resizeNearest", "is", "a", "fast", "nearest", "-", "neighbor", "resize", "no", "filtering", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/resize.go#L177-L213
24,884
disintegration/imaging
resize.go
cropAndResize
func cropAndResize(img image.Image, width, height int, anchor Anchor, filter ResampleFilter) *image.NRGBA { dstW, dstH := width, height srcBounds := img.Bounds() srcW := srcBounds.Dx() srcH := srcBounds.Dy() srcAspectRatio := float64(srcW) / float64(srcH) dstAspectRatio := float64(dstW) / float64(dstH) var tmp...
go
func cropAndResize(img image.Image, width, height int, anchor Anchor, filter ResampleFilter) *image.NRGBA { dstW, dstH := width, height srcBounds := img.Bounds() srcW := srcBounds.Dx() srcH := srcBounds.Dy() srcAspectRatio := float64(srcW) / float64(srcH) dstAspectRatio := float64(dstW) / float64(dstH) var tmp...
[ "func", "cropAndResize", "(", "img", "image", ".", "Image", ",", "width", ",", "height", "int", ",", "anchor", "Anchor", ",", "filter", "ResampleFilter", ")", "*", "image", ".", "NRGBA", "{", "dstW", ",", "dstH", ":=", "width", ",", "height", "\n\n", "...
// cropAndResize crops the image to the smallest possible size that has the required aspect ratio using // the given anchor point, then scales it to the specified dimensions and returns the transformed image. // // This is generally faster than resizing first, but may result in inaccuracies when used on small source im...
[ "cropAndResize", "crops", "the", "image", "to", "the", "smallest", "possible", "size", "that", "has", "the", "required", "aspect", "ratio", "using", "the", "given", "anchor", "point", "then", "scales", "it", "to", "the", "specified", "dimensions", "and", "retu...
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/resize.go#L292-L311
24,885
disintegration/imaging
resize.go
resizeAndCrop
func resizeAndCrop(img image.Image, width, height int, anchor Anchor, filter ResampleFilter) *image.NRGBA { dstW, dstH := width, height srcBounds := img.Bounds() srcW := srcBounds.Dx() srcH := srcBounds.Dy() srcAspectRatio := float64(srcW) / float64(srcH) dstAspectRatio := float64(dstW) / float64(dstH) var tmp...
go
func resizeAndCrop(img image.Image, width, height int, anchor Anchor, filter ResampleFilter) *image.NRGBA { dstW, dstH := width, height srcBounds := img.Bounds() srcW := srcBounds.Dx() srcH := srcBounds.Dy() srcAspectRatio := float64(srcW) / float64(srcH) dstAspectRatio := float64(dstW) / float64(dstH) var tmp...
[ "func", "resizeAndCrop", "(", "img", "image", ".", "Image", ",", "width", ",", "height", "int", ",", "anchor", "Anchor", ",", "filter", "ResampleFilter", ")", "*", "image", ".", "NRGBA", "{", "dstW", ",", "dstH", ":=", "width", ",", "height", "\n\n", "...
// resizeAndCrop resizes the image to the smallest possible size that will cover the specified dimensions, // crops the resized image to the specified dimensions using the given anchor point and returns // the transformed image.
[ "resizeAndCrop", "resizes", "the", "image", "to", "the", "smallest", "possible", "size", "that", "will", "cover", "the", "specified", "dimensions", "crops", "the", "resized", "image", "to", "the", "specified", "dimensions", "using", "the", "given", "anchor", "po...
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/resize.go#L316-L333
24,886
disintegration/imaging
adjust.go
Grayscale
func Grayscale(img image.Image) *image.NRGBA { src := newScanner(img) dst := image.NewNRGBA(image.Rect(0, 0, src.w, src.h)) parallel(0, src.h, func(ys <-chan int) { for y := range ys { i := y * dst.Stride src.scan(0, y, src.w, y+1, dst.Pix[i:i+src.w*4]) for x := 0; x < src.w; x++ { d := dst.Pix[i : i+...
go
func Grayscale(img image.Image) *image.NRGBA { src := newScanner(img) dst := image.NewNRGBA(image.Rect(0, 0, src.w, src.h)) parallel(0, src.h, func(ys <-chan int) { for y := range ys { i := y * dst.Stride src.scan(0, y, src.w, y+1, dst.Pix[i:i+src.w*4]) for x := 0; x < src.w; x++ { d := dst.Pix[i : i+...
[ "func", "Grayscale", "(", "img", "image", ".", "Image", ")", "*", "image", ".", "NRGBA", "{", "src", ":=", "newScanner", "(", "img", ")", "\n", "dst", ":=", "image", ".", "NewNRGBA", "(", "image", ".", "Rect", "(", "0", ",", "0", ",", "src", ".",...
// Grayscale produces a grayscale version of the image.
[ "Grayscale", "produces", "a", "grayscale", "version", "of", "the", "image", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/adjust.go#L10-L32
24,887
disintegration/imaging
io.go
Decode
func Decode(r io.Reader, opts ...DecodeOption) (image.Image, error) { cfg := defaultDecodeConfig for _, option := range opts { option(&cfg) } if !cfg.autoOrientation { img, _, err := image.Decode(r) return img, err } var orient orientation pr, pw := io.Pipe() r = io.TeeReader(r, pw) done := make(chan s...
go
func Decode(r io.Reader, opts ...DecodeOption) (image.Image, error) { cfg := defaultDecodeConfig for _, option := range opts { option(&cfg) } if !cfg.autoOrientation { img, _, err := image.Decode(r) return img, err } var orient orientation pr, pw := io.Pipe() r = io.TeeReader(r, pw) done := make(chan s...
[ "func", "Decode", "(", "r", "io", ".", "Reader", ",", "opts", "...", "DecodeOption", ")", "(", "image", ".", "Image", ",", "error", ")", "{", "cfg", ":=", "defaultDecodeConfig", "\n", "for", "_", ",", "option", ":=", "range", "opts", "{", "option", "...
// Decode reads an image from r.
[ "Decode", "reads", "an", "image", "from", "r", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/io.go#L54-L83
24,888
disintegration/imaging
io.go
GIFQuantizer
func GIFQuantizer(quantizer draw.Quantizer) EncodeOption { return func(c *encodeConfig) { c.gifQuantizer = quantizer } }
go
func GIFQuantizer(quantizer draw.Quantizer) EncodeOption { return func(c *encodeConfig) { c.gifQuantizer = quantizer } }
[ "func", "GIFQuantizer", "(", "quantizer", "draw", ".", "Quantizer", ")", "EncodeOption", "{", "return", "func", "(", "c", "*", "encodeConfig", ")", "{", "c", ".", "gifQuantizer", "=", "quantizer", "\n", "}", "\n", "}" ]
// GIFQuantizer returns an EncodeOption that sets the quantizer that is used to produce // a palette of the GIF-encoded image.
[ "GIFQuantizer", "returns", "an", "EncodeOption", "that", "sets", "the", "quantizer", "that", "is", "used", "to", "produce", "a", "palette", "of", "the", "GIF", "-", "encoded", "image", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/io.go#L194-L198
24,889
disintegration/imaging
io.go
GIFDrawer
func GIFDrawer(drawer draw.Drawer) EncodeOption { return func(c *encodeConfig) { c.gifDrawer = drawer } }
go
func GIFDrawer(drawer draw.Drawer) EncodeOption { return func(c *encodeConfig) { c.gifDrawer = drawer } }
[ "func", "GIFDrawer", "(", "drawer", "draw", ".", "Drawer", ")", "EncodeOption", "{", "return", "func", "(", "c", "*", "encodeConfig", ")", "{", "c", ".", "gifDrawer", "=", "drawer", "\n", "}", "\n", "}" ]
// GIFDrawer returns an EncodeOption that sets the drawer that is used to convert // the source image to the desired palette of the GIF-encoded image.
[ "GIFDrawer", "returns", "an", "EncodeOption", "that", "sets", "the", "drawer", "that", "is", "used", "to", "convert", "the", "source", "image", "to", "the", "desired", "palette", "of", "the", "GIF", "-", "encoded", "image", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/io.go#L202-L206
24,890
disintegration/imaging
io.go
PNGCompressionLevel
func PNGCompressionLevel(level png.CompressionLevel) EncodeOption { return func(c *encodeConfig) { c.pngCompressionLevel = level } }
go
func PNGCompressionLevel(level png.CompressionLevel) EncodeOption { return func(c *encodeConfig) { c.pngCompressionLevel = level } }
[ "func", "PNGCompressionLevel", "(", "level", "png", ".", "CompressionLevel", ")", "EncodeOption", "{", "return", "func", "(", "c", "*", "encodeConfig", ")", "{", "c", ".", "pngCompressionLevel", "=", "level", "\n", "}", "\n", "}" ]
// PNGCompressionLevel returns an EncodeOption that sets the compression level // of the PNG-encoded image. Default is png.DefaultCompression.
[ "PNGCompressionLevel", "returns", "an", "EncodeOption", "that", "sets", "the", "compression", "level", "of", "the", "PNG", "-", "encoded", "image", ".", "Default", "is", "png", ".", "DefaultCompression", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/io.go#L210-L214
24,891
disintegration/imaging
io.go
fixOrientation
func fixOrientation(img image.Image, o orientation) image.Image { switch o { case orientationNormal: case orientationFlipH: img = FlipH(img) case orientationFlipV: img = FlipV(img) case orientationRotate90: img = Rotate90(img) case orientationRotate180: img = Rotate180(img) case orientationRotate270: i...
go
func fixOrientation(img image.Image, o orientation) image.Image { switch o { case orientationNormal: case orientationFlipH: img = FlipH(img) case orientationFlipV: img = FlipV(img) case orientationRotate90: img = Rotate90(img) case orientationRotate180: img = Rotate180(img) case orientationRotate270: i...
[ "func", "fixOrientation", "(", "img", "image", ".", "Image", ",", "o", "orientation", ")", "image", ".", "Image", "{", "switch", "o", "{", "case", "orientationNormal", ":", "case", "orientationFlipH", ":", "img", "=", "FlipH", "(", "img", ")", "\n", "cas...
// fixOrientation applies a transform to img corresponding to the given orientation flag.
[ "fixOrientation", "applies", "a", "transform", "to", "img", "corresponding", "to", "the", "given", "orientation", "flag", "." ]
061e8a750a4db9667cdf9e2af7f4029ba506cb3b
https://github.com/disintegration/imaging/blob/061e8a750a4db9667cdf9e2af7f4029ba506cb3b/io.go#L425-L444
24,892
rqlite/rqlite
tcp/transport.go
NewTLSTransport
func NewTLSTransport(certFile, keyPath string, skipVerify bool) *Transport { return &Transport{ certFile: certFile, certKey: keyPath, remoteEncrypted: true, skipVerify: skipVerify, } }
go
func NewTLSTransport(certFile, keyPath string, skipVerify bool) *Transport { return &Transport{ certFile: certFile, certKey: keyPath, remoteEncrypted: true, skipVerify: skipVerify, } }
[ "func", "NewTLSTransport", "(", "certFile", ",", "keyPath", "string", ",", "skipVerify", "bool", ")", "*", "Transport", "{", "return", "&", "Transport", "{", "certFile", ":", "certFile", ",", "certKey", ":", "keyPath", ",", "remoteEncrypted", ":", "true", ",...
// NewTLSTransport returns an initialized TLS-ecrypted Transport.
[ "NewTLSTransport", "returns", "an", "initialized", "TLS", "-", "ecrypted", "Transport", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/tcp/transport.go#L26-L33
24,893
rqlite/rqlite
tcp/transport.go
Open
func (t *Transport) Open(addr string) error { ln, err := net.Listen("tcp", addr) if err != nil { return err } if t.certFile != "" { config, err := createTLSConfig(t.certFile, t.certKey) if err != nil { return err } ln = tls.NewListener(ln, config) } t.ln = ln return nil }
go
func (t *Transport) Open(addr string) error { ln, err := net.Listen("tcp", addr) if err != nil { return err } if t.certFile != "" { config, err := createTLSConfig(t.certFile, t.certKey) if err != nil { return err } ln = tls.NewListener(ln, config) } t.ln = ln return nil }
[ "func", "(", "t", "*", "Transport", ")", "Open", "(", "addr", "string", ")", "error", "{", "ln", ",", "err", ":=", "net", ".", "Listen", "(", "\"", "\"", ",", "addr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", ...
// Open opens the transport, binding to the supplied address.
[ "Open", "opens", "the", "transport", "binding", "to", "the", "supplied", "address", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/tcp/transport.go#L36-L51
24,894
rqlite/rqlite
tcp/transport.go
Dial
func (t *Transport) Dial(addr string, timeout time.Duration) (net.Conn, error) { dialer := &net.Dialer{Timeout: timeout} var err error var conn net.Conn if t.remoteEncrypted { conf := &tls.Config{ InsecureSkipVerify: t.skipVerify, } fmt.Println("doing a TLS dial") conn, err = tls.DialWithDialer(dialer, ...
go
func (t *Transport) Dial(addr string, timeout time.Duration) (net.Conn, error) { dialer := &net.Dialer{Timeout: timeout} var err error var conn net.Conn if t.remoteEncrypted { conf := &tls.Config{ InsecureSkipVerify: t.skipVerify, } fmt.Println("doing a TLS dial") conn, err = tls.DialWithDialer(dialer, ...
[ "func", "(", "t", "*", "Transport", ")", "Dial", "(", "addr", "string", ",", "timeout", "time", ".", "Duration", ")", "(", "net", ".", "Conn", ",", "error", ")", "{", "dialer", ":=", "&", "net", ".", "Dialer", "{", "Timeout", ":", "timeout", "}", ...
// Dial opens a network connection.
[ "Dial", "opens", "a", "network", "connection", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/tcp/transport.go#L54-L70
24,895
rqlite/rqlite
cmd/rqbench/http.go
Prepare
func (h *HTTPTester) Prepare(stmt string, bSz int, tx bool) error { s := make([]string, bSz) for i := 0; i < len(s); i++ { s[i] = stmt } b, err := json.Marshal(s) if err != nil { return err } h.br = bytes.NewReader(b) if tx { h.url = h.url + "?transaction" } return nil }
go
func (h *HTTPTester) Prepare(stmt string, bSz int, tx bool) error { s := make([]string, bSz) for i := 0; i < len(s); i++ { s[i] = stmt } b, err := json.Marshal(s) if err != nil { return err } h.br = bytes.NewReader(b) if tx { h.url = h.url + "?transaction" } return nil }
[ "func", "(", "h", "*", "HTTPTester", ")", "Prepare", "(", "stmt", "string", ",", "bSz", "int", ",", "tx", "bool", ")", "error", "{", "s", ":=", "make", "(", "[", "]", "string", ",", "bSz", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "len...
// Prepare prepares the tester for execution.
[ "Prepare", "prepares", "the", "tester", "for", "execution", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/cmd/rqbench/http.go#L28-L45
24,896
rqlite/rqlite
cmd/rqbench/http.go
Once
func (h *HTTPTester) Once() (time.Duration, error) { h.br.Seek(0, io.SeekStart) start := time.Now() resp, err := h.client.Post(h.url, "application/json", h.br) if err != nil { return 0, err } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return 0, fmt.Errorf("received %s", resp.Status) } ...
go
func (h *HTTPTester) Once() (time.Duration, error) { h.br.Seek(0, io.SeekStart) start := time.Now() resp, err := h.client.Post(h.url, "application/json", h.br) if err != nil { return 0, err } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { return 0, fmt.Errorf("received %s", resp.Status) } ...
[ "func", "(", "h", "*", "HTTPTester", ")", "Once", "(", ")", "(", "time", ".", "Duration", ",", "error", ")", "{", "h", ".", "br", ".", "Seek", "(", "0", ",", "io", ".", "SeekStart", ")", "\n\n", "start", ":=", "time", ".", "Now", "(", ")", "\...
// Once executes a single test request.
[ "Once", "executes", "a", "single", "test", "request", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/cmd/rqbench/http.go#L48-L64
24,897
rqlite/rqlite
store/peers.go
NumPeers
func NumPeers(raftDir string) (int, error) { // Read the file buf, err := ioutil.ReadFile(filepath.Join(raftDir, jsonPeerPath)) if err != nil && !os.IsNotExist(err) { return 0, err } // Check for no peers if len(buf) == 0 { return 0, nil } // Decode the peers var peerSet []string dec := json.NewDecoder(...
go
func NumPeers(raftDir string) (int, error) { // Read the file buf, err := ioutil.ReadFile(filepath.Join(raftDir, jsonPeerPath)) if err != nil && !os.IsNotExist(err) { return 0, err } // Check for no peers if len(buf) == 0 { return 0, nil } // Decode the peers var peerSet []string dec := json.NewDecoder(...
[ "func", "NumPeers", "(", "raftDir", "string", ")", "(", "int", ",", "error", ")", "{", "// Read the file", "buf", ",", "err", ":=", "ioutil", ".", "ReadFile", "(", "filepath", ".", "Join", "(", "raftDir", ",", "jsonPeerPath", ")", ")", "\n", "if", "err...
// NumPeers returns the number of peers indicated by the config files // within raftDir. // // This code makes assumptions about how the Raft module works.
[ "NumPeers", "returns", "the", "number", "of", "peers", "indicated", "by", "the", "config", "files", "within", "raftDir", ".", "This", "code", "makes", "assumptions", "about", "how", "the", "Raft", "module", "works", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/peers.go#L19-L39
24,898
rqlite/rqlite
store/peers.go
JoinAllowed
func JoinAllowed(raftDir string) (bool, error) { n, err := NumPeers(raftDir) if err != nil { return false, err } return n <= 1, nil }
go
func JoinAllowed(raftDir string) (bool, error) { n, err := NumPeers(raftDir) if err != nil { return false, err } return n <= 1, nil }
[ "func", "JoinAllowed", "(", "raftDir", "string", ")", "(", "bool", ",", "error", ")", "{", "n", ",", "err", ":=", "NumPeers", "(", "raftDir", ")", "\n", "if", "err", "!=", "nil", "{", "return", "false", ",", "err", "\n", "}", "\n", "return", "n", ...
// JoinAllowed returns whether the config files within raftDir indicate // that the node can join a cluster.
[ "JoinAllowed", "returns", "whether", "the", "config", "files", "within", "raftDir", "indicate", "that", "the", "node", "can", "join", "a", "cluster", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/peers.go#L43-L49
24,899
rqlite/rqlite
store/store.go
New
func New(ln Listener, c *StoreConfig) *Store { logger := c.Logger if logger == nil { logger = log.New(os.Stderr, "[store] ", log.LstdFlags) } return &Store{ ln: ln, raftDir: c.Dir, raftID: c.ID, dbConf: c.DBConf, dbPath: filepath.Join(c.Dir, sqliteFile), ran...
go
func New(ln Listener, c *StoreConfig) *Store { logger := c.Logger if logger == nil { logger = log.New(os.Stderr, "[store] ", log.LstdFlags) } return &Store{ ln: ln, raftDir: c.Dir, raftID: c.ID, dbConf: c.DBConf, dbPath: filepath.Join(c.Dir, sqliteFile), ran...
[ "func", "New", "(", "ln", "Listener", ",", "c", "*", "StoreConfig", ")", "*", "Store", "{", "logger", ":=", "c", ".", "Logger", "\n", "if", "logger", "==", "nil", "{", "logger", "=", "log", ".", "New", "(", "os", ".", "Stderr", ",", "\"", "\"", ...
// New returns a new Store.
[ "New", "returns", "a", "new", "Store", "." ]
12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3
https://github.com/rqlite/rqlite/blob/12a954c7ef29a9060870c0b5c6c4d8a9e8c35ce3/store/store.go#L220-L240