id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
22,500
NaySoftware/go-fcm
instanceid.go
generateBatchResponse
func generateBatchResponse(resp []byte) (*BatchResponse, error) { result := new(BatchResponse) if err := json.Unmarshal(resp, &result); err != nil { return nil, err } return result, nil }
go
func generateBatchResponse(resp []byte) (*BatchResponse, error) { result := new(BatchResponse) if err := json.Unmarshal(resp, &result); err != nil { return nil, err } return result, nil }
[ "func", "generateBatchResponse", "(", "resp", "[", "]", "byte", ")", "(", "*", "BatchResponse", ",", "error", ")", "{", "result", ":=", "new", "(", "BatchResponse", ")", "\n\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", "resul...
// generateBatchResponse converts a byte response to BatchResponse
[ "generateBatchResponse", "converts", "a", "byte", "response", "to", "BatchResponse" ]
28fff9381d17f35619309c7a5ada41d26030d976
https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L367-L376
22,501
NaySoftware/go-fcm
instanceid.go
ApnsBatchImportRequest
func (this *FcmClient) ApnsBatchImportRequest(apnsReq *ApnsBatchRequest) (*ApnsBatchResponse, error) { jsonByte, err := apnsReq.ToByte() if err != nil { return nil, err } request, err := http.NewRequest("POST", apns_batch_import_srv_url, bytes.NewBuffer(jsonByte)) request.Header.Set("Authorization", this.apiKe...
go
func (this *FcmClient) ApnsBatchImportRequest(apnsReq *ApnsBatchRequest) (*ApnsBatchResponse, error) { jsonByte, err := apnsReq.ToByte() if err != nil { return nil, err } request, err := http.NewRequest("POST", apns_batch_import_srv_url, bytes.NewBuffer(jsonByte)) request.Header.Set("Authorization", this.apiKe...
[ "func", "(", "this", "*", "FcmClient", ")", "ApnsBatchImportRequest", "(", "apnsReq", "*", "ApnsBatchRequest", ")", "(", "*", "ApnsBatchResponse", ",", "error", ")", "{", "jsonByte", ",", "err", ":=", "apnsReq", ".", "ToByte", "(", ")", "\n", "if", "err", ...
// ApnsBatchImportRequest apns import requst
[ "ApnsBatchImportRequest", "apns", "import", "requst" ]
28fff9381d17f35619309c7a5ada41d26030d976
https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L379-L420
22,502
NaySoftware/go-fcm
instanceid.go
ToByte
func (this *ApnsBatchRequest) ToByte() ([]byte, error) { data, err := json.Marshal(this) if err != nil { return nil, err } return data, nil }
go
func (this *ApnsBatchRequest) ToByte() ([]byte, error) { data, err := json.Marshal(this) if err != nil { return nil, err } return data, nil }
[ "func", "(", "this", "*", "ApnsBatchRequest", ")", "ToByte", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "data", ",", "err", ":=", "json", ".", "Marshal", "(", "this", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", ...
// ToByte converts ApnsBatchRequest to a byte
[ "ToByte", "converts", "ApnsBatchRequest", "to", "a", "byte" ]
28fff9381d17f35619309c7a5ada41d26030d976
https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L423-L430
22,503
NaySoftware/go-fcm
instanceid.go
parseApnsBatchResponse
func parseApnsBatchResponse(resp []byte) (*ApnsBatchResponse, error) { result := new(ApnsBatchResponse) if err := json.Unmarshal(resp, &result); err != nil { return nil, err } return result, nil }
go
func parseApnsBatchResponse(resp []byte) (*ApnsBatchResponse, error) { result := new(ApnsBatchResponse) if err := json.Unmarshal(resp, &result); err != nil { return nil, err } return result, nil }
[ "func", "parseApnsBatchResponse", "(", "resp", "[", "]", "byte", ")", "(", "*", "ApnsBatchResponse", ",", "error", ")", "{", "result", ":=", "new", "(", "ApnsBatchResponse", ")", "\n", "if", "err", ":=", "json", ".", "Unmarshal", "(", "resp", ",", "&", ...
// parseApnsBatchResponse converts apns byte response to ApnsBatchResponse
[ "parseApnsBatchResponse", "converts", "apns", "byte", "response", "to", "ApnsBatchResponse" ]
28fff9381d17f35619309c7a5ada41d26030d976
https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L433-L442
22,504
NaySoftware/go-fcm
instanceid.go
PrintResults
func (this *ApnsBatchResponse) PrintResults() { fmt.Println("Status : ", this.Status) fmt.Println("StatusCode : ", this.StatusCode) fmt.Println("Error : ", this.Error) for i, val := range this.Results { fmt.Println(i, ":") fmt.Println("\tAPNS Token", val[apns_token_key]) fmt.Println("\tStatus ", v...
go
func (this *ApnsBatchResponse) PrintResults() { fmt.Println("Status : ", this.Status) fmt.Println("StatusCode : ", this.StatusCode) fmt.Println("Error : ", this.Error) for i, val := range this.Results { fmt.Println(i, ":") fmt.Println("\tAPNS Token", val[apns_token_key]) fmt.Println("\tStatus ", v...
[ "func", "(", "this", "*", "ApnsBatchResponse", ")", "PrintResults", "(", ")", "{", "fmt", ".", "Println", "(", "\"", "\"", ",", "this", ".", "Status", ")", "\n", "fmt", ".", "Println", "(", "\"", "\"", ",", "this", ".", "StatusCode", ")", "\n", "fm...
// PrintResults prints ApnsBatchResponse, for faster debugging
[ "PrintResults", "prints", "ApnsBatchResponse", "for", "faster", "debugging" ]
28fff9381d17f35619309c7a5ada41d26030d976
https://github.com/NaySoftware/go-fcm/blob/28fff9381d17f35619309c7a5ada41d26030d976/instanceid.go#L445-L455
22,505
kavu/go_reuseport
reuseport.go
Listen
func Listen(proto, addr string) (l net.Listener, err error) { return NewReusablePortListener(proto, addr) }
go
func Listen(proto, addr string) (l net.Listener, err error) { return NewReusablePortListener(proto, addr) }
[ "func", "Listen", "(", "proto", ",", "addr", "string", ")", "(", "l", "net", ".", "Listener", ",", "err", "error", ")", "{", "return", "NewReusablePortListener", "(", "proto", ",", "addr", ")", "\n", "}" ]
// Listen function is an alias for NewReusablePortListener.
[ "Listen", "function", "is", "an", "alias", "for", "NewReusablePortListener", "." ]
1f6171f327ed3893406d2a802c563390993c4bb5
https://github.com/kavu/go_reuseport/blob/1f6171f327ed3893406d2a802c563390993c4bb5/reuseport.go#L43-L45
22,506
kavu/go_reuseport
reuseport.go
ListenPacket
func ListenPacket(proto, addr string) (l net.PacketConn, err error) { return NewReusablePortPacketConn(proto, addr) }
go
func ListenPacket(proto, addr string) (l net.PacketConn, err error) { return NewReusablePortPacketConn(proto, addr) }
[ "func", "ListenPacket", "(", "proto", ",", "addr", "string", ")", "(", "l", "net", ".", "PacketConn", ",", "err", "error", ")", "{", "return", "NewReusablePortPacketConn", "(", "proto", ",", "addr", ")", "\n", "}" ]
// ListenPacket is an alias for NewReusablePortPacketConn.
[ "ListenPacket", "is", "an", "alias", "for", "NewReusablePortPacketConn", "." ]
1f6171f327ed3893406d2a802c563390993c4bb5
https://github.com/kavu/go_reuseport/blob/1f6171f327ed3893406d2a802c563390993c4bb5/reuseport.go#L48-L50
22,507
kavu/go_reuseport
udp.go
NewReusablePortPacketConn
func NewReusablePortPacketConn(proto, addr string) (l net.PacketConn, err error) { var ( soType, fd int file *os.File sockaddr syscall.Sockaddr ) if sockaddr, soType, err = getSockaddr(proto, addr); err != nil { return nil, err } syscall.ForkLock.RLock() fd, err = syscall.Socket(soType, syscall....
go
func NewReusablePortPacketConn(proto, addr string) (l net.PacketConn, err error) { var ( soType, fd int file *os.File sockaddr syscall.Sockaddr ) if sockaddr, soType, err = getSockaddr(proto, addr); err != nil { return nil, err } syscall.ForkLock.RLock() fd, err = syscall.Socket(soType, syscall....
[ "func", "NewReusablePortPacketConn", "(", "proto", ",", "addr", "string", ")", "(", "l", "net", ".", "PacketConn", ",", "err", "error", ")", "{", "var", "(", "soType", ",", "fd", "int", "\n", "file", "*", "os", ".", "File", "\n", "sockaddr", "syscall",...
// NewReusablePortPacketConn returns net.FilePacketConn that created from // a file discriptor for a socket with SO_REUSEPORT option.
[ "NewReusablePortPacketConn", "returns", "net", ".", "FilePacketConn", "that", "created", "from", "a", "file", "discriptor", "for", "a", "socket", "with", "SO_REUSEPORT", "option", "." ]
1f6171f327ed3893406d2a802c563390993c4bb5
https://github.com/kavu/go_reuseport/blob/1f6171f327ed3893406d2a802c563390993c4bb5/udp.go#L93-L147
22,508
kavu/go_reuseport
tcp.go
NewReusablePortListener
func NewReusablePortListener(proto, addr string) (l net.Listener, err error) { var ( soType, fd int file *os.File sockaddr syscall.Sockaddr ) if sockaddr, soType, err = getSockaddr(proto, addr); err != nil { return nil, err } syscall.ForkLock.RLock() if fd, err = syscall.Socket(soType, syscall.S...
go
func NewReusablePortListener(proto, addr string) (l net.Listener, err error) { var ( soType, fd int file *os.File sockaddr syscall.Sockaddr ) if sockaddr, soType, err = getSockaddr(proto, addr); err != nil { return nil, err } syscall.ForkLock.RLock() if fd, err = syscall.Socket(soType, syscall.S...
[ "func", "NewReusablePortListener", "(", "proto", ",", "addr", "string", ")", "(", "l", "net", ".", "Listener", ",", "err", "error", ")", "{", "var", "(", "soType", ",", "fd", "int", "\n", "file", "*", "os", ".", "File", "\n", "sockaddr", "syscall", "...
// NewReusablePortListener returns net.FileListener that created from // a file discriptor for a socket with SO_REUSEPORT option.
[ "NewReusablePortListener", "returns", "net", ".", "FileListener", "that", "created", "from", "a", "file", "discriptor", "for", "a", "socket", "with", "SO_REUSEPORT", "option", "." ]
1f6171f327ed3893406d2a802c563390993c4bb5
https://github.com/kavu/go_reuseport/blob/1f6171f327ed3893406d2a802c563390993c4bb5/tcp.go#L96-L147
22,509
sohlich/elogrus
hook.go
Fire
func (hook *ElasticHook) Fire(entry *logrus.Entry) error { return hook.fireFunc(entry, hook, hook.index()) }
go
func (hook *ElasticHook) Fire(entry *logrus.Entry) error { return hook.fireFunc(entry, hook, hook.index()) }
[ "func", "(", "hook", "*", "ElasticHook", ")", "Fire", "(", "entry", "*", "logrus", ".", "Entry", ")", "error", "{", "return", "hook", ".", "fireFunc", "(", "entry", ",", "hook", ",", "hook", ".", "index", "(", ")", ")", "\n", "}" ]
// Fire is required to implement // Logrus hook
[ "Fire", "is", "required", "to", "implement", "Logrus", "hook" ]
1fa29e2f2009c129693c7079e5f6361bfbd34080
https://github.com/sohlich/elogrus/blob/1fa29e2f2009c129693c7079e5f6361bfbd34080/hook.go#L125-L127
22,510
adrianmo/go-nmea
parser.go
AssertType
func (p *parser) AssertType(typ string) { if p.Type != typ { p.SetErr("type", p.Type) } }
go
func (p *parser) AssertType(typ string) { if p.Type != typ { p.SetErr("type", p.Type) } }
[ "func", "(", "p", "*", "parser", ")", "AssertType", "(", "typ", "string", ")", "{", "if", "p", ".", "Type", "!=", "typ", "{", "p", ".", "SetErr", "(", "\"", "\"", ",", "p", ".", "Type", ")", "\n", "}", "\n", "}" ]
// AssertType makes sure the sentence's type matches the provided one.
[ "AssertType", "makes", "sure", "the", "sentence", "s", "type", "matches", "the", "provided", "one", "." ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L21-L25
22,511
adrianmo/go-nmea
parser.go
SetErr
func (p *parser) SetErr(context, value string) { if p.err == nil { p.err = fmt.Errorf("nmea: %s invalid %s: %s", p.Prefix(), context, value) } }
go
func (p *parser) SetErr(context, value string) { if p.err == nil { p.err = fmt.Errorf("nmea: %s invalid %s: %s", p.Prefix(), context, value) } }
[ "func", "(", "p", "*", "parser", ")", "SetErr", "(", "context", ",", "value", "string", ")", "{", "if", "p", ".", "err", "==", "nil", "{", "p", ".", "err", "=", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "p", ".", "Prefix", "(", ")", ",", ...
// SetErr assigns an error. Calling this method has no // effect if there is already an error.
[ "SetErr", "assigns", "an", "error", ".", "Calling", "this", "method", "has", "no", "effect", "if", "there", "is", "already", "an", "error", "." ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L34-L38
22,512
adrianmo/go-nmea
parser.go
String
func (p *parser) String(i int, context string) string { if p.err != nil { return "" } if i < 0 || i >= len(p.Fields) { p.SetErr(context, "index out of range") return "" } return p.Fields[i] }
go
func (p *parser) String(i int, context string) string { if p.err != nil { return "" } if i < 0 || i >= len(p.Fields) { p.SetErr(context, "index out of range") return "" } return p.Fields[i] }
[ "func", "(", "p", "*", "parser", ")", "String", "(", "i", "int", ",", "context", "string", ")", "string", "{", "if", "p", ".", "err", "!=", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "if", "i", "<", "0", "||", "i", ">=", "len", "(", ...
// String returns the field value at the specified index.
[ "String", "returns", "the", "field", "value", "at", "the", "specified", "index", "." ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L41-L50
22,513
adrianmo/go-nmea
parser.go
EnumString
func (p *parser) EnumString(i int, context string, options ...string) string { s := p.String(i, context) if p.err != nil || s == "" { return "" } for _, o := range options { if o == s { return s } } p.SetErr(context, s) return "" }
go
func (p *parser) EnumString(i int, context string, options ...string) string { s := p.String(i, context) if p.err != nil || s == "" { return "" } for _, o := range options { if o == s { return s } } p.SetErr(context, s) return "" }
[ "func", "(", "p", "*", "parser", ")", "EnumString", "(", "i", "int", ",", "context", "string", ",", "options", "...", "string", ")", "string", "{", "s", ":=", "p", ".", "String", "(", "i", ",", "context", ")", "\n", "if", "p", ".", "err", "!=", ...
// EnumString returns the field value at the specified index. // An error occurs if the value is not one of the options and not empty.
[ "EnumString", "returns", "the", "field", "value", "at", "the", "specified", "index", ".", "An", "error", "occurs", "if", "the", "value", "is", "not", "one", "of", "the", "options", "and", "not", "empty", "." ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L54-L66
22,514
adrianmo/go-nmea
parser.go
EnumChars
func (p *parser) EnumChars(i int, context string, options ...string) []string { s := p.String(i, context) if p.err != nil || s == "" { return []string{} } strs := []string{} for _, r := range s { rs := string(r) for _, o := range options { if o == rs { strs = append(strs, o) break } } } if ...
go
func (p *parser) EnumChars(i int, context string, options ...string) []string { s := p.String(i, context) if p.err != nil || s == "" { return []string{} } strs := []string{} for _, r := range s { rs := string(r) for _, o := range options { if o == rs { strs = append(strs, o) break } } } if ...
[ "func", "(", "p", "*", "parser", ")", "EnumChars", "(", "i", "int", ",", "context", "string", ",", "options", "...", "string", ")", "[", "]", "string", "{", "s", ":=", "p", ".", "String", "(", "i", ",", "context", ")", "\n", "if", "p", ".", "er...
// EnumChars returns an array of strings that are matched in the Mode field. // It will only match the number of characters that are in the Mode field. // If the value is empty, it will return an empty array
[ "EnumChars", "returns", "an", "array", "of", "strings", "that", "are", "matched", "in", "the", "Mode", "field", ".", "It", "will", "only", "match", "the", "number", "of", "characters", "that", "are", "in", "the", "Mode", "field", ".", "If", "the", "value...
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L71-L92
22,515
adrianmo/go-nmea
parser.go
Int64
func (p *parser) Int64(i int, context string) int64 { s := p.String(i, context) if p.err != nil { return 0 } if s == "" { return 0 } v, err := strconv.ParseInt(s, 10, 64) if err != nil { p.SetErr(context, s) } return v }
go
func (p *parser) Int64(i int, context string) int64 { s := p.String(i, context) if p.err != nil { return 0 } if s == "" { return 0 } v, err := strconv.ParseInt(s, 10, 64) if err != nil { p.SetErr(context, s) } return v }
[ "func", "(", "p", "*", "parser", ")", "Int64", "(", "i", "int", ",", "context", "string", ")", "int64", "{", "s", ":=", "p", ".", "String", "(", "i", ",", "context", ")", "\n", "if", "p", ".", "err", "!=", "nil", "{", "return", "0", "\n", "}"...
// Int64 returns the int64 value at the specified index. // If the value is an empty string, 0 is returned.
[ "Int64", "returns", "the", "int64", "value", "at", "the", "specified", "index", ".", "If", "the", "value", "is", "an", "empty", "string", "0", "is", "returned", "." ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L96-L109
22,516
adrianmo/go-nmea
parser.go
Float64
func (p *parser) Float64(i int, context string) float64 { s := p.String(i, context) if p.err != nil { return 0 } if s == "" { return 0 } v, err := strconv.ParseFloat(s, 64) if err != nil { p.SetErr(context, s) } return v }
go
func (p *parser) Float64(i int, context string) float64 { s := p.String(i, context) if p.err != nil { return 0 } if s == "" { return 0 } v, err := strconv.ParseFloat(s, 64) if err != nil { p.SetErr(context, s) } return v }
[ "func", "(", "p", "*", "parser", ")", "Float64", "(", "i", "int", ",", "context", "string", ")", "float64", "{", "s", ":=", "p", ".", "String", "(", "i", ",", "context", ")", "\n", "if", "p", ".", "err", "!=", "nil", "{", "return", "0", "\n", ...
// Float64 returns the float64 value at the specified index. // If the value is an empty string, 0 is returned.
[ "Float64", "returns", "the", "float64", "value", "at", "the", "specified", "index", ".", "If", "the", "value", "is", "an", "empty", "string", "0", "is", "returned", "." ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L113-L126
22,517
adrianmo/go-nmea
parser.go
Time
func (p *parser) Time(i int, context string) Time { s := p.String(i, context) if p.err != nil { return Time{} } v, err := ParseTime(s) if err != nil { p.SetErr(context, s) } return v }
go
func (p *parser) Time(i int, context string) Time { s := p.String(i, context) if p.err != nil { return Time{} } v, err := ParseTime(s) if err != nil { p.SetErr(context, s) } return v }
[ "func", "(", "p", "*", "parser", ")", "Time", "(", "i", "int", ",", "context", "string", ")", "Time", "{", "s", ":=", "p", ".", "String", "(", "i", ",", "context", ")", "\n", "if", "p", ".", "err", "!=", "nil", "{", "return", "Time", "{", "}"...
// Time returns the Time value at the specified index. // If the value is empty, the Time is marked as invalid.
[ "Time", "returns", "the", "Time", "value", "at", "the", "specified", "index", ".", "If", "the", "value", "is", "empty", "the", "Time", "is", "marked", "as", "invalid", "." ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L130-L140
22,518
adrianmo/go-nmea
parser.go
Date
func (p *parser) Date(i int, context string) Date { s := p.String(i, context) if p.err != nil { return Date{} } v, err := ParseDate(s) if err != nil { p.SetErr(context, s) } return v }
go
func (p *parser) Date(i int, context string) Date { s := p.String(i, context) if p.err != nil { return Date{} } v, err := ParseDate(s) if err != nil { p.SetErr(context, s) } return v }
[ "func", "(", "p", "*", "parser", ")", "Date", "(", "i", "int", ",", "context", "string", ")", "Date", "{", "s", ":=", "p", ".", "String", "(", "i", ",", "context", ")", "\n", "if", "p", ".", "err", "!=", "nil", "{", "return", "Date", "{", "}"...
// Date returns the Date value at the specified index. // If the value is empty, the Date is marked as invalid.
[ "Date", "returns", "the", "Date", "value", "at", "the", "specified", "index", ".", "If", "the", "value", "is", "empty", "the", "Date", "is", "marked", "as", "invalid", "." ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L144-L154
22,519
adrianmo/go-nmea
parser.go
LatLong
func (p *parser) LatLong(i, j int, context string) float64 { a := p.String(i, context) b := p.String(j, context) if p.err != nil { return 0 } s := fmt.Sprintf("%s %s", a, b) v, err := ParseLatLong(s) if err != nil { p.SetErr(context, err.Error()) } return v }
go
func (p *parser) LatLong(i, j int, context string) float64 { a := p.String(i, context) b := p.String(j, context) if p.err != nil { return 0 } s := fmt.Sprintf("%s %s", a, b) v, err := ParseLatLong(s) if err != nil { p.SetErr(context, err.Error()) } return v }
[ "func", "(", "p", "*", "parser", ")", "LatLong", "(", "i", ",", "j", "int", ",", "context", "string", ")", "float64", "{", "a", ":=", "p", ".", "String", "(", "i", ",", "context", ")", "\n", "b", ":=", "p", ".", "String", "(", "j", ",", "cont...
// LatLong returns the coordinate value of the specified fields.
[ "LatLong", "returns", "the", "coordinate", "value", "of", "the", "specified", "fields", "." ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L157-L169
22,520
adrianmo/go-nmea
parser.go
SixBitASCIIArmour
func (p *parser) SixBitASCIIArmour(i int, fillBits int, context string) []byte { if p.err != nil { return nil } if fillBits < 0 || fillBits >= 6 { p.SetErr(context, "fill bits") return nil } payload := []byte(p.String(i, "encoded payload")) numBits := len(payload)*6 - fillBits if numBits < 0 { p.SetErr...
go
func (p *parser) SixBitASCIIArmour(i int, fillBits int, context string) []byte { if p.err != nil { return nil } if fillBits < 0 || fillBits >= 6 { p.SetErr(context, "fill bits") return nil } payload := []byte(p.String(i, "encoded payload")) numBits := len(payload)*6 - fillBits if numBits < 0 { p.SetErr...
[ "func", "(", "p", "*", "parser", ")", "SixBitASCIIArmour", "(", "i", "int", ",", "fillBits", "int", ",", "context", "string", ")", "[", "]", "byte", "{", "if", "p", ".", "err", "!=", "nil", "{", "return", "nil", "\n", "}", "\n", "if", "fillBits", ...
// SixBitASCIIArmour decodes the 6-bit ascii armor used for VDM and VDO messages
[ "SixBitASCIIArmour", "decodes", "the", "6", "-", "bit", "ascii", "armor", "used", "for", "VDM", "and", "VDO", "messages" ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/parser.go#L172-L210
22,521
adrianmo/go-nmea
gsa.go
newGSA
func newGSA(s BaseSentence) (GSA, error) { p := newParser(s) p.AssertType(TypeGSA) m := GSA{ BaseSentence: s, Mode: p.EnumString(0, "selection mode", Auto, Manual), FixType: p.EnumString(1, "fix type", FixNone, Fix2D, Fix3D), } // Satellites in view. for i := 2; i < 14; i++ { if v := p.String...
go
func newGSA(s BaseSentence) (GSA, error) { p := newParser(s) p.AssertType(TypeGSA) m := GSA{ BaseSentence: s, Mode: p.EnumString(0, "selection mode", Auto, Manual), FixType: p.EnumString(1, "fix type", FixNone, Fix2D, Fix3D), } // Satellites in view. for i := 2; i < 14; i++ { if v := p.String...
[ "func", "newGSA", "(", "s", "BaseSentence", ")", "(", "GSA", ",", "error", ")", "{", "p", ":=", "newParser", "(", "s", ")", "\n", "p", ".", "AssertType", "(", "TypeGSA", ")", "\n", "m", ":=", "GSA", "{", "BaseSentence", ":", "s", ",", "Mode", ":"...
// newGSA parses the GSA sentence into this struct.
[ "newGSA", "parses", "the", "GSA", "sentence", "into", "this", "struct", "." ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/gsa.go#L31-L50
22,522
adrianmo/go-nmea
sentence.go
parseSentence
func parseSentence(raw string) (BaseSentence, error) { startIndex := strings.IndexAny(raw, SentenceStart+SentenceStartEncapsulated) if startIndex != 0 { return BaseSentence{}, fmt.Errorf("nmea: sentence does not start with a '$' or '!'") } sumSepIndex := strings.Index(raw, ChecksumSep) if sumSepIndex == -1 { r...
go
func parseSentence(raw string) (BaseSentence, error) { startIndex := strings.IndexAny(raw, SentenceStart+SentenceStartEncapsulated) if startIndex != 0 { return BaseSentence{}, fmt.Errorf("nmea: sentence does not start with a '$' or '!'") } sumSepIndex := strings.Index(raw, ChecksumSep) if sumSepIndex == -1 { r...
[ "func", "parseSentence", "(", "raw", "string", ")", "(", "BaseSentence", ",", "error", ")", "{", "startIndex", ":=", "strings", ".", "IndexAny", "(", "raw", ",", "SentenceStart", "+", "SentenceStartEncapsulated", ")", "\n", "if", "startIndex", "!=", "0", "{"...
// parseSentence parses a raw message into it's fields
[ "parseSentence", "parses", "a", "raw", "message", "into", "it", "s", "fields" ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/sentence.go#L58-L86
22,523
adrianmo/go-nmea
sentence.go
parsePrefix
func parsePrefix(s string) (string, string) { if strings.HasPrefix(s, "P") { return "P", s[1:] } if len(s) < 2 { return s, "" } return s[:2], s[2:] }
go
func parsePrefix(s string) (string, string) { if strings.HasPrefix(s, "P") { return "P", s[1:] } if len(s) < 2 { return s, "" } return s[:2], s[2:] }
[ "func", "parsePrefix", "(", "s", "string", ")", "(", "string", ",", "string", ")", "{", "if", "strings", ".", "HasPrefix", "(", "s", ",", "\"", "\"", ")", "{", "return", "\"", "\"", ",", "s", "[", "1", ":", "]", "\n", "}", "\n", "if", "len", ...
// parsePrefix takes the first field and splits it into a talker id and data type.
[ "parsePrefix", "takes", "the", "first", "field", "and", "splits", "it", "into", "a", "talker", "id", "and", "data", "type", "." ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/sentence.go#L89-L97
22,524
adrianmo/go-nmea
sentence.go
xorChecksum
func xorChecksum(s string) string { var checksum uint8 for i := 0; i < len(s); i++ { checksum ^= s[i] } return fmt.Sprintf("%02X", checksum) }
go
func xorChecksum(s string) string { var checksum uint8 for i := 0; i < len(s); i++ { checksum ^= s[i] } return fmt.Sprintf("%02X", checksum) }
[ "func", "xorChecksum", "(", "s", "string", ")", "string", "{", "var", "checksum", "uint8", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "s", ")", ";", "i", "++", "{", "checksum", "^=", "s", "[", "i", "]", "\n", "}", "\n", "return", ...
// xor all the bytes in a string an return it // as an uppercase hex string
[ "xor", "all", "the", "bytes", "in", "a", "string", "an", "return", "it", "as", "an", "uppercase", "hex", "string" ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/sentence.go#L101-L107
22,525
adrianmo/go-nmea
sentence.go
Parse
func Parse(raw string) (Sentence, error) { s, err := parseSentence(raw) if err != nil { return nil, err } if strings.HasPrefix(s.Raw, SentenceStart) { switch s.Type { case TypeRMC: return newRMC(s) case TypeGGA: return newGGA(s) case TypeGSA: return newGSA(s) case TypeGLL: return newGLL(s) ...
go
func Parse(raw string) (Sentence, error) { s, err := parseSentence(raw) if err != nil { return nil, err } if strings.HasPrefix(s.Raw, SentenceStart) { switch s.Type { case TypeRMC: return newRMC(s) case TypeGGA: return newGGA(s) case TypeGSA: return newGSA(s) case TypeGLL: return newGLL(s) ...
[ "func", "Parse", "(", "raw", "string", ")", "(", "Sentence", ",", "error", ")", "{", "s", ",", "err", ":=", "parseSentence", "(", "raw", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "if", "strings", ".",...
// Parse parses the given string into the correct sentence type.
[ "Parse", "parses", "the", "given", "string", "into", "the", "correct", "sentence", "type", "." ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/sentence.go#L110-L148
22,526
adrianmo/go-nmea
types.go
FormatDMS
func FormatDMS(l float64) string { val := math.Abs(l) degrees := int(math.Floor(val)) minutes := int(math.Floor(60 * (val - float64(degrees)))) seconds := 3600 * (val - float64(degrees) - (float64(minutes) / 60)) return fmt.Sprintf("%d\u00B0 %d' %f\"", degrees, minutes, seconds) }
go
func FormatDMS(l float64) string { val := math.Abs(l) degrees := int(math.Floor(val)) minutes := int(math.Floor(60 * (val - float64(degrees)))) seconds := 3600 * (val - float64(degrees) - (float64(minutes) / 60)) return fmt.Sprintf("%d\u00B0 %d' %f\"", degrees, minutes, seconds) }
[ "func", "FormatDMS", "(", "l", "float64", ")", "string", "{", "val", ":=", "math", ".", "Abs", "(", "l", ")", "\n", "degrees", ":=", "int", "(", "math", ".", "Floor", "(", "val", ")", ")", "\n", "minutes", ":=", "int", "(", "math", ".", "Floor", ...
// FormatDMS returns the degrees, minutes, seconds format for the given LatLong.
[ "FormatDMS", "returns", "the", "degrees", "minutes", "seconds", "format", "for", "the", "given", "LatLong", "." ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/types.go#L160-L166
22,527
adrianmo/go-nmea
types.go
String
func (t Time) String() string { seconds := float64(t.Second) + float64(t.Millisecond)/1000 return fmt.Sprintf("%02d:%02d:%07.4f", t.Hour, t.Minute, seconds) }
go
func (t Time) String() string { seconds := float64(t.Second) + float64(t.Millisecond)/1000 return fmt.Sprintf("%02d:%02d:%07.4f", t.Hour, t.Minute, seconds) }
[ "func", "(", "t", "Time", ")", "String", "(", ")", "string", "{", "seconds", ":=", "float64", "(", "t", ".", "Second", ")", "+", "float64", "(", "t", ".", "Millisecond", ")", "/", "1000", "\n", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",...
// String representation of Time
[ "String", "representation", "of", "Time" ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/types.go#L178-L181
22,528
adrianmo/go-nmea
types.go
String
func (d Date) String() string { return fmt.Sprintf("%02d/%02d/%02d", d.DD, d.MM, d.YY) }
go
func (d Date) String() string { return fmt.Sprintf("%02d/%02d/%02d", d.DD, d.MM, d.YY) }
[ "func", "(", "d", "Date", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "d", ".", "DD", ",", "d", ".", "MM", ",", "d", ".", "YY", ")", "\n", "}" ]
// String representation of date
[ "String", "representation", "of", "date" ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/types.go#L223-L225
22,529
adrianmo/go-nmea
types.go
ParseDate
func ParseDate(ddmmyy string) (Date, error) { if ddmmyy == "" { return Date{}, nil } if len(ddmmyy) != 6 { return Date{}, fmt.Errorf("parse date: exptected ddmmyy format, got '%s'", ddmmyy) } dd, err := strconv.Atoi(ddmmyy[0:2]) if err != nil { return Date{}, errors.New(ddmmyy) } mm, err := strconv.Atoi(d...
go
func ParseDate(ddmmyy string) (Date, error) { if ddmmyy == "" { return Date{}, nil } if len(ddmmyy) != 6 { return Date{}, fmt.Errorf("parse date: exptected ddmmyy format, got '%s'", ddmmyy) } dd, err := strconv.Atoi(ddmmyy[0:2]) if err != nil { return Date{}, errors.New(ddmmyy) } mm, err := strconv.Atoi(d...
[ "func", "ParseDate", "(", "ddmmyy", "string", ")", "(", "Date", ",", "error", ")", "{", "if", "ddmmyy", "==", "\"", "\"", "{", "return", "Date", "{", "}", ",", "nil", "\n", "}", "\n", "if", "len", "(", "ddmmyy", ")", "!=", "6", "{", "return", "...
// ParseDate field ddmmyy format
[ "ParseDate", "field", "ddmmyy", "format" ]
7572fbeb90aaa0bd3d1dcb674938ffbc0a943123
https://github.com/adrianmo/go-nmea/blob/7572fbeb90aaa0bd3d1dcb674938ffbc0a943123/types.go#L228-L248
22,530
jessevdk/go-flags
group.go
Find
func (g *Group) Find(shortDescription string) *Group { lshortDescription := strings.ToLower(shortDescription) var ret *Group g.eachGroup(func(gg *Group) { if gg != g && strings.ToLower(gg.ShortDescription) == lshortDescription { ret = gg } }) return ret }
go
func (g *Group) Find(shortDescription string) *Group { lshortDescription := strings.ToLower(shortDescription) var ret *Group g.eachGroup(func(gg *Group) { if gg != g && strings.ToLower(gg.ShortDescription) == lshortDescription { ret = gg } }) return ret }
[ "func", "(", "g", "*", "Group", ")", "Find", "(", "shortDescription", "string", ")", "*", "Group", "{", "lshortDescription", ":=", "strings", ".", "ToLower", "(", "shortDescription", ")", "\n\n", "var", "ret", "*", "Group", "\n\n", "g", ".", "eachGroup", ...
// Find locates the subgroup with the given short description and returns it. // If no such group can be found Find will return nil. Note that the description // is matched case insensitively.
[ "Find", "locates", "the", "subgroup", "with", "the", "given", "short", "description", "and", "returns", "it", ".", "If", "no", "such", "group", "can", "be", "found", "Find", "will", "return", "nil", ".", "Note", "that", "the", "description", "is", "matched...
c0795c8afcf41dd1d786bebce68636c199b3bb45
https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/group.go#L89-L101
22,531
jessevdk/go-flags
group.go
FindOptionByShortName
func (g *Group) FindOptionByShortName(shortName rune) *Option { return g.findOption(func(option *Option) bool { return option.ShortName == shortName }) }
go
func (g *Group) FindOptionByShortName(shortName rune) *Option { return g.findOption(func(option *Option) bool { return option.ShortName == shortName }) }
[ "func", "(", "g", "*", "Group", ")", "FindOptionByShortName", "(", "shortName", "rune", ")", "*", "Option", "{", "return", "g", ".", "findOption", "(", "func", "(", "option", "*", "Option", ")", "bool", "{", "return", "option", ".", "ShortName", "==", ...
// FindOptionByShortName finds an option that is part of the group, or any of // its subgroups, by matching its short name.
[ "FindOptionByShortName", "finds", "an", "option", "that", "is", "part", "of", "the", "group", "or", "any", "of", "its", "subgroups", "by", "matching", "its", "short", "name", "." ]
c0795c8afcf41dd1d786bebce68636c199b3bb45
https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/group.go#L125-L129
22,532
jessevdk/go-flags
man.go
WriteManPage
func (p *Parser) WriteManPage(wr io.Writer) { t := time.Now() source_date_epoch := os.Getenv("SOURCE_DATE_EPOCH") if source_date_epoch != "" { sde, err := strconv.ParseInt(source_date_epoch, 10, 64) if err != nil { panic(fmt.Sprintf("Invalid SOURCE_DATE_EPOCH: %s", err)) } t = time.Unix(sde, 0) } fmt.F...
go
func (p *Parser) WriteManPage(wr io.Writer) { t := time.Now() source_date_epoch := os.Getenv("SOURCE_DATE_EPOCH") if source_date_epoch != "" { sde, err := strconv.ParseInt(source_date_epoch, 10, 64) if err != nil { panic(fmt.Sprintf("Invalid SOURCE_DATE_EPOCH: %s", err)) } t = time.Unix(sde, 0) } fmt.F...
[ "func", "(", "p", "*", "Parser", ")", "WriteManPage", "(", "wr", "io", ".", "Writer", ")", "{", "t", ":=", "time", ".", "Now", "(", ")", "\n", "source_date_epoch", ":=", "os", ".", "Getenv", "(", "\"", "\"", ")", "\n", "if", "source_date_epoch", "!...
// WriteManPage writes a basic man page in groff format to the specified // writer.
[ "WriteManPage", "writes", "a", "basic", "man", "page", "in", "groff", "format", "to", "the", "specified", "writer", "." ]
c0795c8afcf41dd1d786bebce68636c199b3bb45
https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/man.go#L178-L215
22,533
jessevdk/go-flags
parser.go
NewNamedParser
func NewNamedParser(appname string, options Options) *Parser { p := &Parser{ Command: newCommand(appname, "", "", nil), Options: options, NamespaceDelimiter: ".", EnvNamespaceDelimiter: "_", } p.Command.parent = p return p }
go
func NewNamedParser(appname string, options Options) *Parser { p := &Parser{ Command: newCommand(appname, "", "", nil), Options: options, NamespaceDelimiter: ".", EnvNamespaceDelimiter: "_", } p.Command.parent = p return p }
[ "func", "NewNamedParser", "(", "appname", "string", ",", "options", "Options", ")", "*", "Parser", "{", "p", ":=", "&", "Parser", "{", "Command", ":", "newCommand", "(", "appname", ",", "\"", "\"", ",", "\"", "\"", ",", "nil", ")", ",", "Options", ":...
// NewNamedParser creates a new parser. The appname is used to display the // executable name in the built-in help message. Option groups and commands can // be added to this parser by using AddGroup and AddCommand.
[ "NewNamedParser", "creates", "a", "new", "parser", ".", "The", "appname", "is", "used", "to", "display", "the", "executable", "name", "in", "the", "built", "-", "in", "help", "message", ".", "Option", "groups", "and", "commands", "can", "be", "added", "to"...
c0795c8afcf41dd1d786bebce68636c199b3bb45
https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/parser.go#L174-L185
22,534
jessevdk/go-flags
ini.go
ParseFile
func (i *IniParser) ParseFile(filename string) error { ini, err := readIniFromFile(filename) if err != nil { return err } return i.parse(ini) }
go
func (i *IniParser) ParseFile(filename string) error { ini, err := readIniFromFile(filename) if err != nil { return err } return i.parse(ini) }
[ "func", "(", "i", "*", "IniParser", ")", "ParseFile", "(", "filename", "string", ")", "error", "{", "ini", ",", "err", ":=", "readIniFromFile", "(", "filename", ")", "\n\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "return", ...
// ParseFile parses flags from an ini formatted file. See Parse for more // information on the ini file format. The returned errors can be of the type // flags.Error or flags.IniError.
[ "ParseFile", "parses", "flags", "from", "an", "ini", "formatted", "file", ".", "See", "Parse", "for", "more", "information", "on", "the", "ini", "file", "format", ".", "The", "returned", "errors", "can", "be", "of", "the", "type", "flags", ".", "Error", ...
c0795c8afcf41dd1d786bebce68636c199b3bb45
https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/ini.go#L100-L108
22,535
jessevdk/go-flags
ini.go
WriteFile
func (i *IniParser) WriteFile(filename string, options IniOptions) error { return writeIniToFile(i, filename, options) }
go
func (i *IniParser) WriteFile(filename string, options IniOptions) error { return writeIniToFile(i, filename, options) }
[ "func", "(", "i", "*", "IniParser", ")", "WriteFile", "(", "filename", "string", ",", "options", "IniOptions", ")", "error", "{", "return", "writeIniToFile", "(", "i", ",", "filename", ",", "options", ")", "\n", "}" ]
// WriteFile writes the flags as ini format into a file. See Write // for more information. The returned error occurs when the specified file // could not be opened for writing.
[ "WriteFile", "writes", "the", "flags", "as", "ini", "format", "into", "a", "file", ".", "See", "Write", "for", "more", "information", ".", "The", "returned", "error", "occurs", "when", "the", "specified", "file", "could", "not", "be", "opened", "for", "wri...
c0795c8afcf41dd1d786bebce68636c199b3bb45
https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/ini.go#L147-L149
22,536
jessevdk/go-flags
completion.go
Complete
func (f *Filename) Complete(match string) []Completion { ret, _ := filepath.Glob(match + "*") if len(ret) == 1 { if info, err := os.Stat(ret[0]); err == nil && info.IsDir() { ret[0] = ret[0] + "/" } } return completionsWithoutDescriptions(ret) }
go
func (f *Filename) Complete(match string) []Completion { ret, _ := filepath.Glob(match + "*") if len(ret) == 1 { if info, err := os.Stat(ret[0]); err == nil && info.IsDir() { ret[0] = ret[0] + "/" } } return completionsWithoutDescriptions(ret) }
[ "func", "(", "f", "*", "Filename", ")", "Complete", "(", "match", "string", ")", "[", "]", "Completion", "{", "ret", ",", "_", ":=", "filepath", ".", "Glob", "(", "match", "+", "\"", "\"", ")", "\n", "if", "len", "(", "ret", ")", "==", "1", "{"...
// Complete returns a list of existing files with the given // prefix.
[ "Complete", "returns", "a", "list", "of", "existing", "files", "with", "the", "given", "prefix", "." ]
c0795c8afcf41dd1d786bebce68636c199b3bb45
https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/completion.go#L64-L72
22,537
jessevdk/go-flags
option.go
LongNameWithNamespace
func (option *Option) LongNameWithNamespace() string { if len(option.LongName) == 0 { return "" } // fetch the namespace delimiter from the parser which is always at the // end of the group hierarchy namespaceDelimiter := "" g := option.group for { if p, ok := g.parent.(*Parser); ok { namespaceDelimiter...
go
func (option *Option) LongNameWithNamespace() string { if len(option.LongName) == 0 { return "" } // fetch the namespace delimiter from the parser which is always at the // end of the group hierarchy namespaceDelimiter := "" g := option.group for { if p, ok := g.parent.(*Parser); ok { namespaceDelimiter...
[ "func", "(", "option", "*", "Option", ")", "LongNameWithNamespace", "(", ")", "string", "{", "if", "len", "(", "option", ".", "LongName", ")", "==", "0", "{", "return", "\"", "\"", "\n", "}", "\n\n", "// fetch the namespace delimiter from the parser which is alw...
// LongNameWithNamespace returns the option's long name with the group namespaces // prepended by walking up the option's group tree. Namespaces and the long name // itself are separated by the parser's namespace delimiter. If the long name is // empty an empty string is returned.
[ "LongNameWithNamespace", "returns", "the", "option", "s", "long", "name", "with", "the", "group", "namespaces", "prepended", "by", "walking", "up", "the", "option", "s", "group", "tree", ".", "Namespaces", "and", "the", "long", "name", "itself", "are", "separa...
c0795c8afcf41dd1d786bebce68636c199b3bb45
https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/option.go#L95-L140
22,538
jessevdk/go-flags
option.go
EnvKeyWithNamespace
func (option *Option) EnvKeyWithNamespace() string { if len(option.EnvDefaultKey) == 0 { return "" } // fetch the namespace delimiter from the parser which is always at the // end of the group hierarchy namespaceDelimiter := "" g := option.group for { if p, ok := g.parent.(*Parser); ok { namespaceDelimi...
go
func (option *Option) EnvKeyWithNamespace() string { if len(option.EnvDefaultKey) == 0 { return "" } // fetch the namespace delimiter from the parser which is always at the // end of the group hierarchy namespaceDelimiter := "" g := option.group for { if p, ok := g.parent.(*Parser); ok { namespaceDelimi...
[ "func", "(", "option", "*", "Option", ")", "EnvKeyWithNamespace", "(", ")", "string", "{", "if", "len", "(", "option", ".", "EnvDefaultKey", ")", "==", "0", "{", "return", "\"", "\"", "\n", "}", "\n\n", "// fetch the namespace delimiter from the parser which is ...
// EnvKeyWithNamespace returns the option's env key with the group namespaces // prepended by walking up the option's group tree. Namespaces and the env key // itself are separated by the parser's namespace delimiter. If the env key is // empty an empty string is returned.
[ "EnvKeyWithNamespace", "returns", "the", "option", "s", "env", "key", "with", "the", "group", "namespaces", "prepended", "by", "walking", "up", "the", "option", "s", "group", "tree", ".", "Namespaces", "and", "the", "env", "key", "itself", "are", "separated", ...
c0795c8afcf41dd1d786bebce68636c199b3bb45
https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/option.go#L146-L191
22,539
jessevdk/go-flags
option.go
String
func (option *Option) String() string { var s string var short string if option.ShortName != 0 { data := make([]byte, utf8.RuneLen(option.ShortName)) utf8.EncodeRune(data, option.ShortName) short = string(data) if len(option.LongName) != 0 { s = fmt.Sprintf("%s%s, %s%s", string(defaultShortOptDelimi...
go
func (option *Option) String() string { var s string var short string if option.ShortName != 0 { data := make([]byte, utf8.RuneLen(option.ShortName)) utf8.EncodeRune(data, option.ShortName) short = string(data) if len(option.LongName) != 0 { s = fmt.Sprintf("%s%s, %s%s", string(defaultShortOptDelimi...
[ "func", "(", "option", "*", "Option", ")", "String", "(", ")", "string", "{", "var", "s", "string", "\n", "var", "short", "string", "\n\n", "if", "option", ".", "ShortName", "!=", "0", "{", "data", ":=", "make", "(", "[", "]", "byte", ",", "utf8", ...
// String converts an option to a human friendly readable string describing the // option.
[ "String", "converts", "an", "option", "to", "a", "human", "friendly", "readable", "string", "describing", "the", "option", "." ]
c0795c8afcf41dd1d786bebce68636c199b3bb45
https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/option.go#L195-L216
22,540
jessevdk/go-flags
option.go
set
func (option *Option) set(value *string) error { kind := option.value.Type().Kind() if (kind == reflect.Map || kind == reflect.Slice) && !option.isSet { option.empty() } option.isSet = true option.preventDefault = true if len(option.Choices) != 0 { found := false for _, choice := range option.Choices { ...
go
func (option *Option) set(value *string) error { kind := option.value.Type().Kind() if (kind == reflect.Map || kind == reflect.Slice) && !option.isSet { option.empty() } option.isSet = true option.preventDefault = true if len(option.Choices) != 0 { found := false for _, choice := range option.Choices { ...
[ "func", "(", "option", "*", "Option", ")", "set", "(", "value", "*", "string", ")", "error", "{", "kind", ":=", "option", ".", "value", ".", "Type", "(", ")", ".", "Kind", "(", ")", "\n\n", "if", "(", "kind", "==", "reflect", ".", "Map", "||", ...
// Set the value of an option to the specified value. An error will be returned // if the specified value could not be converted to the corresponding option // value type.
[ "Set", "the", "value", "of", "an", "option", "to", "the", "specified", "value", ".", "An", "error", "will", "be", "returned", "if", "the", "specified", "value", "could", "not", "be", "converted", "to", "the", "corresponding", "option", "value", "type", "."...
c0795c8afcf41dd1d786bebce68636c199b3bb45
https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/option.go#L241-L281
22,541
jessevdk/go-flags
command.go
AddCommand
func (c *Command) AddCommand(command string, shortDescription string, longDescription string, data interface{}) (*Command, error) { cmd := newCommand(command, shortDescription, longDescription, data) cmd.parent = c if err := cmd.scan(); err != nil { return nil, err } c.commands = append(c.commands, cmd) retu...
go
func (c *Command) AddCommand(command string, shortDescription string, longDescription string, data interface{}) (*Command, error) { cmd := newCommand(command, shortDescription, longDescription, data) cmd.parent = c if err := cmd.scan(); err != nil { return nil, err } c.commands = append(c.commands, cmd) retu...
[ "func", "(", "c", "*", "Command", ")", "AddCommand", "(", "command", "string", ",", "shortDescription", "string", ",", "longDescription", "string", ",", "data", "interface", "{", "}", ")", "(", "*", "Command", ",", "error", ")", "{", "cmd", ":=", "newCom...
// AddCommand adds a new command to the parser with the given name and data. The // data needs to be a pointer to a struct from which the fields indicate which // options are in the command. The provided data can implement the Command and // Usage interfaces.
[ "AddCommand", "adds", "a", "new", "command", "to", "the", "parser", "with", "the", "given", "name", "and", "data", ".", "The", "data", "needs", "to", "be", "a", "pointer", "to", "a", "struct", "from", "which", "the", "fields", "indicate", "which", "optio...
c0795c8afcf41dd1d786bebce68636c199b3bb45
https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/command.go#L68-L79
22,542
jessevdk/go-flags
command.go
Find
func (c *Command) Find(name string) *Command { for _, cc := range c.commands { if cc.match(name) { return cc } } return nil }
go
func (c *Command) Find(name string) *Command { for _, cc := range c.commands { if cc.match(name) { return cc } } return nil }
[ "func", "(", "c", "*", "Command", ")", "Find", "(", "name", "string", ")", "*", "Command", "{", "for", "_", ",", "cc", ":=", "range", "c", ".", "commands", "{", "if", "cc", ".", "match", "(", "name", ")", "{", "return", "cc", "\n", "}", "\n", ...
// Find locates the subcommand with the given name and returns it. If no such // command can be found Find will return nil.
[ "Find", "locates", "the", "subcommand", "with", "the", "given", "name", "and", "returns", "it", ".", "If", "no", "such", "command", "can", "be", "found", "Find", "will", "return", "nil", "." ]
c0795c8afcf41dd1d786bebce68636c199b3bb45
https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/command.go#L104-L112
22,543
jessevdk/go-flags
command.go
Args
func (c *Command) Args() []*Arg { ret := make([]*Arg, len(c.args)) copy(ret, c.args) return ret }
go
func (c *Command) Args() []*Arg { ret := make([]*Arg, len(c.args)) copy(ret, c.args) return ret }
[ "func", "(", "c", "*", "Command", ")", "Args", "(", ")", "[", "]", "*", "Arg", "{", "ret", ":=", "make", "(", "[", "]", "*", "Arg", ",", "len", "(", "c", ".", "args", ")", ")", "\n", "copy", "(", "ret", ",", "c", ".", "args", ")", "\n\n",...
// Args returns a list of positional arguments associated with this command.
[ "Args", "returns", "a", "list", "of", "positional", "arguments", "associated", "with", "this", "command", "." ]
c0795c8afcf41dd1d786bebce68636c199b3bb45
https://github.com/jessevdk/go-flags/blob/c0795c8afcf41dd1d786bebce68636c199b3bb45/command.go#L141-L146
22,544
motemen/ghq
commands.go
mkCommandsTemplate
func mkCommandsTemplate(genTemplate func(commandDoc) string) string { template := "{{if false}}" for _, command := range append(commands) { template = template + fmt.Sprintf("{{else if (eq .Name %q)}}%s", command.Name, genTemplate(commandDocs[command.Name])) } return template + "{{end}}" }
go
func mkCommandsTemplate(genTemplate func(commandDoc) string) string { template := "{{if false}}" for _, command := range append(commands) { template = template + fmt.Sprintf("{{else if (eq .Name %q)}}%s", command.Name, genTemplate(commandDocs[command.Name])) } return template + "{{end}}" }
[ "func", "mkCommandsTemplate", "(", "genTemplate", "func", "(", "commandDoc", ")", "string", ")", "string", "{", "template", ":=", "\"", "\"", "\n", "for", "_", ",", "command", ":=", "range", "append", "(", "commands", ")", "{", "template", "=", "template",...
// Makes template conditionals to generate per-command documents.
[ "Makes", "template", "conditionals", "to", "generate", "per", "-", "command", "documents", "." ]
f311c7108b66c3c94d7730882fdf53a170fd6722
https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/commands.go#L105-L111
22,545
motemen/ghq
git.go
GitConfigAll
func GitConfigAll(key string) ([]string, error) { value, err := GitConfig("--get-all", key) if err != nil { return nil, err } // No results found, return an empty slice if value == "" { return nil, nil } return strings.Split(value, "\000"), nil }
go
func GitConfigAll(key string) ([]string, error) { value, err := GitConfig("--get-all", key) if err != nil { return nil, err } // No results found, return an empty slice if value == "" { return nil, nil } return strings.Split(value, "\000"), nil }
[ "func", "GitConfigAll", "(", "key", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "value", ",", "err", ":=", "GitConfig", "(", "\"", "\"", ",", "key", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", ...
// GitConfigAll fetches git-config variable of multiple values.
[ "GitConfigAll", "fetches", "git", "-", "config", "variable", "of", "multiple", "values", "." ]
f311c7108b66c3c94d7730882fdf53a170fd6722
https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/git.go#L21-L33
22,546
motemen/ghq
git.go
GitConfig
func GitConfig(args ...string) (string, error) { gitArgs := append([]string{"config", "--path", "--null"}, args...) cmd := exec.Command("git", gitArgs...) cmd.Stderr = os.Stderr buf, err := cmd.Output() if exitError, ok := err.(*exec.ExitError); ok { if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); o...
go
func GitConfig(args ...string) (string, error) { gitArgs := append([]string{"config", "--path", "--null"}, args...) cmd := exec.Command("git", gitArgs...) cmd.Stderr = os.Stderr buf, err := cmd.Output() if exitError, ok := err.(*exec.ExitError); ok { if waitStatus, ok := exitError.Sys().(syscall.WaitStatus); o...
[ "func", "GitConfig", "(", "args", "...", "string", ")", "(", "string", ",", "error", ")", "{", "gitArgs", ":=", "append", "(", "[", "]", "string", "{", "\"", "\"", ",", "\"", "\"", ",", "\"", "\"", "}", ",", "args", "...", ")", "\n", "cmd", ":=...
// GitConfig invokes 'git config' and handles some errors properly.
[ "GitConfig", "invokes", "git", "config", "and", "handles", "some", "errors", "properly", "." ]
f311c7108b66c3c94d7730882fdf53a170fd6722
https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/git.go#L36-L55
22,547
motemen/ghq
cmdutil/run.go
Run
func Run(command string, args ...string) error { cmd := exec.Command(command, args...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr return RunCommand(cmd, false) }
go
func Run(command string, args ...string) error { cmd := exec.Command(command, args...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr return RunCommand(cmd, false) }
[ "func", "Run", "(", "command", "string", ",", "args", "...", "string", ")", "error", "{", "cmd", ":=", "exec", ".", "Command", "(", "command", ",", "args", "...", ")", "\n", "cmd", ".", "Stdout", "=", "os", ".", "Stdout", "\n", "cmd", ".", "Stderr"...
// Run the command
[ "Run", "the", "command" ]
f311c7108b66c3c94d7730882fdf53a170fd6722
https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/cmdutil/run.go#L14-L20
22,548
motemen/ghq
cmdutil/run.go
RunSilently
func RunSilently(command string, args ...string) error { cmd := exec.Command(command, args...) cmd.Stdout = ioutil.Discard cmd.Stderr = ioutil.Discard return RunCommand(cmd, true) }
go
func RunSilently(command string, args ...string) error { cmd := exec.Command(command, args...) cmd.Stdout = ioutil.Discard cmd.Stderr = ioutil.Discard return RunCommand(cmd, true) }
[ "func", "RunSilently", "(", "command", "string", ",", "args", "...", "string", ")", "error", "{", "cmd", ":=", "exec", ".", "Command", "(", "command", ",", "args", "...", ")", "\n", "cmd", ".", "Stdout", "=", "ioutil", ".", "Discard", "\n", "cmd", "....
// RunSilently runs the command silently
[ "RunSilently", "runs", "the", "command", "silently" ]
f311c7108b66c3c94d7730882fdf53a170fd6722
https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/cmdutil/run.go#L23-L29
22,549
motemen/ghq
cmdutil/run.go
RunInDir
func RunInDir(dir, command string, args ...string) error { cmd := exec.Command(command, args...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.Dir = dir return RunCommand(cmd, false) }
go
func RunInDir(dir, command string, args ...string) error { cmd := exec.Command(command, args...) cmd.Stdout = os.Stdout cmd.Stderr = os.Stderr cmd.Dir = dir return RunCommand(cmd, false) }
[ "func", "RunInDir", "(", "dir", ",", "command", "string", ",", "args", "...", "string", ")", "error", "{", "cmd", ":=", "exec", ".", "Command", "(", "command", ",", "args", "...", ")", "\n", "cmd", ".", "Stdout", "=", "os", ".", "Stdout", "\n", "cm...
// RunInDir runs the command in the specified directory
[ "RunInDir", "runs", "the", "command", "in", "the", "specified", "directory" ]
f311c7108b66c3c94d7730882fdf53a170fd6722
https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/cmdutil/run.go#L32-L39
22,550
motemen/ghq
cmdutil/run.go
RunInDirSilently
func RunInDirSilently(dir, command string, args ...string) error { cmd := exec.Command(command, args...) cmd.Stdout = ioutil.Discard cmd.Stderr = ioutil.Discard cmd.Dir = dir return RunCommand(cmd, true) }
go
func RunInDirSilently(dir, command string, args ...string) error { cmd := exec.Command(command, args...) cmd.Stdout = ioutil.Discard cmd.Stderr = ioutil.Discard cmd.Dir = dir return RunCommand(cmd, true) }
[ "func", "RunInDirSilently", "(", "dir", ",", "command", "string", ",", "args", "...", "string", ")", "error", "{", "cmd", ":=", "exec", ".", "Command", "(", "command", ",", "args", "...", ")", "\n", "cmd", ".", "Stdout", "=", "ioutil", ".", "Discard", ...
// RunInDirSilently run the command in the specified directory silently
[ "RunInDirSilently", "run", "the", "command", "in", "the", "specified", "directory", "silently" ]
f311c7108b66c3c94d7730882fdf53a170fd6722
https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/cmdutil/run.go#L42-L49
22,551
motemen/ghq
cmdutil/run.go
RunCommand
func RunCommand(cmd *exec.Cmd, silent bool) error { if !silent { logger.Log(cmd.Args[0], strings.Join(cmd.Args[1:], " ")) } err := CommandRunner(cmd) if err != nil { if execErr, ok := err.(*exec.Error); ok { logger.Log("warning", fmt.Sprintf("%q: %s", execErr.Name, execErr.Err)) } return &RunError{cmd, e...
go
func RunCommand(cmd *exec.Cmd, silent bool) error { if !silent { logger.Log(cmd.Args[0], strings.Join(cmd.Args[1:], " ")) } err := CommandRunner(cmd) if err != nil { if execErr, ok := err.(*exec.Error); ok { logger.Log("warning", fmt.Sprintf("%q: %s", execErr.Name, execErr.Err)) } return &RunError{cmd, e...
[ "func", "RunCommand", "(", "cmd", "*", "exec", ".", "Cmd", ",", "silent", "bool", ")", "error", "{", "if", "!", "silent", "{", "logger", ".", "Log", "(", "cmd", ".", "Args", "[", "0", "]", ",", "strings", ".", "Join", "(", "cmd", ".", "Args", "...
// RunCommand run the command
[ "RunCommand", "run", "the", "command" ]
f311c7108b66c3c94d7730882fdf53a170fd6722
https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/cmdutil/run.go#L60-L73
22,552
motemen/ghq
cmdutil/run.go
Error
func (e *RunError) Error() string { return fmt.Sprintf("%s: %s", e.Command.Path, e.ExecError) }
go
func (e *RunError) Error() string { return fmt.Sprintf("%s: %s", e.Command.Path, e.ExecError) }
[ "func", "(", "e", "*", "RunError", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "Command", ".", "Path", ",", "e", ".", "ExecError", ")", "\n", "}" ]
// Error to implement error interface
[ "Error", "to", "implement", "error", "interface" ]
f311c7108b66c3c94d7730882fdf53a170fd6722
https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/cmdutil/run.go#L82-L84
22,553
motemen/ghq
local_repository.go
Matches
func (repo *LocalRepository) Matches(pathQuery string) bool { for _, p := range repo.Subpaths() { if p == pathQuery { return true } } return false }
go
func (repo *LocalRepository) Matches(pathQuery string) bool { for _, p := range repo.Subpaths() { if p == pathQuery { return true } } return false }
[ "func", "(", "repo", "*", "LocalRepository", ")", "Matches", "(", "pathQuery", "string", ")", "bool", "{", "for", "_", ",", "p", ":=", "range", "repo", ".", "Subpaths", "(", ")", "{", "if", "p", "==", "pathQuery", "{", "return", "true", "\n", "}", ...
// Matches checks if any subpath of the local repository equals the query.
[ "Matches", "checks", "if", "any", "subpath", "of", "the", "local", "repository", "equals", "the", "query", "." ]
f311c7108b66c3c94d7730882fdf53a170fd6722
https://github.com/motemen/ghq/blob/f311c7108b66c3c94d7730882fdf53a170fd6722/local_repository.go#L112-L120
22,554
openzipkin-contrib/zipkin-go-opentracing
zipkin-recorder.go
annotate
func annotate(span *zipkincore.Span, timestamp time.Time, value string, host *zipkincore.Endpoint) { if timestamp.IsZero() { timestamp = time.Now() } span.Annotations = append(span.Annotations, &zipkincore.Annotation{ Timestamp: timestamp.UnixNano() / 1e3, Value: value, Host: host, }) }
go
func annotate(span *zipkincore.Span, timestamp time.Time, value string, host *zipkincore.Endpoint) { if timestamp.IsZero() { timestamp = time.Now() } span.Annotations = append(span.Annotations, &zipkincore.Annotation{ Timestamp: timestamp.UnixNano() / 1e3, Value: value, Host: host, }) }
[ "func", "annotate", "(", "span", "*", "zipkincore", ".", "Span", ",", "timestamp", "time", ".", "Time", ",", "value", "string", ",", "host", "*", "zipkincore", ".", "Endpoint", ")", "{", "if", "timestamp", ".", "IsZero", "(", ")", "{", "timestamp", "="...
// annotate annotates the span with the given value.
[ "annotate", "annotates", "the", "span", "with", "the", "given", "value", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/zipkin-recorder.go#L191-L200
22,555
openzipkin-contrib/zipkin-go-opentracing
examples/cli_with_2_services/svc2/httpclient.go
NewHTTPClient
func NewHTTPClient(tracer opentracing.Tracer, baseURL string) Service { return &client{ baseURL: baseURL, httpClient: &http.Client{}, tracer: tracer, traceRequest: middleware.ToHTTPRequest(tracer), } }
go
func NewHTTPClient(tracer opentracing.Tracer, baseURL string) Service { return &client{ baseURL: baseURL, httpClient: &http.Client{}, tracer: tracer, traceRequest: middleware.ToHTTPRequest(tracer), } }
[ "func", "NewHTTPClient", "(", "tracer", "opentracing", ".", "Tracer", ",", "baseURL", "string", ")", "Service", "{", "return", "&", "client", "{", "baseURL", ":", "baseURL", ",", "httpClient", ":", "&", "http", ".", "Client", "{", "}", ",", "tracer", ":"...
// NewHTTPClient returns a new client instance to our svc2 using the HTTP // transport.
[ "NewHTTPClient", "returns", "a", "new", "client", "instance", "to", "our", "svc2", "using", "the", "HTTP", "transport", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/examples/cli_with_2_services/svc2/httpclient.go#L75-L82
22,556
openzipkin-contrib/zipkin-go-opentracing
logger.go
Log
func (l *wrappedLogger) Log(k ...interface{}) error { if len(k)%2 == 1 { k = append(k, ErrMissingValue) } o := make([]string, len(k)/2) for i := 0; i < len(k); i += 2 { o[i/2] = fmt.Sprintf("%s=%q", k[i], k[i+1]) } l.l.Println(strings.Join(o, " ")) return nil }
go
func (l *wrappedLogger) Log(k ...interface{}) error { if len(k)%2 == 1 { k = append(k, ErrMissingValue) } o := make([]string, len(k)/2) for i := 0; i < len(k); i += 2 { o[i/2] = fmt.Sprintf("%s=%q", k[i], k[i+1]) } l.l.Println(strings.Join(o, " ")) return nil }
[ "func", "(", "l", "*", "wrappedLogger", ")", "Log", "(", "k", "...", "interface", "{", "}", ")", "error", "{", "if", "len", "(", "k", ")", "%", "2", "==", "1", "{", "k", "=", "append", "(", "k", ",", "ErrMissingValue", ")", "\n", "}", "\n", "...
// Log implements Logger
[ "Log", "implements", "Logger" ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/logger.go#L38-L48
22,557
openzipkin-contrib/zipkin-go-opentracing
examples/cli_with_2_services/svc1/httpserver.go
concatHandler
func (s *httpService) concatHandler(w http.ResponseWriter, req *http.Request) { // parse query parameters v := req.URL.Query() result, err := s.service.Concat(req.Context(), v.Get("a"), v.Get("b")) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } // return the result w.Write([]byte(...
go
func (s *httpService) concatHandler(w http.ResponseWriter, req *http.Request) { // parse query parameters v := req.URL.Query() result, err := s.service.Concat(req.Context(), v.Get("a"), v.Get("b")) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } // return the result w.Write([]byte(...
[ "func", "(", "s", "*", "httpService", ")", "concatHandler", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "// parse query parameters", "v", ":=", "req", ".", "URL", ".", "Query", "(", ")", "\n", "result", "...
// concatHandler is our HTTP HandlerFunc for a Concat request.
[ "concatHandler", "is", "our", "HTTP", "HandlerFunc", "for", "a", "Concat", "request", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/examples/cli_with_2_services/svc1/httpserver.go#L20-L30
22,558
openzipkin-contrib/zipkin-go-opentracing
examples/cli_with_2_services/svc1/httpserver.go
sumHandler
func (s *httpService) sumHandler(w http.ResponseWriter, req *http.Request) { // parse query parameters v := req.URL.Query() a, err := strconv.ParseInt(v.Get("a"), 10, 64) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } b, err := strconv.ParseInt(v.Get("b"), 10, 64) if err != nil { ...
go
func (s *httpService) sumHandler(w http.ResponseWriter, req *http.Request) { // parse query parameters v := req.URL.Query() a, err := strconv.ParseInt(v.Get("a"), 10, 64) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return } b, err := strconv.ParseInt(v.Get("b"), 10, 64) if err != nil { ...
[ "func", "(", "s", "*", "httpService", ")", "sumHandler", "(", "w", "http", ".", "ResponseWriter", ",", "req", "*", "http", ".", "Request", ")", "{", "// parse query parameters", "v", ":=", "req", ".", "URL", ".", "Query", "(", ")", "\n", "a", ",", "e...
// sumHandler is our HTTP Handlerfunc for a Sum request.
[ "sumHandler", "is", "our", "HTTP", "Handlerfunc", "for", "a", "Sum", "request", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/examples/cli_with_2_services/svc1/httpserver.go#L33-L54
22,559
openzipkin-contrib/zipkin-go-opentracing
examples/cli_with_2_services/svc1/httpserver.go
NewHTTPHandler
func NewHTTPHandler(tracer opentracing.Tracer, service Service) http.Handler { // Create our HTTP Service. svc := &httpService{service: service} // Create the mux. mux := http.NewServeMux() // Create the Concat handler. var concatHandler http.Handler concatHandler = http.HandlerFunc(svc.concatHandler) // Wra...
go
func NewHTTPHandler(tracer opentracing.Tracer, service Service) http.Handler { // Create our HTTP Service. svc := &httpService{service: service} // Create the mux. mux := http.NewServeMux() // Create the Concat handler. var concatHandler http.Handler concatHandler = http.HandlerFunc(svc.concatHandler) // Wra...
[ "func", "NewHTTPHandler", "(", "tracer", "opentracing", ".", "Tracer", ",", "service", "Service", ")", "http", ".", "Handler", "{", "// Create our HTTP Service.", "svc", ":=", "&", "httpService", "{", "service", ":", "service", "}", "\n\n", "// Create the mux.", ...
// NewHTTPHandler returns a new HTTP handler our svc1.
[ "NewHTTPHandler", "returns", "a", "new", "HTTP", "handler", "our", "svc1", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/examples/cli_with_2_services/svc1/httpserver.go#L57-L84
22,560
openzipkin-contrib/zipkin-go-opentracing
collector-kafka.go
KafkaProducer
func KafkaProducer(p sarama.AsyncProducer) KafkaOption { return func(c *KafkaCollector) { c.producer = p } }
go
func KafkaProducer(p sarama.AsyncProducer) KafkaOption { return func(c *KafkaCollector) { c.producer = p } }
[ "func", "KafkaProducer", "(", "p", "sarama", ".", "AsyncProducer", ")", "KafkaOption", "{", "return", "func", "(", "c", "*", "KafkaCollector", ")", "{", "c", ".", "producer", "=", "p", "}", "\n", "}" ]
// KafkaProducer sets the producer used to produce to Kafka.
[ "KafkaProducer", "sets", "the", "producer", "used", "to", "produce", "to", "Kafka", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector-kafka.go#L34-L36
22,561
openzipkin-contrib/zipkin-go-opentracing
collector-scribe.go
ScribeBatchInterval
func ScribeBatchInterval(d time.Duration) ScribeOption { return func(s *ScribeCollector) { s.batchInterval = d } }
go
func ScribeBatchInterval(d time.Duration) ScribeOption { return func(s *ScribeCollector) { s.batchInterval = d } }
[ "func", "ScribeBatchInterval", "(", "d", "time", ".", "Duration", ")", "ScribeOption", "{", "return", "func", "(", "s", "*", "ScribeCollector", ")", "{", "s", ".", "batchInterval", "=", "d", "}", "\n", "}" ]
// ScribeBatchInterval sets the maximum duration we will buffer traces before // emitting them to the collector. The default batch interval is 1 second.
[ "ScribeBatchInterval", "sets", "the", "maximum", "duration", "we", "will", "buffer", "traces", "before", "emitting", "them", "to", "the", "collector", ".", "The", "default", "batch", "interval", "is", "1", "second", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector-scribe.go#L69-L71
22,562
openzipkin-contrib/zipkin-go-opentracing
tracer.go
WithSampler
func WithSampler(sampler Sampler) TracerOption { return func(opts *TracerOptions) error { opts.shouldSample = sampler return nil } }
go
func WithSampler(sampler Sampler) TracerOption { return func(opts *TracerOptions) error { opts.shouldSample = sampler return nil } }
[ "func", "WithSampler", "(", "sampler", "Sampler", ")", "TracerOption", "{", "return", "func", "(", "opts", "*", "TracerOptions", ")", "error", "{", "opts", ".", "shouldSample", "=", "sampler", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// WithSampler allows one to add a Sampler function
[ "WithSampler", "allows", "one", "to", "add", "a", "Sampler", "function" ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/tracer.go#L120-L125
22,563
openzipkin-contrib/zipkin-go-opentracing
tracer.go
DebugMode
func DebugMode(val bool) TracerOption { return func(opts *TracerOptions) error { opts.debugMode = val return nil } }
go
func DebugMode(val bool) TracerOption { return func(opts *TracerOptions) error { opts.debugMode = val return nil } }
[ "func", "DebugMode", "(", "val", "bool", ")", "TracerOption", "{", "return", "func", "(", "opts", "*", "TracerOptions", ")", "error", "{", "opts", ".", "debugMode", "=", "val", "\n", "return", "nil", "\n", "}", "\n", "}" ]
// DebugMode allows to set the tracer to Zipkin debug mode
[ "DebugMode", "allows", "to", "set", "the", "tracer", "to", "Zipkin", "debug", "mode" ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/tracer.go#L189-L194
22,564
openzipkin-contrib/zipkin-go-opentracing
tracer.go
NewTracer
func NewTracer(recorder SpanRecorder, options ...TracerOption) (opentracing.Tracer, error) { opts := &TracerOptions{ recorder: recorder, shouldSample: alwaysSample, trimUnsampledSpans: false, newSpanEventListener: func() func(SpanEvent) { return nil }, logger: &nopLogger{}...
go
func NewTracer(recorder SpanRecorder, options ...TracerOption) (opentracing.Tracer, error) { opts := &TracerOptions{ recorder: recorder, shouldSample: alwaysSample, trimUnsampledSpans: false, newSpanEventListener: func() func(SpanEvent) { return nil }, logger: &nopLogger{}...
[ "func", "NewTracer", "(", "recorder", "SpanRecorder", ",", "options", "...", "TracerOption", ")", "(", "opentracing", ".", "Tracer", ",", "error", ")", "{", "opts", ":=", "&", "TracerOptions", "{", "recorder", ":", "recorder", ",", "shouldSample", ":", "alwa...
// NewTracer creates a new OpenTracing compatible Zipkin Tracer.
[ "NewTracer", "creates", "a", "new", "OpenTracing", "compatible", "Zipkin", "Tracer", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/tracer.go#L224-L250
22,565
openzipkin-contrib/zipkin-go-opentracing
tracer.go
WithObserver
func WithObserver(observer otobserver.Observer) TracerOption { return func(opts *TracerOptions) error { opts.observer = observer return nil } }
go
func WithObserver(observer otobserver.Observer) TracerOption { return func(opts *TracerOptions) error { opts.observer = observer return nil } }
[ "func", "WithObserver", "(", "observer", "otobserver", ".", "Observer", ")", "TracerOption", "{", "return", "func", "(", "opts", "*", "TracerOptions", ")", "error", "{", "opts", ".", "observer", "=", "observer", "\n", "return", "nil", "\n", "}", "\n", "}" ...
// WithObserver assigns an initialized observer to opts.observer
[ "WithObserver", "assigns", "an", "initialized", "observer", "to", "opts", ".", "observer" ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/tracer.go#L435-L440
22,566
openzipkin-contrib/zipkin-go-opentracing
collector-http.go
HTTPTimeout
func HTTPTimeout(duration time.Duration) HTTPOption { return func(c *HTTPCollector) { c.client.Timeout = duration } }
go
func HTTPTimeout(duration time.Duration) HTTPOption { return func(c *HTTPCollector) { c.client.Timeout = duration } }
[ "func", "HTTPTimeout", "(", "duration", "time", ".", "Duration", ")", "HTTPOption", "{", "return", "func", "(", "c", "*", "HTTPCollector", ")", "{", "c", ".", "client", ".", "Timeout", "=", "duration", "}", "\n", "}" ]
// HTTPTimeout sets maximum timeout for http request.
[ "HTTPTimeout", "sets", "maximum", "timeout", "for", "http", "request", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector-http.go#L53-L55
22,567
openzipkin-contrib/zipkin-go-opentracing
collector-http.go
HTTPBatchInterval
func HTTPBatchInterval(d time.Duration) HTTPOption { return func(c *HTTPCollector) { c.batchInterval = d } }
go
func HTTPBatchInterval(d time.Duration) HTTPOption { return func(c *HTTPCollector) { c.batchInterval = d } }
[ "func", "HTTPBatchInterval", "(", "d", "time", ".", "Duration", ")", "HTTPOption", "{", "return", "func", "(", "c", "*", "HTTPCollector", ")", "{", "c", ".", "batchInterval", "=", "d", "}", "\n", "}" ]
// HTTPBatchInterval sets the maximum duration we will buffer traces before // emitting them to the collector. The default batch interval is 1 second.
[ "HTTPBatchInterval", "sets", "the", "maximum", "duration", "we", "will", "buffer", "traces", "before", "emitting", "them", "to", "the", "collector", ".", "The", "default", "batch", "interval", "is", "1", "second", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector-http.go#L72-L74
22,568
openzipkin-contrib/zipkin-go-opentracing
collector-http.go
HTTPClient
func HTTPClient(client *http.Client) HTTPOption { return func(c *HTTPCollector) { c.client = client } }
go
func HTTPClient(client *http.Client) HTTPOption { return func(c *HTTPCollector) { c.client = client } }
[ "func", "HTTPClient", "(", "client", "*", "http", ".", "Client", ")", "HTTPOption", "{", "return", "func", "(", "c", "*", "HTTPCollector", ")", "{", "c", ".", "client", "=", "client", "}", "\n", "}" ]
// HTTPClient sets a custom http client to use.
[ "HTTPClient", "sets", "a", "custom", "http", "client", "to", "use", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector-http.go#L77-L79
22,569
openzipkin-contrib/zipkin-go-opentracing
collector-http.go
NewHTTPCollector
func NewHTTPCollector(url string, options ...HTTPOption) (Collector, error) { c := &HTTPCollector{ logger: NewNopLogger(), url: url, client: &http.Client{Timeout: defaultHTTPTimeout}, batchInterval: defaultHTTPBatchInterval * time.Second, batchSize: defaultHTTPBatchSize, maxBack...
go
func NewHTTPCollector(url string, options ...HTTPOption) (Collector, error) { c := &HTTPCollector{ logger: NewNopLogger(), url: url, client: &http.Client{Timeout: defaultHTTPTimeout}, batchInterval: defaultHTTPBatchInterval * time.Second, batchSize: defaultHTTPBatchSize, maxBack...
[ "func", "NewHTTPCollector", "(", "url", "string", ",", "options", "...", "HTTPOption", ")", "(", "Collector", ",", "error", ")", "{", "c", ":=", "&", "HTTPCollector", "{", "logger", ":", "NewNopLogger", "(", ")", ",", "url", ":", "url", ",", "client", ...
// NewHTTPCollector returns a new HTTP-backend Collector. url should be a http // url for handle post request. timeout is passed to http client. queueSize control // the maximum size of buffer of async queue. The logger is used to log errors, // such as send failures;
[ "NewHTTPCollector", "returns", "a", "new", "HTTP", "-", "backend", "Collector", ".", "url", "should", "be", "a", "http", "url", "for", "handle", "post", "request", ".", "timeout", "is", "passed", "to", "http", "client", ".", "queueSize", "control", "the", ...
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector-http.go#L91-L112
22,570
openzipkin-contrib/zipkin-go-opentracing
collector-http.go
Collect
func (c *HTTPCollector) Collect(s *zipkincore.Span) error { select { case c.spanc <- s: // Accepted. case <-c.quit: // Collector concurrently closed. default: c.logger.Log("msg", "queue full, disposing spans.", "size", len(c.spanc)) } return nil }
go
func (c *HTTPCollector) Collect(s *zipkincore.Span) error { select { case c.spanc <- s: // Accepted. case <-c.quit: // Collector concurrently closed. default: c.logger.Log("msg", "queue full, disposing spans.", "size", len(c.spanc)) } return nil }
[ "func", "(", "c", "*", "HTTPCollector", ")", "Collect", "(", "s", "*", "zipkincore", ".", "Span", ")", "error", "{", "select", "{", "case", "c", ".", "spanc", "<-", "s", ":", "// Accepted.", "case", "<-", "c", ".", "quit", ":", "// Collector concurrent...
// Collect implements Collector. // attempts a non blocking send on the channel.
[ "Collect", "implements", "Collector", ".", "attempts", "a", "non", "blocking", "send", "on", "the", "channel", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector-http.go#L116-L126
22,571
openzipkin-contrib/zipkin-go-opentracing
wire/carrier.go
State
func (p *ProtobufCarrier) State() (traceID types.TraceID, spanID uint64, parentSpanID *uint64, sampled bool, flags flag.Flags) { traceID.Low = p.TraceId traceID.High = p.TraceIdHigh spanID = p.SpanId sampled = p.Sampled flags = flag.Flags(p.Flags) if flags&flag.IsRoot == 0 { parentSpanID = &p.ParentSpanId } r...
go
func (p *ProtobufCarrier) State() (traceID types.TraceID, spanID uint64, parentSpanID *uint64, sampled bool, flags flag.Flags) { traceID.Low = p.TraceId traceID.High = p.TraceIdHigh spanID = p.SpanId sampled = p.Sampled flags = flag.Flags(p.Flags) if flags&flag.IsRoot == 0 { parentSpanID = &p.ParentSpanId } r...
[ "func", "(", "p", "*", "ProtobufCarrier", ")", "State", "(", ")", "(", "traceID", "types", ".", "TraceID", ",", "spanID", "uint64", ",", "parentSpanID", "*", "uint64", ",", "sampled", "bool", ",", "flags", "flag", ".", "Flags", ")", "{", "traceID", "."...
// State returns the tracer state.
[ "State", "returns", "the", "tracer", "state", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/wire/carrier.go#L37-L47
22,572
openzipkin-contrib/zipkin-go-opentracing
wire/carrier.go
SetBaggageItem
func (p *ProtobufCarrier) SetBaggageItem(key, value string) { if p.BaggageItems == nil { p.BaggageItems = map[string]string{key: value} return } p.BaggageItems[key] = value }
go
func (p *ProtobufCarrier) SetBaggageItem(key, value string) { if p.BaggageItems == nil { p.BaggageItems = map[string]string{key: value} return } p.BaggageItems[key] = value }
[ "func", "(", "p", "*", "ProtobufCarrier", ")", "SetBaggageItem", "(", "key", ",", "value", "string", ")", "{", "if", "p", ".", "BaggageItems", "==", "nil", "{", "p", ".", "BaggageItems", "=", "map", "[", "string", "]", "string", "{", "key", ":", "val...
// SetBaggageItem sets a baggage item.
[ "SetBaggageItem", "sets", "a", "baggage", "item", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/wire/carrier.go#L50-L57
22,573
openzipkin-contrib/zipkin-go-opentracing
examples/middleware/http.go
ToHTTPRequest
func ToHTTPRequest(tracer opentracing.Tracer) RequestFunc { return func(req *http.Request) *http.Request { // Retrieve the Span from context. if span := opentracing.SpanFromContext(req.Context()); span != nil { // We are going to use this span in a client request, so mark as such. ext.SpanKindRPCClient.Set(...
go
func ToHTTPRequest(tracer opentracing.Tracer) RequestFunc { return func(req *http.Request) *http.Request { // Retrieve the Span from context. if span := opentracing.SpanFromContext(req.Context()); span != nil { // We are going to use this span in a client request, so mark as such. ext.SpanKindRPCClient.Set(...
[ "func", "ToHTTPRequest", "(", "tracer", "opentracing", ".", "Tracer", ")", "RequestFunc", "{", "return", "func", "(", "req", "*", "http", ".", "Request", ")", "*", "http", ".", "Request", "{", "// Retrieve the Span from context.", "if", "span", ":=", "opentrac...
// ToHTTPRequest returns a RequestFunc that injects an OpenTracing Span found in // context into the HTTP Headers. If no such Span can be found, the RequestFunc // is a noop.
[ "ToHTTPRequest", "returns", "a", "RequestFunc", "that", "injects", "an", "OpenTracing", "Span", "found", "in", "context", "into", "the", "HTTP", "Headers", ".", "If", "no", "such", "Span", "can", "be", "found", "the", "RequestFunc", "is", "a", "noop", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/examples/middleware/http.go#L25-L63
22,574
openzipkin-contrib/zipkin-go-opentracing
log-materializers.go
MaterializeWithLogFmt
func MaterializeWithLogFmt(logFields []log.Field) ([]byte, error) { var ( buffer = bytes.NewBuffer(nil) encoder = logfmt.NewEncoder(buffer) ) for _, field := range logFields { if err := encoder.EncodeKeyval(field.Key(), field.Value()); err != nil { encoder.EncodeKeyval(field.Key(), err.Error()) } } ret...
go
func MaterializeWithLogFmt(logFields []log.Field) ([]byte, error) { var ( buffer = bytes.NewBuffer(nil) encoder = logfmt.NewEncoder(buffer) ) for _, field := range logFields { if err := encoder.EncodeKeyval(field.Key(), field.Value()); err != nil { encoder.EncodeKeyval(field.Key(), err.Error()) } } ret...
[ "func", "MaterializeWithLogFmt", "(", "logFields", "[", "]", "log", ".", "Field", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "var", "(", "buffer", "=", "bytes", ".", "NewBuffer", "(", "nil", ")", "\n", "encoder", "=", "logfmt", ".", "NewEnco...
// MaterializeWithLogFmt converts log Fields into LogFmt string
[ "MaterializeWithLogFmt", "converts", "log", "Fields", "into", "LogFmt", "string" ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/log-materializers.go#L48-L59
22,575
openzipkin-contrib/zipkin-go-opentracing
log-materializers.go
StrictZipkinMaterializer
func StrictZipkinMaterializer(logFields []log.Field) ([]byte, error) { for _, field := range logFields { if field.Key() == "event" { return []byte(fmt.Sprintf("%+v", field.Value())), nil } } return nil, errEventLogNotFound }
go
func StrictZipkinMaterializer(logFields []log.Field) ([]byte, error) { for _, field := range logFields { if field.Key() == "event" { return []byte(fmt.Sprintf("%+v", field.Value())), nil } } return nil, errEventLogNotFound }
[ "func", "StrictZipkinMaterializer", "(", "logFields", "[", "]", "log", ".", "Field", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "for", "_", ",", "field", ":=", "range", "logFields", "{", "if", "field", ".", "Key", "(", ")", "==", "\"", "\"...
// StrictZipkinMaterializer will only record a log.Field of type "event".
[ "StrictZipkinMaterializer", "will", "only", "record", "a", "log", ".", "Field", "of", "type", "event", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/log-materializers.go#L62-L69
22,576
openzipkin-contrib/zipkin-go-opentracing
recorder.go
GetSpans
func (r *InMemorySpanRecorder) GetSpans() []RawSpan { r.RLock() defer r.RUnlock() spans := make([]RawSpan, len(r.spans)) copy(spans, r.spans) return spans }
go
func (r *InMemorySpanRecorder) GetSpans() []RawSpan { r.RLock() defer r.RUnlock() spans := make([]RawSpan, len(r.spans)) copy(spans, r.spans) return spans }
[ "func", "(", "r", "*", "InMemorySpanRecorder", ")", "GetSpans", "(", ")", "[", "]", "RawSpan", "{", "r", ".", "RLock", "(", ")", "\n", "defer", "r", ".", "RUnlock", "(", ")", "\n", "spans", ":=", "make", "(", "[", "]", "RawSpan", ",", "len", "(",...
// GetSpans returns a copy of the array of spans accumulated so far.
[ "GetSpans", "returns", "a", "copy", "of", "the", "array", "of", "spans", "accumulated", "so", "far", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/recorder.go#L34-L40
22,577
openzipkin-contrib/zipkin-go-opentracing
recorder.go
GetSampledSpans
func (r *InMemorySpanRecorder) GetSampledSpans() []RawSpan { r.RLock() defer r.RUnlock() spans := make([]RawSpan, 0, len(r.spans)) for _, span := range r.spans { if span.Context.Sampled { spans = append(spans, span) } } return spans }
go
func (r *InMemorySpanRecorder) GetSampledSpans() []RawSpan { r.RLock() defer r.RUnlock() spans := make([]RawSpan, 0, len(r.spans)) for _, span := range r.spans { if span.Context.Sampled { spans = append(spans, span) } } return spans }
[ "func", "(", "r", "*", "InMemorySpanRecorder", ")", "GetSampledSpans", "(", ")", "[", "]", "RawSpan", "{", "r", ".", "RLock", "(", ")", "\n", "defer", "r", ".", "RUnlock", "(", ")", "\n", "spans", ":=", "make", "(", "[", "]", "RawSpan", ",", "0", ...
// GetSampledSpans returns a slice of spans accumulated so far which were sampled.
[ "GetSampledSpans", "returns", "a", "slice", "of", "spans", "accumulated", "so", "far", "which", "were", "sampled", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/recorder.go#L43-L53
22,578
openzipkin-contrib/zipkin-go-opentracing
recorder.go
Reset
func (r *InMemorySpanRecorder) Reset() { r.Lock() defer r.Unlock() r.spans = nil }
go
func (r *InMemorySpanRecorder) Reset() { r.Lock() defer r.Unlock() r.spans = nil }
[ "func", "(", "r", "*", "InMemorySpanRecorder", ")", "Reset", "(", ")", "{", "r", ".", "Lock", "(", ")", "\n", "defer", "r", ".", "Unlock", "(", ")", "\n", "r", ".", "spans", "=", "nil", "\n", "}" ]
// Reset clears the internal array of spans.
[ "Reset", "clears", "the", "internal", "array", "of", "spans", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/recorder.go#L56-L60
22,579
openzipkin-contrib/zipkin-go-opentracing
collector.go
Close
func (c MultiCollector) Close() error { return c.aggregateErrors(func(coll Collector) error { return coll.Close() }) }
go
func (c MultiCollector) Close() error { return c.aggregateErrors(func(coll Collector) error { return coll.Close() }) }
[ "func", "(", "c", "MultiCollector", ")", "Close", "(", ")", "error", "{", "return", "c", ".", "aggregateErrors", "(", "func", "(", "coll", "Collector", ")", "error", "{", "return", "coll", ".", "Close", "(", ")", "}", ")", "\n", "}" ]
// Close implements Collector.
[ "Close", "implements", "Collector", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/collector.go#L34-L36
22,580
openzipkin-contrib/zipkin-go-opentracing
sample.go
ModuloSampler
func ModuloSampler(mod uint64) Sampler { if mod < 2 { return alwaysSample } return func(id uint64) bool { return (id % mod) == 0 } }
go
func ModuloSampler(mod uint64) Sampler { if mod < 2 { return alwaysSample } return func(id uint64) bool { return (id % mod) == 0 } }
[ "func", "ModuloSampler", "(", "mod", "uint64", ")", "Sampler", "{", "if", "mod", "<", "2", "{", "return", "alwaysSample", "\n", "}", "\n", "return", "func", "(", "id", "uint64", ")", "bool", "{", "return", "(", "id", "%", "mod", ")", "==", "0", "\n...
// ModuloSampler provides a typical OpenTracing type Sampler.
[ "ModuloSampler", "provides", "a", "typical", "OpenTracing", "type", "Sampler", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/sample.go#L19-L26
22,581
openzipkin-contrib/zipkin-go-opentracing
zipkin-endpoint.go
makeEndpoint
func makeEndpoint(hostport, serviceName string) (ep *zipkincore.Endpoint) { ep = zipkincore.NewEndpoint() // Set the ServiceName ep.ServiceName = serviceName if strings.IndexByte(hostport, ':') < 0 { // "<host>" becomes "<host>:0" hostport = hostport + ":0" } // try to parse provided "<host>:<port>" host,...
go
func makeEndpoint(hostport, serviceName string) (ep *zipkincore.Endpoint) { ep = zipkincore.NewEndpoint() // Set the ServiceName ep.ServiceName = serviceName if strings.IndexByte(hostport, ':') < 0 { // "<host>" becomes "<host>:0" hostport = hostport + ":0" } // try to parse provided "<host>:<port>" host,...
[ "func", "makeEndpoint", "(", "hostport", ",", "serviceName", "string", ")", "(", "ep", "*", "zipkincore", ".", "Endpoint", ")", "{", "ep", "=", "zipkincore", ".", "NewEndpoint", "(", ")", "\n\n", "// Set the ServiceName", "ep", ".", "ServiceName", "=", "serv...
// makeEndpoint takes the hostport and service name that represent this Zipkin // service, and returns an endpoint that's embedded into the Zipkin core Span // type. It will return a nil endpoint if the input parameters are malformed.
[ "makeEndpoint", "takes", "the", "hostport", "and", "service", "name", "that", "represent", "this", "Zipkin", "service", "and", "returns", "an", "endpoint", "that", "s", "embedded", "into", "the", "Zipkin", "core", "Span", "type", ".", "It", "will", "return", ...
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/zipkin-endpoint.go#L15-L72
22,582
openzipkin-contrib/zipkin-go-opentracing
examples/cli_with_2_services/svc2/httpserver.go
NewHTTPHandler
func NewHTTPHandler(tracer opentracing.Tracer, service Service) http.Handler { // Create our HTTP Service. svc := &httpService{service: service} // Create the mux. mux := http.NewServeMux() // Create the Sum handler. var sumHandler http.Handler sumHandler = http.HandlerFunc(svc.sumHandler) // Wrap the Sum ha...
go
func NewHTTPHandler(tracer opentracing.Tracer, service Service) http.Handler { // Create our HTTP Service. svc := &httpService{service: service} // Create the mux. mux := http.NewServeMux() // Create the Sum handler. var sumHandler http.Handler sumHandler = http.HandlerFunc(svc.sumHandler) // Wrap the Sum ha...
[ "func", "NewHTTPHandler", "(", "tracer", "opentracing", ".", "Tracer", ",", "service", "Service", ")", "http", ".", "Handler", "{", "// Create our HTTP Service.", "svc", ":=", "&", "httpService", "{", "service", ":", "service", "}", "\n\n", "// Create the mux.", ...
// NewHTTPHandler returns a new HTTP handler our svc2.
[ "NewHTTPHandler", "returns", "a", "new", "HTTP", "handler", "our", "svc2", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/examples/cli_with_2_services/svc2/httpserver.go#L44-L63
22,583
openzipkin-contrib/zipkin-go-opentracing
types/traceid.go
ToHex
func (t TraceID) ToHex() string { if t.High == 0 { return fmt.Sprintf("%016x", t.Low) } return fmt.Sprintf("%016x%016x", t.High, t.Low) }
go
func (t TraceID) ToHex() string { if t.High == 0 { return fmt.Sprintf("%016x", t.Low) } return fmt.Sprintf("%016x%016x", t.High, t.Low) }
[ "func", "(", "t", "TraceID", ")", "ToHex", "(", ")", "string", "{", "if", "t", ".", "High", "==", "0", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "t", ".", "Low", ")", "\n", "}", "\n", "return", "fmt", ".", "Sprintf", "(", "\...
// ToHex outputs the 128-bit traceID as hex string.
[ "ToHex", "outputs", "the", "128", "-", "bit", "traceID", "as", "hex", "string", "." ]
f0f479ad013a498e4cbfb369414e5d3880903779
https://github.com/openzipkin-contrib/zipkin-go-opentracing/blob/f0f479ad013a498e4cbfb369414e5d3880903779/types/traceid.go#L28-L33
22,584
schollz/progressbar
progressbar.go
OptionSetWidth
func OptionSetWidth(s int) Option { return func(p *ProgressBar) { p.config.width = s } }
go
func OptionSetWidth(s int) Option { return func(p *ProgressBar) { p.config.width = s } }
[ "func", "OptionSetWidth", "(", "s", "int", ")", "Option", "{", "return", "func", "(", "p", "*", "ProgressBar", ")", "{", "p", ".", "config", ".", "width", "=", "s", "\n", "}", "\n", "}" ]
// OptionSetWidth sets the width of the bar
[ "OptionSetWidth", "sets", "the", "width", "of", "the", "bar" ]
8607ead5339fbde7efa7dafff8e2d4b5e3cd046b
https://github.com/schollz/progressbar/blob/8607ead5339fbde7efa7dafff8e2d4b5e3cd046b/progressbar.go#L86-L90
22,585
schollz/progressbar
progressbar.go
OptionSetTheme
func OptionSetTheme(t Theme) Option { return func(p *ProgressBar) { p.config.theme = t } }
go
func OptionSetTheme(t Theme) Option { return func(p *ProgressBar) { p.config.theme = t } }
[ "func", "OptionSetTheme", "(", "t", "Theme", ")", "Option", "{", "return", "func", "(", "p", "*", "ProgressBar", ")", "{", "p", ".", "config", ".", "theme", "=", "t", "\n", "}", "\n", "}" ]
// OptionSetTheme sets the elements the bar is constructed of
[ "OptionSetTheme", "sets", "the", "elements", "the", "bar", "is", "constructed", "of" ]
8607ead5339fbde7efa7dafff8e2d4b5e3cd046b
https://github.com/schollz/progressbar/blob/8607ead5339fbde7efa7dafff8e2d4b5e3cd046b/progressbar.go#L93-L97
22,586
schollz/progressbar
progressbar.go
OptionSetRenderBlankState
func OptionSetRenderBlankState(r bool) Option { return func(p *ProgressBar) { p.config.renderWithBlankState = r } }
go
func OptionSetRenderBlankState(r bool) Option { return func(p *ProgressBar) { p.config.renderWithBlankState = r } }
[ "func", "OptionSetRenderBlankState", "(", "r", "bool", ")", "Option", "{", "return", "func", "(", "p", "*", "ProgressBar", ")", "{", "p", ".", "config", ".", "renderWithBlankState", "=", "r", "\n", "}", "\n", "}" ]
// OptionSetRenderBlankState sets whether or not to render a 0% bar on construction
[ "OptionSetRenderBlankState", "sets", "whether", "or", "not", "to", "render", "a", "0%", "bar", "on", "construction" ]
8607ead5339fbde7efa7dafff8e2d4b5e3cd046b
https://github.com/schollz/progressbar/blob/8607ead5339fbde7efa7dafff8e2d4b5e3cd046b/progressbar.go#L107-L111
22,587
schollz/progressbar
progressbar.go
OptionSetDescription
func OptionSetDescription(description string) Option { return func(p *ProgressBar) { p.config.description = description } }
go
func OptionSetDescription(description string) Option { return func(p *ProgressBar) { p.config.description = description } }
[ "func", "OptionSetDescription", "(", "description", "string", ")", "Option", "{", "return", "func", "(", "p", "*", "ProgressBar", ")", "{", "p", ".", "config", ".", "description", "=", "description", "\n", "}", "\n", "}" ]
// OptionSetDescription sets the description of the bar to render in front of it
[ "OptionSetDescription", "sets", "the", "description", "of", "the", "bar", "to", "render", "in", "front", "of", "it" ]
8607ead5339fbde7efa7dafff8e2d4b5e3cd046b
https://github.com/schollz/progressbar/blob/8607ead5339fbde7efa7dafff8e2d4b5e3cd046b/progressbar.go#L114-L118
22,588
schollz/progressbar
progressbar.go
OptionThrottle
func OptionThrottle(duration time.Duration) Option { return func(p *ProgressBar) { p.config.throttleDuration = duration } }
go
func OptionThrottle(duration time.Duration) Option { return func(p *ProgressBar) { p.config.throttleDuration = duration } }
[ "func", "OptionThrottle", "(", "duration", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "p", "*", "ProgressBar", ")", "{", "p", ".", "config", ".", "throttleDuration", "=", "duration", "\n", "}", "\n", "}" ]
// OptionThrottle will wait the specified duration before updating again. The default // duration is 0 seconds.
[ "OptionThrottle", "will", "wait", "the", "specified", "duration", "before", "updating", "again", ".", "The", "default", "duration", "is", "0", "seconds", "." ]
8607ead5339fbde7efa7dafff8e2d4b5e3cd046b
https://github.com/schollz/progressbar/blob/8607ead5339fbde7efa7dafff8e2d4b5e3cd046b/progressbar.go#L156-L160
22,589
schollz/progressbar
progressbar.go
NewOptions
func NewOptions(max int, options ...Option) *ProgressBar { return NewOptions64(int64(max), options...) }
go
func NewOptions(max int, options ...Option) *ProgressBar { return NewOptions64(int64(max), options...) }
[ "func", "NewOptions", "(", "max", "int", ",", "options", "...", "Option", ")", "*", "ProgressBar", "{", "return", "NewOptions64", "(", "int64", "(", "max", ")", ",", "options", "...", ")", "\n", "}" ]
// NewOptions constructs a new instance of ProgressBar, with any options you specify
[ "NewOptions", "constructs", "a", "new", "instance", "of", "ProgressBar", "with", "any", "options", "you", "specify" ]
8607ead5339fbde7efa7dafff8e2d4b5e3cd046b
https://github.com/schollz/progressbar/blob/8607ead5339fbde7efa7dafff8e2d4b5e3cd046b/progressbar.go#L178-L180
22,590
schollz/progressbar
progressbar.go
NewOptions64
func NewOptions64(max int64, options ...Option) *ProgressBar { b := ProgressBar{ state: getBlankState(), config: config{ writer: os.Stdout, theme: defaultTheme, width: 40, max: max, throttleDuration: 0 * time.Nanosecond, }, } for _, o := range option...
go
func NewOptions64(max int64, options ...Option) *ProgressBar { b := ProgressBar{ state: getBlankState(), config: config{ writer: os.Stdout, theme: defaultTheme, width: 40, max: max, throttleDuration: 0 * time.Nanosecond, }, } for _, o := range option...
[ "func", "NewOptions64", "(", "max", "int64", ",", "options", "...", "Option", ")", "*", "ProgressBar", "{", "b", ":=", "ProgressBar", "{", "state", ":", "getBlankState", "(", ")", ",", "config", ":", "config", "{", "writer", ":", "os", ".", "Stdout", "...
// NewOptions64 constructs a new instance of ProgressBar, with any options you specify
[ "NewOptions64", "constructs", "a", "new", "instance", "of", "ProgressBar", "with", "any", "options", "you", "specify" ]
8607ead5339fbde7efa7dafff8e2d4b5e3cd046b
https://github.com/schollz/progressbar/blob/8607ead5339fbde7efa7dafff8e2d4b5e3cd046b/progressbar.go#L183-L204
22,591
schollz/progressbar
progressbar.go
Reset
func (p *ProgressBar) Reset() { p.lock.Lock() defer p.lock.Unlock() p.state = getBlankState() }
go
func (p *ProgressBar) Reset() { p.lock.Lock() defer p.lock.Unlock() p.state = getBlankState() }
[ "func", "(", "p", "*", "ProgressBar", ")", "Reset", "(", ")", "{", "p", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "lock", ".", "Unlock", "(", ")", "\n\n", "p", ".", "state", "=", "getBlankState", "(", ")", "\n", "}" ]
// Reset will reset the clock that is used // to calculate current time and the time left.
[ "Reset", "will", "reset", "the", "clock", "that", "is", "used", "to", "calculate", "current", "time", "and", "the", "time", "left", "." ]
8607ead5339fbde7efa7dafff8e2d4b5e3cd046b
https://github.com/schollz/progressbar/blob/8607ead5339fbde7efa7dafff8e2d4b5e3cd046b/progressbar.go#L227-L232
22,592
schollz/progressbar
progressbar.go
Finish
func (p *ProgressBar) Finish() error { p.lock.Lock() p.state.currentNum = p.config.max p.lock.Unlock() return p.Add(0) }
go
func (p *ProgressBar) Finish() error { p.lock.Lock() p.state.currentNum = p.config.max p.lock.Unlock() return p.Add(0) }
[ "func", "(", "p", "*", "ProgressBar", ")", "Finish", "(", ")", "error", "{", "p", ".", "lock", ".", "Lock", "(", ")", "\n", "p", ".", "state", ".", "currentNum", "=", "p", ".", "config", ".", "max", "\n", "p", ".", "lock", ".", "Unlock", "(", ...
// Finish will fill the bar to full
[ "Finish", "will", "fill", "the", "bar", "to", "full" ]
8607ead5339fbde7efa7dafff8e2d4b5e3cd046b
https://github.com/schollz/progressbar/blob/8607ead5339fbde7efa7dafff8e2d4b5e3cd046b/progressbar.go#L235-L240
22,593
schollz/progressbar
progressbar.go
render
func (p *ProgressBar) render() error { // make sure that the rendering is not happening too quickly // but always show if the currentNum reaches the max if time.Since(p.state.lastShown).Nanoseconds() < p.config.throttleDuration.Nanoseconds() && p.state.currentNum < p.config.max { return nil } // first, clear ...
go
func (p *ProgressBar) render() error { // make sure that the rendering is not happening too quickly // but always show if the currentNum reaches the max if time.Since(p.state.lastShown).Nanoseconds() < p.config.throttleDuration.Nanoseconds() && p.state.currentNum < p.config.max { return nil } // first, clear ...
[ "func", "(", "p", "*", "ProgressBar", ")", "render", "(", ")", "error", "{", "// make sure that the rendering is not happening too quickly", "// but always show if the currentNum reaches the max", "if", "time", ".", "Since", "(", "p", ".", "state", ".", "lastShown", ")"...
// render renders the progress bar, updating the maximum // rendered line width. this function is not thread-safe, // so it must be called with an acquired lock.
[ "render", "renders", "the", "progress", "bar", "updating", "the", "maximum", "rendered", "line", "width", ".", "this", "function", "is", "not", "thread", "-", "safe", "so", "it", "must", "be", "called", "with", "an", "acquired", "lock", "." ]
8607ead5339fbde7efa7dafff8e2d4b5e3cd046b
https://github.com/schollz/progressbar/blob/8607ead5339fbde7efa7dafff8e2d4b5e3cd046b/progressbar.go#L297-L339
22,594
schollz/progressbar
progressbar.go
State
func (p *ProgressBar) State() State { p.lock.Lock() defer p.lock.Unlock() s := State{} s.CurrentPercent = float64(p.state.currentNum) / float64(p.config.max) s.CurrentBytes = p.state.currentBytes s.MaxBytes = p.config.maxBytes s.SecondsSince = time.Since(p.state.startTime).Seconds() if p.state.currentNum > 0 { ...
go
func (p *ProgressBar) State() State { p.lock.Lock() defer p.lock.Unlock() s := State{} s.CurrentPercent = float64(p.state.currentNum) / float64(p.config.max) s.CurrentBytes = p.state.currentBytes s.MaxBytes = p.config.maxBytes s.SecondsSince = time.Since(p.state.startTime).Seconds() if p.state.currentNum > 0 { ...
[ "func", "(", "p", "*", "ProgressBar", ")", "State", "(", ")", "State", "{", "p", ".", "lock", ".", "Lock", "(", ")", "\n", "defer", "p", ".", "lock", ".", "Unlock", "(", ")", "\n", "s", ":=", "State", "{", "}", "\n", "s", ".", "CurrentPercent",...
// State returns the current state
[ "State", "returns", "the", "current", "state" ]
8607ead5339fbde7efa7dafff8e2d4b5e3cd046b
https://github.com/schollz/progressbar/blob/8607ead5339fbde7efa7dafff8e2d4b5e3cd046b/progressbar.go#L342-L355
22,595
schollz/progressbar
progressbar.go
Close
func (r *Reader) Close() (err error) { if closer, ok := r.Reader.(io.Closer); ok { return closer.Close() } return }
go
func (r *Reader) Close() (err error) { if closer, ok := r.Reader.(io.Closer); ok { return closer.Close() } return }
[ "func", "(", "r", "*", "Reader", ")", "Close", "(", ")", "(", "err", "error", ")", "{", "if", "closer", ",", "ok", ":=", "r", ".", "Reader", ".", "(", "io", ".", "Closer", ")", ";", "ok", "{", "return", "closer", ".", "Close", "(", ")", "\n",...
// Close the reader when it implements io.Closer
[ "Close", "the", "reader", "when", "it", "implements", "io", ".", "Closer" ]
8607ead5339fbde7efa7dafff8e2d4b5e3cd046b
https://github.com/schollz/progressbar/blob/8607ead5339fbde7efa7dafff8e2d4b5e3cd046b/progressbar.go#L467-L472
22,596
RoaringBitmap/roaring
bitmapcontainer.go
clz
func clz(i uint64) int { n := 1 x := uint32(i >> 32) if x == 0 { n += 32 x = uint32(i) } if x>>16 == 0 { n += 16 x = x << 16 } if x>>24 == 0 { n += 8 x = x << 8 } if x>>28 == 0 { n += 4 x = x << 4 } if x>>30 == 0 { n += 2 x = x << 2 } return n - int(x>>31) }
go
func clz(i uint64) int { n := 1 x := uint32(i >> 32) if x == 0 { n += 32 x = uint32(i) } if x>>16 == 0 { n += 16 x = x << 16 } if x>>24 == 0 { n += 8 x = x << 8 } if x>>28 == 0 { n += 4 x = x << 4 } if x>>30 == 0 { n += 2 x = x << 2 } return n - int(x>>31) }
[ "func", "clz", "(", "i", "uint64", ")", "int", "{", "n", ":=", "1", "\n", "x", ":=", "uint32", "(", "i", ">>", "32", ")", "\n", "if", "x", "==", "0", "{", "n", "+=", "32", "\n", "x", "=", "uint32", "(", "i", ")", "\n", "}", "\n", "if", ...
// i should be non-zero
[ "i", "should", "be", "non", "-", "zero" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/bitmapcontainer.go#L62-L86
22,597
RoaringBitmap/roaring
bitmapcontainer.go
iremove
func (bc *bitmapContainer) iremove(i uint16) bool { if bc.contains(i) { bc.cardinality-- bc.bitmap[i/64] &^= (uint64(1) << (i % 64)) return true } return false }
go
func (bc *bitmapContainer) iremove(i uint16) bool { if bc.contains(i) { bc.cardinality-- bc.bitmap[i/64] &^= (uint64(1) << (i % 64)) return true } return false }
[ "func", "(", "bc", "*", "bitmapContainer", ")", "iremove", "(", "i", "uint16", ")", "bool", "{", "if", "bc", ".", "contains", "(", "i", ")", "{", "bc", ".", "cardinality", "--", "\n", "bc", ".", "bitmap", "[", "i", "/", "64", "]", "&^=", "(", "...
// iremove returns true if i was found.
[ "iremove", "returns", "true", "if", "i", "was", "found", "." ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/bitmapcontainer.go#L288-L295
22,598
RoaringBitmap/roaring
bitmapcontainer.go
iaddRange
func (bc *bitmapContainer) iaddRange(firstOfRange, lastOfRange int) container { bc.cardinality += setBitmapRangeAndCardinalityChange(bc.bitmap, firstOfRange, lastOfRange) return bc }
go
func (bc *bitmapContainer) iaddRange(firstOfRange, lastOfRange int) container { bc.cardinality += setBitmapRangeAndCardinalityChange(bc.bitmap, firstOfRange, lastOfRange) return bc }
[ "func", "(", "bc", "*", "bitmapContainer", ")", "iaddRange", "(", "firstOfRange", ",", "lastOfRange", "int", ")", "container", "{", "bc", ".", "cardinality", "+=", "setBitmapRangeAndCardinalityChange", "(", "bc", ".", "bitmap", ",", "firstOfRange", ",", "lastOfR...
// add all values in range [firstOfRange,lastOfRange)
[ "add", "all", "values", "in", "range", "[", "firstOfRange", "lastOfRange", ")" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/bitmapcontainer.go#L312-L315
22,599
RoaringBitmap/roaring
bitmapcontainer.go
iremoveRange
func (bc *bitmapContainer) iremoveRange(firstOfRange, lastOfRange int) container { bc.cardinality += resetBitmapRangeAndCardinalityChange(bc.bitmap, firstOfRange, lastOfRange) if bc.getCardinality() <= arrayDefaultMaxSize { return bc.toArrayContainer() } return bc }
go
func (bc *bitmapContainer) iremoveRange(firstOfRange, lastOfRange int) container { bc.cardinality += resetBitmapRangeAndCardinalityChange(bc.bitmap, firstOfRange, lastOfRange) if bc.getCardinality() <= arrayDefaultMaxSize { return bc.toArrayContainer() } return bc }
[ "func", "(", "bc", "*", "bitmapContainer", ")", "iremoveRange", "(", "firstOfRange", ",", "lastOfRange", "int", ")", "container", "{", "bc", ".", "cardinality", "+=", "resetBitmapRangeAndCardinalityChange", "(", "bc", ".", "bitmap", ",", "firstOfRange", ",", "la...
// remove all values in range [firstOfRange,lastOfRange)
[ "remove", "all", "values", "in", "range", "[", "firstOfRange", "lastOfRange", ")" ]
8d778e47dd84f169ef4436abb474b0e0101a6dae
https://github.com/RoaringBitmap/roaring/blob/8d778e47dd84f169ef4436abb474b0e0101a6dae/bitmapcontainer.go#L318-L324