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
166,200
hashicorp/serf
serf/serf.go
checkQueueDepth
func (s *Serf) checkQueueDepth(name string, queue *memberlist.TransmitLimitedQueue) { for { select { case <-time.After(s.config.QueueCheckInterval): numq := queue.NumQueued() metrics.AddSample([]string{"serf", "queue", name}, float32(numq)) if numq >= s.config.QueueDepthWarning { s.logger.Printf("[WAR...
go
func (s *Serf) checkQueueDepth(name string, queue *memberlist.TransmitLimitedQueue) { for { select { case <-time.After(s.config.QueueCheckInterval): numq := queue.NumQueued() metrics.AddSample([]string{"serf", "queue", name}, float32(numq)) if numq >= s.config.QueueDepthWarning { s.logger.Printf("[WAR...
[ "func", "(", "s", "*", "Serf", ")", "checkQueueDepth", "(", "name", "string", ",", "queue", "*", "memberlist", ".", "TransmitLimitedQueue", ")", "{", "for", "{", "select", "{", "case", "<-", "time", ".", "After", "(", "s", ".", "config", ".", "QueueChe...
// checkQueueDepth periodically checks the size of a queue to see if // it is too large
[ "checkQueueDepth", "periodically", "checks", "the", "size", "of", "a", "queue", "to", "see", "if", "it", "is", "too", "large" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/serf.go#L1576-L1594
166,201
hashicorp/serf
serf/serf.go
removeOldMember
func removeOldMember(old []*memberState, name string) []*memberState { for i, m := range old { if m.Name == name { n := len(old) old[i], old[n-1] = old[n-1], nil return old[:n-1] } } return old }
go
func removeOldMember(old []*memberState, name string) []*memberState { for i, m := range old { if m.Name == name { n := len(old) old[i], old[n-1] = old[n-1], nil return old[:n-1] } } return old }
[ "func", "removeOldMember", "(", "old", "[", "]", "*", "memberState", ",", "name", "string", ")", "[", "]", "*", "memberState", "{", "for", "i", ",", "m", ":=", "range", "old", "{", "if", "m", ".", "Name", "==", "name", "{", "n", ":=", "len", "(",...
// removeOldMember is used to remove an old member from a list of old // members.
[ "removeOldMember", "is", "used", "to", "remove", "an", "old", "member", "from", "a", "list", "of", "old", "members", "." ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/serf.go#L1598-L1608
166,202
hashicorp/serf
serf/serf.go
reapIntents
func reapIntents(intents map[string]nodeIntent, now time.Time, timeout time.Duration) { for node, intent := range intents { if now.Sub(intent.WallTime) > timeout { delete(intents, node) } } }
go
func reapIntents(intents map[string]nodeIntent, now time.Time, timeout time.Duration) { for node, intent := range intents { if now.Sub(intent.WallTime) > timeout { delete(intents, node) } } }
[ "func", "reapIntents", "(", "intents", "map", "[", "string", "]", "nodeIntent", ",", "now", "time", ".", "Time", ",", "timeout", "time", ".", "Duration", ")", "{", "for", "node", ",", "intent", ":=", "range", "intents", "{", "if", "now", ".", "Sub", ...
// reapIntents clears out any intents that are older than the timeout. Make sure // the memberLock is held when passing in the Serf instance's recentIntents // member.
[ "reapIntents", "clears", "out", "any", "intents", "that", "are", "older", "than", "the", "timeout", ".", "Make", "sure", "the", "memberLock", "is", "held", "when", "passing", "in", "the", "Serf", "instance", "s", "recentIntents", "member", "." ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/serf.go#L1613-L1619
166,203
hashicorp/serf
serf/serf.go
upsertIntent
func upsertIntent(intents map[string]nodeIntent, node string, itype messageType, ltime LamportTime, stamper func() time.Time) bool { if intent, ok := intents[node]; !ok || ltime > intent.LTime { intents[node] = nodeIntent{ Type: itype, WallTime: stamper(), LTime: ltime, } return true } return...
go
func upsertIntent(intents map[string]nodeIntent, node string, itype messageType, ltime LamportTime, stamper func() time.Time) bool { if intent, ok := intents[node]; !ok || ltime > intent.LTime { intents[node] = nodeIntent{ Type: itype, WallTime: stamper(), LTime: ltime, } return true } return...
[ "func", "upsertIntent", "(", "intents", "map", "[", "string", "]", "nodeIntent", ",", "node", "string", ",", "itype", "messageType", ",", "ltime", "LamportTime", ",", "stamper", "func", "(", ")", "time", ".", "Time", ")", "bool", "{", "if", "intent", ","...
// upsertIntent will update an existing intent with the supplied Lamport time, // or create a new entry. This will return true if a new entry was added. The // stamper is used to capture the wall clock time for expiring these buffered // intents. Make sure the memberLock is held when passing in the Serf instance's // r...
[ "upsertIntent", "will", "update", "an", "existing", "intent", "with", "the", "supplied", "Lamport", "time", "or", "create", "a", "new", "entry", ".", "This", "will", "return", "true", "if", "a", "new", "entry", "was", "added", ".", "The", "stamper", "is", ...
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/serf.go#L1626-L1638
166,204
hashicorp/serf
serf/serf.go
recentIntent
func recentIntent(intents map[string]nodeIntent, node string, itype messageType) (LamportTime, bool) { if intent, ok := intents[node]; ok && intent.Type == itype { return intent.LTime, true } return LamportTime(0), false }
go
func recentIntent(intents map[string]nodeIntent, node string, itype messageType) (LamportTime, bool) { if intent, ok := intents[node]; ok && intent.Type == itype { return intent.LTime, true } return LamportTime(0), false }
[ "func", "recentIntent", "(", "intents", "map", "[", "string", "]", "nodeIntent", ",", "node", "string", ",", "itype", "messageType", ")", "(", "LamportTime", ",", "bool", ")", "{", "if", "intent", ",", "ok", ":=", "intents", "[", "node", "]", ";", "ok"...
// recentIntent checks the recent intent buffer for a matching entry for a given // node, and returns the Lamport time, if an intent is present, indicated by the // returned boolean. Make sure the memberLock is held for read when passing in // the Serf instance's recentIntents member.
[ "recentIntent", "checks", "the", "recent", "intent", "buffer", "for", "a", "matching", "entry", "for", "a", "given", "node", "and", "returns", "the", "Lamport", "time", "if", "an", "intent", "is", "present", "indicated", "by", "the", "returned", "boolean", "...
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/serf.go#L1644-L1650
166,205
hashicorp/serf
serf/serf.go
handleRejoin
func (s *Serf) handleRejoin(previous []*PreviousNode) { for _, prev := range previous { // Do not attempt to join ourself if prev.Name == s.config.NodeName { continue } s.logger.Printf("[INFO] serf: Attempting re-join to previously known node: %s", prev) _, err := s.memberlist.Join([]string{prev.Addr}) ...
go
func (s *Serf) handleRejoin(previous []*PreviousNode) { for _, prev := range previous { // Do not attempt to join ourself if prev.Name == s.config.NodeName { continue } s.logger.Printf("[INFO] serf: Attempting re-join to previously known node: %s", prev) _, err := s.memberlist.Join([]string{prev.Addr}) ...
[ "func", "(", "s", "*", "Serf", ")", "handleRejoin", "(", "previous", "[", "]", "*", "PreviousNode", ")", "{", "for", "_", ",", "prev", ":=", "range", "previous", "{", "// Do not attempt to join ourself", "if", "prev", ".", "Name", "==", "s", ".", "config...
// handleRejoin attempts to reconnect to previously known alive nodes
[ "handleRejoin", "attempts", "to", "reconnect", "to", "previously", "known", "alive", "nodes" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/serf.go#L1653-L1668
166,206
hashicorp/serf
serf/serf.go
encodeTags
func (s *Serf) encodeTags(tags map[string]string) []byte { // Support role-only backwards compatibility if s.ProtocolVersion() < 3 { role := tags["role"] return []byte(role) } // Use a magic byte prefix and msgpack encode the tags var buf bytes.Buffer buf.WriteByte(tagMagicByte) enc := codec.NewEncoder(&buf...
go
func (s *Serf) encodeTags(tags map[string]string) []byte { // Support role-only backwards compatibility if s.ProtocolVersion() < 3 { role := tags["role"] return []byte(role) } // Use a magic byte prefix and msgpack encode the tags var buf bytes.Buffer buf.WriteByte(tagMagicByte) enc := codec.NewEncoder(&buf...
[ "func", "(", "s", "*", "Serf", ")", "encodeTags", "(", "tags", "map", "[", "string", "]", "string", ")", "[", "]", "byte", "{", "// Support role-only backwards compatibility", "if", "s", ".", "ProtocolVersion", "(", ")", "<", "3", "{", "role", ":=", "tag...
// encodeTags is used to encode a tag map
[ "encodeTags", "is", "used", "to", "encode", "a", "tag", "map" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/serf.go#L1671-L1686
166,207
hashicorp/serf
serf/serf.go
Stats
func (s *Serf) Stats() map[string]string { toString := func(v uint64) string { return strconv.FormatUint(v, 10) } s.memberLock.RLock() members := toString(uint64(len(s.members))) failed := toString(uint64(len(s.failedMembers))) left := toString(uint64(len(s.leftMembers))) health_score := toString(uint64(s.memb...
go
func (s *Serf) Stats() map[string]string { toString := func(v uint64) string { return strconv.FormatUint(v, 10) } s.memberLock.RLock() members := toString(uint64(len(s.members))) failed := toString(uint64(len(s.failedMembers))) left := toString(uint64(len(s.leftMembers))) health_score := toString(uint64(s.memb...
[ "func", "(", "s", "*", "Serf", ")", "Stats", "(", ")", "map", "[", "string", "]", "string", "{", "toString", ":=", "func", "(", "v", "uint64", ")", "string", "{", "return", "strconv", ".", "FormatUint", "(", "v", ",", "10", ")", "\n", "}", "\n", ...
// Stats is used to provide operator debugging information
[ "Stats", "is", "used", "to", "provide", "operator", "debugging", "information" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/serf.go#L1708-L1736
166,208
hashicorp/serf
serf/serf.go
writeKeyringFile
func (s *Serf) writeKeyringFile() error { if len(s.config.KeyringFile) == 0 { return nil } keyring := s.config.MemberlistConfig.Keyring keysRaw := keyring.GetKeys() keysEncoded := make([]string, len(keysRaw)) for i, key := range keysRaw { keysEncoded[i] = base64.StdEncoding.EncodeToString(key) } encodedK...
go
func (s *Serf) writeKeyringFile() error { if len(s.config.KeyringFile) == 0 { return nil } keyring := s.config.MemberlistConfig.Keyring keysRaw := keyring.GetKeys() keysEncoded := make([]string, len(keysRaw)) for i, key := range keysRaw { keysEncoded[i] = base64.StdEncoding.EncodeToString(key) } encodedK...
[ "func", "(", "s", "*", "Serf", ")", "writeKeyringFile", "(", ")", "error", "{", "if", "len", "(", "s", ".", "config", ".", "KeyringFile", ")", "==", "0", "{", "return", "nil", "\n", "}", "\n\n", "keyring", ":=", "s", ".", "config", ".", "Memberlist...
// WriteKeyringFile will serialize the current keyring and save it to a file.
[ "WriteKeyringFile", "will", "serialize", "the", "current", "keyring", "and", "save", "it", "to", "a", "file", "." ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/serf.go#L1739-L1764
166,209
hashicorp/serf
serf/serf.go
GetCoordinate
func (s *Serf) GetCoordinate() (*coordinate.Coordinate, error) { if !s.config.DisableCoordinates { return s.coordClient.GetCoordinate(), nil } return nil, fmt.Errorf("Coordinates are disabled") }
go
func (s *Serf) GetCoordinate() (*coordinate.Coordinate, error) { if !s.config.DisableCoordinates { return s.coordClient.GetCoordinate(), nil } return nil, fmt.Errorf("Coordinates are disabled") }
[ "func", "(", "s", "*", "Serf", ")", "GetCoordinate", "(", ")", "(", "*", "coordinate", ".", "Coordinate", ",", "error", ")", "{", "if", "!", "s", ".", "config", ".", "DisableCoordinates", "{", "return", "s", ".", "coordClient", ".", "GetCoordinate", "(...
// GetCoordinate returns the network coordinate of the local node.
[ "GetCoordinate", "returns", "the", "network", "coordinate", "of", "the", "local", "node", "." ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/serf.go#L1767-L1773
166,210
hashicorp/serf
serf/serf.go
GetCachedCoordinate
func (s *Serf) GetCachedCoordinate(name string) (coord *coordinate.Coordinate, ok bool) { if !s.config.DisableCoordinates { s.coordCacheLock.RLock() defer s.coordCacheLock.RUnlock() if coord, ok = s.coordCache[name]; ok { return coord, true } return nil, false } return nil, false }
go
func (s *Serf) GetCachedCoordinate(name string) (coord *coordinate.Coordinate, ok bool) { if !s.config.DisableCoordinates { s.coordCacheLock.RLock() defer s.coordCacheLock.RUnlock() if coord, ok = s.coordCache[name]; ok { return coord, true } return nil, false } return nil, false }
[ "func", "(", "s", "*", "Serf", ")", "GetCachedCoordinate", "(", "name", "string", ")", "(", "coord", "*", "coordinate", ".", "Coordinate", ",", "ok", "bool", ")", "{", "if", "!", "s", ".", "config", ".", "DisableCoordinates", "{", "s", ".", "coordCache...
// GetCachedCoordinate returns the network coordinate for the node with the given // name. This will only be valid if DisableCoordinates is set to false.
[ "GetCachedCoordinate", "returns", "the", "network", "coordinate", "for", "the", "node", "with", "the", "given", "name", ".", "This", "will", "only", "be", "valid", "if", "DisableCoordinates", "is", "set", "to", "false", "." ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/serf.go#L1777-L1789
166,211
hashicorp/serf
serf/serf.go
NumNodes
func (s *Serf) NumNodes() (numNodes int) { s.memberLock.RLock() numNodes = len(s.members) s.memberLock.RUnlock() return numNodes }
go
func (s *Serf) NumNodes() (numNodes int) { s.memberLock.RLock() numNodes = len(s.members) s.memberLock.RUnlock() return numNodes }
[ "func", "(", "s", "*", "Serf", ")", "NumNodes", "(", ")", "(", "numNodes", "int", ")", "{", "s", ".", "memberLock", ".", "RLock", "(", ")", "\n", "numNodes", "=", "len", "(", "s", ".", "members", ")", "\n", "s", ".", "memberLock", ".", "RUnlock",...
// NumNodes returns the number of nodes in the serf cluster, regardless of // their health or status.
[ "NumNodes", "returns", "the", "number", "of", "nodes", "in", "the", "serf", "cluster", "regardless", "of", "their", "health", "or", "status", "." ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/serf.go#L1793-L1799
166,212
hashicorp/serf
cmd/serf/command/agent/ipc_query_response_stream.go
Stream
func (qs *queryResponseStream) Stream(resp *serf.QueryResponse) { // Setup a timer for the query ending remaining := resp.Deadline().Sub(time.Now()) done := time.After(remaining) ackCh := resp.AckCh() respCh := resp.ResponseCh() for { select { case a := <-ackCh: if err := qs.sendAck(a); err != nil { q...
go
func (qs *queryResponseStream) Stream(resp *serf.QueryResponse) { // Setup a timer for the query ending remaining := resp.Deadline().Sub(time.Now()) done := time.After(remaining) ackCh := resp.AckCh() respCh := resp.ResponseCh() for { select { case a := <-ackCh: if err := qs.sendAck(a); err != nil { q...
[ "func", "(", "qs", "*", "queryResponseStream", ")", "Stream", "(", "resp", "*", "serf", ".", "QueryResponse", ")", "{", "// Setup a timer for the query ending", "remaining", ":=", "resp", ".", "Deadline", "(", ")", ".", "Sub", "(", "time", ".", "Now", "(", ...
// Stream is a long running routine used to stream the results of a query back to a client
[ "Stream", "is", "a", "long", "running", "routine", "used", "to", "stream", "the", "results", "of", "a", "query", "back", "to", "a", "client" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/cmd/serf/command/agent/ipc_query_response_stream.go#L27-L53
166,213
hashicorp/serf
cmd/serf/command/agent/ipc_query_response_stream.go
sendAck
func (qs *queryResponseStream) sendAck(from string) error { header := responseHeader{ Seq: qs.seq, Error: "", } rec := queryRecord{ Type: queryRecordAck, From: from, } return qs.client.Send(&header, &rec) }
go
func (qs *queryResponseStream) sendAck(from string) error { header := responseHeader{ Seq: qs.seq, Error: "", } rec := queryRecord{ Type: queryRecordAck, From: from, } return qs.client.Send(&header, &rec) }
[ "func", "(", "qs", "*", "queryResponseStream", ")", "sendAck", "(", "from", "string", ")", "error", "{", "header", ":=", "responseHeader", "{", "Seq", ":", "qs", ".", "seq", ",", "Error", ":", "\"", "\"", ",", "}", "\n", "rec", ":=", "queryRecord", "...
// sendAck is used to send a single ack
[ "sendAck", "is", "used", "to", "send", "a", "single", "ack" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/cmd/serf/command/agent/ipc_query_response_stream.go#L56-L66
166,214
hashicorp/serf
cmd/serf/command/agent/ipc_query_response_stream.go
sendResponse
func (qs *queryResponseStream) sendResponse(from string, payload []byte) error { header := responseHeader{ Seq: qs.seq, Error: "", } rec := queryRecord{ Type: queryRecordResponse, From: from, Payload: payload, } return qs.client.Send(&header, &rec) }
go
func (qs *queryResponseStream) sendResponse(from string, payload []byte) error { header := responseHeader{ Seq: qs.seq, Error: "", } rec := queryRecord{ Type: queryRecordResponse, From: from, Payload: payload, } return qs.client.Send(&header, &rec) }
[ "func", "(", "qs", "*", "queryResponseStream", ")", "sendResponse", "(", "from", "string", ",", "payload", "[", "]", "byte", ")", "error", "{", "header", ":=", "responseHeader", "{", "Seq", ":", "qs", ".", "seq", ",", "Error", ":", "\"", "\"", ",", "...
// sendResponse is used to send a single response
[ "sendResponse", "is", "used", "to", "send", "a", "single", "response" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/cmd/serf/command/agent/ipc_query_response_stream.go#L69-L80
166,215
hashicorp/serf
cmd/serf/command/agent/ipc_query_response_stream.go
sendDone
func (qs *queryResponseStream) sendDone() error { header := responseHeader{ Seq: qs.seq, Error: "", } rec := queryRecord{ Type: queryRecordDone, } return qs.client.Send(&header, &rec) }
go
func (qs *queryResponseStream) sendDone() error { header := responseHeader{ Seq: qs.seq, Error: "", } rec := queryRecord{ Type: queryRecordDone, } return qs.client.Send(&header, &rec) }
[ "func", "(", "qs", "*", "queryResponseStream", ")", "sendDone", "(", ")", "error", "{", "header", ":=", "responseHeader", "{", "Seq", ":", "qs", ".", "seq", ",", "Error", ":", "\"", "\"", ",", "}", "\n", "rec", ":=", "queryRecord", "{", "Type", ":", ...
// sendDone is used to signal the end
[ "sendDone", "is", "used", "to", "signal", "the", "end" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/cmd/serf/command/agent/ipc_query_response_stream.go#L83-L92
166,216
hashicorp/serf
client/rpc_client.go
NewRPCClient
func NewRPCClient(addr string) (*RPCClient, error) { conf := Config{Addr: addr} return ClientFromConfig(&conf) }
go
func NewRPCClient(addr string) (*RPCClient, error) { conf := Config{Addr: addr} return ClientFromConfig(&conf) }
[ "func", "NewRPCClient", "(", "addr", "string", ")", "(", "*", "RPCClient", ",", "error", ")", "{", "conf", ":=", "Config", "{", "Addr", ":", "addr", "}", "\n", "return", "ClientFromConfig", "(", "&", "conf", ")", "\n", "}" ]
// NewRPCClient is used to create a new RPC client given the // RPC address of the Serf agent. This will return a client, // or an error if the connection could not be established. // This will use the DefaultTimeout for the client.
[ "NewRPCClient", "is", "used", "to", "create", "a", "new", "RPC", "client", "given", "the", "RPC", "address", "of", "the", "Serf", "agent", ".", "This", "will", "return", "a", "client", "or", "an", "error", "if", "the", "connection", "could", "not", "be",...
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L114-L117
166,217
hashicorp/serf
client/rpc_client.go
ClientFromConfig
func ClientFromConfig(c *Config) (*RPCClient, error) { // Setup the defaults if c.Timeout == 0 { c.Timeout = DefaultTimeout } // Try to dial to serf conn, err := net.DialTimeout("tcp", c.Addr, c.Timeout) if err != nil { return nil, err } // Create the client client := &RPCClient{ seq: 0, timeo...
go
func ClientFromConfig(c *Config) (*RPCClient, error) { // Setup the defaults if c.Timeout == 0 { c.Timeout = DefaultTimeout } // Try to dial to serf conn, err := net.DialTimeout("tcp", c.Addr, c.Timeout) if err != nil { return nil, err } // Create the client client := &RPCClient{ seq: 0, timeo...
[ "func", "ClientFromConfig", "(", "c", "*", "Config", ")", "(", "*", "RPCClient", ",", "error", ")", "{", "// Setup the defaults", "if", "c", ".", "Timeout", "==", "0", "{", "c", ".", "Timeout", "=", "DefaultTimeout", "\n", "}", "\n\n", "// Try to dial to s...
// ClientFromConfig is used to create a new RPC client given the // configuration object. This will return a client, or an error if // the connection could not be established.
[ "ClientFromConfig", "is", "used", "to", "create", "a", "new", "RPC", "client", "given", "the", "configuration", "object", ".", "This", "will", "return", "a", "client", "or", "an", "error", "if", "the", "connection", "could", "not", "be", "established", "." ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L122-L165
166,218
hashicorp/serf
client/rpc_client.go
Close
func (c *RPCClient) Close() error { c.shutdownLock.Lock() defer c.shutdownLock.Unlock() if !c.shutdown { c.shutdown = true close(c.shutdownCh) c.deregisterAll() return c.conn.Close() } return nil }
go
func (c *RPCClient) Close() error { c.shutdownLock.Lock() defer c.shutdownLock.Unlock() if !c.shutdown { c.shutdown = true close(c.shutdownCh) c.deregisterAll() return c.conn.Close() } return nil }
[ "func", "(", "c", "*", "RPCClient", ")", "Close", "(", ")", "error", "{", "c", ".", "shutdownLock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "shutdownLock", ".", "Unlock", "(", ")", "\n\n", "if", "!", "c", ".", "shutdown", "{", "c", ".", ...
// Close is used to free any resources associated with the client
[ "Close", "is", "used", "to", "free", "any", "resources", "associated", "with", "the", "client" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L175-L186
166,219
hashicorp/serf
client/rpc_client.go
ForceLeave
func (c *RPCClient) ForceLeave(node string) error { header := requestHeader{ Command: forceLeaveCommand, Seq: c.getSeq(), } req := forceLeaveRequest{ Node: node, } return c.genericRPC(&header, &req, nil) }
go
func (c *RPCClient) ForceLeave(node string) error { header := requestHeader{ Command: forceLeaveCommand, Seq: c.getSeq(), } req := forceLeaveRequest{ Node: node, } return c.genericRPC(&header, &req, nil) }
[ "func", "(", "c", "*", "RPCClient", ")", "ForceLeave", "(", "node", "string", ")", "error", "{", "header", ":=", "requestHeader", "{", "Command", ":", "forceLeaveCommand", ",", "Seq", ":", "c", ".", "getSeq", "(", ")", ",", "}", "\n", "req", ":=", "f...
// ForceLeave is used to ask the agent to issue a leave command for // a given node
[ "ForceLeave", "is", "used", "to", "ask", "the", "agent", "to", "issue", "a", "leave", "command", "for", "a", "given", "node" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L190-L199
166,220
hashicorp/serf
client/rpc_client.go
Join
func (c *RPCClient) Join(addrs []string, replay bool) (int, error) { header := requestHeader{ Command: joinCommand, Seq: c.getSeq(), } req := joinRequest{ Existing: addrs, Replay: replay, } var resp joinResponse err := c.genericRPC(&header, &req, &resp) return int(resp.Num), err }
go
func (c *RPCClient) Join(addrs []string, replay bool) (int, error) { header := requestHeader{ Command: joinCommand, Seq: c.getSeq(), } req := joinRequest{ Existing: addrs, Replay: replay, } var resp joinResponse err := c.genericRPC(&header, &req, &resp) return int(resp.Num), err }
[ "func", "(", "c", "*", "RPCClient", ")", "Join", "(", "addrs", "[", "]", "string", ",", "replay", "bool", ")", "(", "int", ",", "error", ")", "{", "header", ":=", "requestHeader", "{", "Command", ":", "joinCommand", ",", "Seq", ":", "c", ".", "getS...
// Join is used to instruct the agent to attempt a join
[ "Join", "is", "used", "to", "instruct", "the", "agent", "to", "attempt", "a", "join" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L202-L215
166,221
hashicorp/serf
client/rpc_client.go
Members
func (c *RPCClient) Members() ([]Member, error) { header := requestHeader{ Command: membersCommand, Seq: c.getSeq(), } var resp membersResponse err := c.genericRPC(&header, nil, &resp) return resp.Members, err }
go
func (c *RPCClient) Members() ([]Member, error) { header := requestHeader{ Command: membersCommand, Seq: c.getSeq(), } var resp membersResponse err := c.genericRPC(&header, nil, &resp) return resp.Members, err }
[ "func", "(", "c", "*", "RPCClient", ")", "Members", "(", ")", "(", "[", "]", "Member", ",", "error", ")", "{", "header", ":=", "requestHeader", "{", "Command", ":", "membersCommand", ",", "Seq", ":", "c", ".", "getSeq", "(", ")", ",", "}", "\n", ...
// Members is used to fetch a list of known members
[ "Members", "is", "used", "to", "fetch", "a", "list", "of", "known", "members" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L218-L227
166,222
hashicorp/serf
client/rpc_client.go
MembersFiltered
func (c *RPCClient) MembersFiltered(tags map[string]string, status string, name string) ([]Member, error) { header := requestHeader{ Command: membersFilteredCommand, Seq: c.getSeq(), } req := membersFilteredRequest{ Tags: tags, Status: status, Name: name, } var resp membersResponse err := c.ge...
go
func (c *RPCClient) MembersFiltered(tags map[string]string, status string, name string) ([]Member, error) { header := requestHeader{ Command: membersFilteredCommand, Seq: c.getSeq(), } req := membersFilteredRequest{ Tags: tags, Status: status, Name: name, } var resp membersResponse err := c.ge...
[ "func", "(", "c", "*", "RPCClient", ")", "MembersFiltered", "(", "tags", "map", "[", "string", "]", "string", ",", "status", "string", ",", "name", "string", ")", "(", "[", "]", "Member", ",", "error", ")", "{", "header", ":=", "requestHeader", "{", ...
// MembersFiltered returns a subset of members
[ "MembersFiltered", "returns", "a", "subset", "of", "members" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L230-L245
166,223
hashicorp/serf
client/rpc_client.go
UserEvent
func (c *RPCClient) UserEvent(name string, payload []byte, coalesce bool) error { header := requestHeader{ Command: eventCommand, Seq: c.getSeq(), } req := eventRequest{ Name: name, Payload: payload, Coalesce: coalesce, } return c.genericRPC(&header, &req, nil) }
go
func (c *RPCClient) UserEvent(name string, payload []byte, coalesce bool) error { header := requestHeader{ Command: eventCommand, Seq: c.getSeq(), } req := eventRequest{ Name: name, Payload: payload, Coalesce: coalesce, } return c.genericRPC(&header, &req, nil) }
[ "func", "(", "c", "*", "RPCClient", ")", "UserEvent", "(", "name", "string", ",", "payload", "[", "]", "byte", ",", "coalesce", "bool", ")", "error", "{", "header", ":=", "requestHeader", "{", "Command", ":", "eventCommand", ",", "Seq", ":", "c", ".", ...
// UserEvent is used to trigger sending an event
[ "UserEvent", "is", "used", "to", "trigger", "sending", "an", "event" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L248-L259
166,224
hashicorp/serf
client/rpc_client.go
Leave
func (c *RPCClient) Leave() error { header := requestHeader{ Command: leaveCommand, Seq: c.getSeq(), } return c.genericRPC(&header, nil, nil) }
go
func (c *RPCClient) Leave() error { header := requestHeader{ Command: leaveCommand, Seq: c.getSeq(), } return c.genericRPC(&header, nil, nil) }
[ "func", "(", "c", "*", "RPCClient", ")", "Leave", "(", ")", "error", "{", "header", ":=", "requestHeader", "{", "Command", ":", "leaveCommand", ",", "Seq", ":", "c", ".", "getSeq", "(", ")", ",", "}", "\n", "return", "c", ".", "genericRPC", "(", "&...
// Leave is used to trigger a graceful leave and shutdown of the agent
[ "Leave", "is", "used", "to", "trigger", "a", "graceful", "leave", "and", "shutdown", "of", "the", "agent" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L262-L268
166,225
hashicorp/serf
client/rpc_client.go
UpdateTags
func (c *RPCClient) UpdateTags(tags map[string]string, delTags []string) error { header := requestHeader{ Command: tagsCommand, Seq: c.getSeq(), } req := tagsRequest{ Tags: tags, DeleteTags: delTags, } return c.genericRPC(&header, &req, nil) }
go
func (c *RPCClient) UpdateTags(tags map[string]string, delTags []string) error { header := requestHeader{ Command: tagsCommand, Seq: c.getSeq(), } req := tagsRequest{ Tags: tags, DeleteTags: delTags, } return c.genericRPC(&header, &req, nil) }
[ "func", "(", "c", "*", "RPCClient", ")", "UpdateTags", "(", "tags", "map", "[", "string", "]", "string", ",", "delTags", "[", "]", "string", ")", "error", "{", "header", ":=", "requestHeader", "{", "Command", ":", "tagsCommand", ",", "Seq", ":", "c", ...
// UpdateTags will modify the tags on a running serf agent
[ "UpdateTags", "will", "modify", "the", "tags", "on", "a", "running", "serf", "agent" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L271-L281
166,226
hashicorp/serf
client/rpc_client.go
Respond
func (c *RPCClient) Respond(id uint64, buf []byte) error { header := requestHeader{ Command: respondCommand, Seq: c.getSeq(), } req := respondRequest{ ID: id, Payload: buf, } return c.genericRPC(&header, &req, nil) }
go
func (c *RPCClient) Respond(id uint64, buf []byte) error { header := requestHeader{ Command: respondCommand, Seq: c.getSeq(), } req := respondRequest{ ID: id, Payload: buf, } return c.genericRPC(&header, &req, nil) }
[ "func", "(", "c", "*", "RPCClient", ")", "Respond", "(", "id", "uint64", ",", "buf", "[", "]", "byte", ")", "error", "{", "header", ":=", "requestHeader", "{", "Command", ":", "respondCommand", ",", "Seq", ":", "c", ".", "getSeq", "(", ")", ",", "}...
// Respond allows a client to respond to a query event. The ID is the // ID of the Query to respond to, and the given payload is the response.
[ "Respond", "allows", "a", "client", "to", "respond", "to", "a", "query", "event", ".", "The", "ID", "is", "the", "ID", "of", "the", "Query", "to", "respond", "to", "and", "the", "given", "payload", "is", "the", "response", "." ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L285-L295
166,227
hashicorp/serf
client/rpc_client.go
InstallKey
func (c *RPCClient) InstallKey(key string) (map[string]string, error) { header := requestHeader{ Command: installKeyCommand, Seq: c.getSeq(), } req := keyRequest{ Key: key, } resp := keyResponse{} err := c.genericRPC(&header, &req, &resp) return resp.Messages, err }
go
func (c *RPCClient) InstallKey(key string) (map[string]string, error) { header := requestHeader{ Command: installKeyCommand, Seq: c.getSeq(), } req := keyRequest{ Key: key, } resp := keyResponse{} err := c.genericRPC(&header, &req, &resp) return resp.Messages, err }
[ "func", "(", "c", "*", "RPCClient", ")", "InstallKey", "(", "key", "string", ")", "(", "map", "[", "string", "]", "string", ",", "error", ")", "{", "header", ":=", "requestHeader", "{", "Command", ":", "installKeyCommand", ",", "Seq", ":", "c", ".", ...
// IntallKey installs a new encryption key onto the keyring
[ "IntallKey", "installs", "a", "new", "encryption", "key", "onto", "the", "keyring" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L298-L311
166,228
hashicorp/serf
client/rpc_client.go
ListKeys
func (c *RPCClient) ListKeys() (map[string]int, int, map[string]string, error) { header := requestHeader{ Command: listKeysCommand, Seq: c.getSeq(), } resp := keyResponse{} err := c.genericRPC(&header, nil, &resp) return resp.Keys, resp.NumNodes, resp.Messages, err }
go
func (c *RPCClient) ListKeys() (map[string]int, int, map[string]string, error) { header := requestHeader{ Command: listKeysCommand, Seq: c.getSeq(), } resp := keyResponse{} err := c.genericRPC(&header, nil, &resp) return resp.Keys, resp.NumNodes, resp.Messages, err }
[ "func", "(", "c", "*", "RPCClient", ")", "ListKeys", "(", ")", "(", "map", "[", "string", "]", "int", ",", "int", ",", "map", "[", "string", "]", "string", ",", "error", ")", "{", "header", ":=", "requestHeader", "{", "Command", ":", "listKeysCommand...
// ListKeys returns all of the active keys on each member of the cluster
[ "ListKeys", "returns", "all", "of", "the", "active", "keys", "on", "each", "member", "of", "the", "cluster" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L346-L356
166,229
hashicorp/serf
client/rpc_client.go
Stats
func (c *RPCClient) Stats() (map[string]map[string]string, error) { header := requestHeader{ Command: statsCommand, Seq: c.getSeq(), } var resp map[string]map[string]string err := c.genericRPC(&header, nil, &resp) return resp, err }
go
func (c *RPCClient) Stats() (map[string]map[string]string, error) { header := requestHeader{ Command: statsCommand, Seq: c.getSeq(), } var resp map[string]map[string]string err := c.genericRPC(&header, nil, &resp) return resp, err }
[ "func", "(", "c", "*", "RPCClient", ")", "Stats", "(", ")", "(", "map", "[", "string", "]", "map", "[", "string", "]", "string", ",", "error", ")", "{", "header", ":=", "requestHeader", "{", "Command", ":", "statsCommand", ",", "Seq", ":", "c", "."...
// Stats is used to get debugging state information
[ "Stats", "is", "used", "to", "get", "debugging", "state", "information" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L359-L368
166,230
hashicorp/serf
client/rpc_client.go
GetCoordinate
func (c *RPCClient) GetCoordinate(node string) (*coordinate.Coordinate, error) { header := requestHeader{ Command: getCoordinateCommand, Seq: c.getSeq(), } req := coordinateRequest{ Node: node, } var resp coordinateResponse if err := c.genericRPC(&header, &req, &resp); err != nil { return nil, err }...
go
func (c *RPCClient) GetCoordinate(node string) (*coordinate.Coordinate, error) { header := requestHeader{ Command: getCoordinateCommand, Seq: c.getSeq(), } req := coordinateRequest{ Node: node, } var resp coordinateResponse if err := c.genericRPC(&header, &req, &resp); err != nil { return nil, err }...
[ "func", "(", "c", "*", "RPCClient", ")", "GetCoordinate", "(", "node", "string", ")", "(", "*", "coordinate", ".", "Coordinate", ",", "error", ")", "{", "header", ":=", "requestHeader", "{", "Command", ":", "getCoordinateCommand", ",", "Seq", ":", "c", "...
// GetCoordinate is used to retrieve the cached coordinate of a node.
[ "GetCoordinate", "is", "used", "to", "retrieve", "the", "cached", "coordinate", "of", "a", "node", "." ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L371-L388
166,231
hashicorp/serf
client/rpc_client.go
Monitor
func (c *RPCClient) Monitor(level logutils.LogLevel, ch chan<- string) (StreamHandle, error) { // Setup the request seq := c.getSeq() header := requestHeader{ Command: monitorCommand, Seq: seq, } req := monitorRequest{ LogLevel: string(level), } // Create a monitor handler initCh := make(chan error, ...
go
func (c *RPCClient) Monitor(level logutils.LogLevel, ch chan<- string) (StreamHandle, error) { // Setup the request seq := c.getSeq() header := requestHeader{ Command: monitorCommand, Seq: seq, } req := monitorRequest{ LogLevel: string(level), } // Create a monitor handler initCh := make(chan error, ...
[ "func", "(", "c", "*", "RPCClient", ")", "Monitor", "(", "level", "logutils", ".", "LogLevel", ",", "ch", "chan", "<-", "string", ")", "(", "StreamHandle", ",", "error", ")", "{", "// Setup the request", "seq", ":=", "c", ".", "getSeq", "(", ")", "\n",...
// Monitor is used to subscribe to the logs of the agent
[ "Monitor", "is", "used", "to", "subscribe", "to", "the", "logs", "of", "the", "agent" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L435-L470
166,232
hashicorp/serf
client/rpc_client.go
Stream
func (c *RPCClient) Stream(filter string, ch chan<- map[string]interface{}) (StreamHandle, error) { // Setup the request seq := c.getSeq() header := requestHeader{ Command: streamCommand, Seq: seq, } req := streamRequest{ Type: filter, } // Create a monitor handler initCh := make(chan error, 1) hand...
go
func (c *RPCClient) Stream(filter string, ch chan<- map[string]interface{}) (StreamHandle, error) { // Setup the request seq := c.getSeq() header := requestHeader{ Command: streamCommand, Seq: seq, } req := streamRequest{ Type: filter, } // Create a monitor handler initCh := make(chan error, 1) hand...
[ "func", "(", "c", "*", "RPCClient", ")", "Stream", "(", "filter", "string", ",", "ch", "chan", "<-", "map", "[", "string", "]", "interface", "{", "}", ")", "(", "StreamHandle", ",", "error", ")", "{", "// Setup the request", "seq", ":=", "c", ".", "g...
// Stream is used to subscribe to events
[ "Stream", "is", "used", "to", "subscribe", "to", "events" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L517-L552
166,233
hashicorp/serf
client/rpc_client.go
Query
func (c *RPCClient) Query(params *QueryParam) error { // Setup the request seq := c.getSeq() header := requestHeader{ Command: queryCommand, Seq: seq, } req := queryRequest{ FilterNodes: params.FilterNodes, FilterTags: params.FilterTags, RequestAck: params.RequestAck, RelayFactor: params.RelayFac...
go
func (c *RPCClient) Query(params *QueryParam) error { // Setup the request seq := c.getSeq() header := requestHeader{ Command: queryCommand, Seq: seq, } req := queryRequest{ FilterNodes: params.FilterNodes, FilterTags: params.FilterTags, RequestAck: params.RequestAck, RelayFactor: params.RelayFac...
[ "func", "(", "c", "*", "RPCClient", ")", "Query", "(", "params", "*", "QueryParam", ")", "error", "{", "// Setup the request", "seq", ":=", "c", ".", "getSeq", "(", ")", "\n", "header", ":=", "requestHeader", "{", "Command", ":", "queryCommand", ",", "Se...
// Query initiates a new query message using the given parameters, and streams // acks and responses over the given channels. The channels will not block on // sends and should be buffered. At the end of the query, the channels will be // closed.
[ "Query", "initiates", "a", "new", "query", "message", "using", "the", "given", "parameters", "and", "streams", "acks", "and", "responses", "over", "the", "given", "channels", ".", "The", "channels", "will", "not", "block", "on", "sends", "and", "should", "be...
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L637-L679
166,234
hashicorp/serf
client/rpc_client.go
Stop
func (c *RPCClient) Stop(handle StreamHandle) error { // Deregister locally first to stop delivery c.deregisterHandler(uint64(handle)) header := requestHeader{ Command: stopCommand, Seq: c.getSeq(), } req := stopRequest{ Stop: uint64(handle), } return c.genericRPC(&header, &req, nil) }
go
func (c *RPCClient) Stop(handle StreamHandle) error { // Deregister locally first to stop delivery c.deregisterHandler(uint64(handle)) header := requestHeader{ Command: stopCommand, Seq: c.getSeq(), } req := stopRequest{ Stop: uint64(handle), } return c.genericRPC(&header, &req, nil) }
[ "func", "(", "c", "*", "RPCClient", ")", "Stop", "(", "handle", "StreamHandle", ")", "error", "{", "// Deregister locally first to stop delivery", "c", ".", "deregisterHandler", "(", "uint64", "(", "handle", ")", ")", "\n\n", "header", ":=", "requestHeader", "{"...
// Stop is used to unsubscribe from logs or event streams
[ "Stop", "is", "used", "to", "unsubscribe", "from", "logs", "or", "event", "streams" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L682-L694
166,235
hashicorp/serf
client/rpc_client.go
handshake
func (c *RPCClient) handshake() error { header := requestHeader{ Command: handshakeCommand, Seq: c.getSeq(), } req := handshakeRequest{ Version: maxIPCVersion, } return c.genericRPC(&header, &req, nil) }
go
func (c *RPCClient) handshake() error { header := requestHeader{ Command: handshakeCommand, Seq: c.getSeq(), } req := handshakeRequest{ Version: maxIPCVersion, } return c.genericRPC(&header, &req, nil) }
[ "func", "(", "c", "*", "RPCClient", ")", "handshake", "(", ")", "error", "{", "header", ":=", "requestHeader", "{", "Command", ":", "handshakeCommand", ",", "Seq", ":", "c", ".", "getSeq", "(", ")", ",", "}", "\n", "req", ":=", "handshakeRequest", "{",...
// handshake is used to perform the initial handshake on connect
[ "handshake", "is", "used", "to", "perform", "the", "initial", "handshake", "on", "connect" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L697-L706
166,236
hashicorp/serf
client/rpc_client.go
auth
func (c *RPCClient) auth(authKey string) error { header := requestHeader{ Command: authCommand, Seq: c.getSeq(), } req := authRequest{ AuthKey: authKey, } return c.genericRPC(&header, &req, nil) }
go
func (c *RPCClient) auth(authKey string) error { header := requestHeader{ Command: authCommand, Seq: c.getSeq(), } req := authRequest{ AuthKey: authKey, } return c.genericRPC(&header, &req, nil) }
[ "func", "(", "c", "*", "RPCClient", ")", "auth", "(", "authKey", "string", ")", "error", "{", "header", ":=", "requestHeader", "{", "Command", ":", "authCommand", ",", "Seq", ":", "c", ".", "getSeq", "(", ")", ",", "}", "\n", "req", ":=", "authReques...
// auth is used to perform the initial authentication on connect
[ "auth", "is", "used", "to", "perform", "the", "initial", "authentication", "on", "connect" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L709-L718
166,237
hashicorp/serf
client/rpc_client.go
genericRPC
func (c *RPCClient) genericRPC(header *requestHeader, req interface{}, resp interface{}) error { // Setup a response handler errCh := make(chan error, 1) handler := func(respHeader *responseHeader) { // If we get an auth error, we should not wait for a request body if respHeader.Error == authRequired { goto S...
go
func (c *RPCClient) genericRPC(header *requestHeader, req interface{}, resp interface{}) error { // Setup a response handler errCh := make(chan error, 1) handler := func(respHeader *responseHeader) { // If we get an auth error, we should not wait for a request body if respHeader.Error == authRequired { goto S...
[ "func", "(", "c", "*", "RPCClient", ")", "genericRPC", "(", "header", "*", "requestHeader", ",", "req", "interface", "{", "}", ",", "resp", "interface", "{", "}", ")", "error", "{", "// Setup a response handler", "errCh", ":=", "make", "(", "chan", "error"...
// genericRPC is used to send a request and wait for an // errorSequenceResponse, potentially returning an error
[ "genericRPC", "is", "used", "to", "send", "a", "request", "and", "wait", "for", "an", "errorSequenceResponse", "potentially", "returning", "an", "error" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L722-L755
166,238
hashicorp/serf
client/rpc_client.go
deregisterAll
func (c *RPCClient) deregisterAll() { c.dispatchLock.Lock() defer c.dispatchLock.Unlock() for _, seqH := range c.dispatch { seqH.Cleanup() } c.dispatch = make(map[uint64]seqHandler) }
go
func (c *RPCClient) deregisterAll() { c.dispatchLock.Lock() defer c.dispatchLock.Unlock() for _, seqH := range c.dispatch { seqH.Cleanup() } c.dispatch = make(map[uint64]seqHandler) }
[ "func", "(", "c", "*", "RPCClient", ")", "deregisterAll", "(", ")", "{", "c", ".", "dispatchLock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "dispatchLock", ".", "Unlock", "(", ")", "\n\n", "for", "_", ",", "seqH", ":=", "range", "c", ".", ...
// deregisterAll is used to deregister all handlers
[ "deregisterAll", "is", "used", "to", "deregister", "all", "handlers" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L771-L779
166,239
hashicorp/serf
client/rpc_client.go
deregisterHandler
func (c *RPCClient) deregisterHandler(seq uint64) { c.dispatchLock.Lock() seqH, ok := c.dispatch[seq] delete(c.dispatch, seq) c.dispatchLock.Unlock() if ok { seqH.Cleanup() } }
go
func (c *RPCClient) deregisterHandler(seq uint64) { c.dispatchLock.Lock() seqH, ok := c.dispatch[seq] delete(c.dispatch, seq) c.dispatchLock.Unlock() if ok { seqH.Cleanup() } }
[ "func", "(", "c", "*", "RPCClient", ")", "deregisterHandler", "(", "seq", "uint64", ")", "{", "c", ".", "dispatchLock", ".", "Lock", "(", ")", "\n", "seqH", ",", "ok", ":=", "c", ".", "dispatch", "[", "seq", "]", "\n", "delete", "(", "c", ".", "d...
// deregisterHandler is used to deregister a handler
[ "deregisterHandler", "is", "used", "to", "deregister", "a", "handler" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L782-L791
166,240
hashicorp/serf
client/rpc_client.go
handleSeq
func (c *RPCClient) handleSeq(seq uint64, handler seqHandler) { c.dispatchLock.Lock() defer c.dispatchLock.Unlock() c.dispatch[seq] = handler }
go
func (c *RPCClient) handleSeq(seq uint64, handler seqHandler) { c.dispatchLock.Lock() defer c.dispatchLock.Unlock() c.dispatch[seq] = handler }
[ "func", "(", "c", "*", "RPCClient", ")", "handleSeq", "(", "seq", "uint64", ",", "handler", "seqHandler", ")", "{", "c", ".", "dispatchLock", ".", "Lock", "(", ")", "\n", "defer", "c", ".", "dispatchLock", ".", "Unlock", "(", ")", "\n", "c", ".", "...
// handleSeq is used to setup a handlerto wait on a response for // a given sequence number.
[ "handleSeq", "is", "used", "to", "setup", "a", "handlerto", "wait", "on", "a", "response", "for", "a", "given", "sequence", "number", "." ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L795-L799
166,241
hashicorp/serf
client/rpc_client.go
respondSeq
func (c *RPCClient) respondSeq(seq uint64, respHeader *responseHeader) { c.dispatchLock.Lock() seqL, ok := c.dispatch[seq] c.dispatchLock.Unlock() // Get a registered listener, ignore if none if ok { seqL.Handle(respHeader) } }
go
func (c *RPCClient) respondSeq(seq uint64, respHeader *responseHeader) { c.dispatchLock.Lock() seqL, ok := c.dispatch[seq] c.dispatchLock.Unlock() // Get a registered listener, ignore if none if ok { seqL.Handle(respHeader) } }
[ "func", "(", "c", "*", "RPCClient", ")", "respondSeq", "(", "seq", "uint64", ",", "respHeader", "*", "responseHeader", ")", "{", "c", ".", "dispatchLock", ".", "Lock", "(", ")", "\n", "seqL", ",", "ok", ":=", "c", ".", "dispatch", "[", "seq", "]", ...
// respondSeq is used to respond to a given sequence number
[ "respondSeq", "is", "used", "to", "respond", "to", "a", "given", "sequence", "number" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L802-L811
166,242
hashicorp/serf
client/rpc_client.go
listen
func (c *RPCClient) listen() { defer c.Close() var respHeader responseHeader for { if err := c.dec.Decode(&respHeader); err != nil { if !c.shutdown { log.Printf("[ERR] agent.client: Failed to decode response header: %v", err) } break } c.respondSeq(respHeader.Seq, &respHeader) } }
go
func (c *RPCClient) listen() { defer c.Close() var respHeader responseHeader for { if err := c.dec.Decode(&respHeader); err != nil { if !c.shutdown { log.Printf("[ERR] agent.client: Failed to decode response header: %v", err) } break } c.respondSeq(respHeader.Seq, &respHeader) } }
[ "func", "(", "c", "*", "RPCClient", ")", "listen", "(", ")", "{", "defer", "c", ".", "Close", "(", ")", "\n", "var", "respHeader", "responseHeader", "\n", "for", "{", "if", "err", ":=", "c", ".", "dec", ".", "Decode", "(", "&", "respHeader", ")", ...
// listen is used to processes data coming over the IPC channel, // and wrote it to the correct destination based on seq no
[ "listen", "is", "used", "to", "processes", "data", "coming", "over", "the", "IPC", "channel", "and", "wrote", "it", "to", "the", "correct", "destination", "based", "on", "seq", "no" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/client/rpc_client.go#L815-L827
166,243
hashicorp/serf
serf/config.go
Init
func (c *Config) Init() { if c.Tags == nil { c.Tags = make(map[string]string) } }
go
func (c *Config) Init() { if c.Tags == nil { c.Tags = make(map[string]string) } }
[ "func", "(", "c", "*", "Config", ")", "Init", "(", ")", "{", "if", "c", ".", "Tags", "==", "nil", "{", "c", ".", "Tags", "=", "make", "(", "map", "[", "string", "]", "string", ")", "\n", "}", "\n", "}" ]
// Init allocates the subdata structures
[ "Init", "allocates", "the", "subdata", "structures" ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/config.go#L252-L256
166,244
hashicorp/serf
serf/config.go
DefaultConfig
func DefaultConfig() *Config { hostname, err := os.Hostname() if err != nil { panic(err) } return &Config{ NodeName: hostname, BroadcastTimeout: 5 * time.Second, LeavePropagateDelay: 1 * time.Second, EventBuffer: 512, QueryBuffer: ...
go
func DefaultConfig() *Config { hostname, err := os.Hostname() if err != nil { panic(err) } return &Config{ NodeName: hostname, BroadcastTimeout: 5 * time.Second, LeavePropagateDelay: 1 * time.Second, EventBuffer: 512, QueryBuffer: ...
[ "func", "DefaultConfig", "(", ")", "*", "Config", "{", "hostname", ",", "err", ":=", "os", ".", "Hostname", "(", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n\n", "return", "&", "Config", "{", "NodeName", ":", ...
// DefaultConfig returns a Config struct that contains reasonable defaults // for most of the configurations.
[ "DefaultConfig", "returns", "a", "Config", "struct", "that", "contains", "reasonable", "defaults", "for", "most", "of", "the", "configurations", "." ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/config.go#L260-L291
166,245
hashicorp/serf
serf/coalesce.go
coalescedEventCh
func coalescedEventCh(outCh chan<- Event, shutdownCh <-chan struct{}, cPeriod time.Duration, qPeriod time.Duration, c coalescer) chan<- Event { inCh := make(chan Event, 1024) go coalesceLoop(inCh, outCh, shutdownCh, cPeriod, qPeriod, c) return inCh }
go
func coalescedEventCh(outCh chan<- Event, shutdownCh <-chan struct{}, cPeriod time.Duration, qPeriod time.Duration, c coalescer) chan<- Event { inCh := make(chan Event, 1024) go coalesceLoop(inCh, outCh, shutdownCh, cPeriod, qPeriod, c) return inCh }
[ "func", "coalescedEventCh", "(", "outCh", "chan", "<-", "Event", ",", "shutdownCh", "<-", "chan", "struct", "{", "}", ",", "cPeriod", "time", ".", "Duration", ",", "qPeriod", "time", ".", "Duration", ",", "c", "coalescer", ")", "chan", "<-", "Event", "{"...
// coalescedEventCh returns an event channel where the events are coalesced // using the given coalescer.
[ "coalescedEventCh", "returns", "an", "event", "channel", "where", "the", "events", "are", "coalesced", "using", "the", "given", "coalescer", "." ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/coalesce.go#L23-L28
166,246
hashicorp/serf
serf/coalesce.go
coalesceLoop
func coalesceLoop(inCh <-chan Event, outCh chan<- Event, shutdownCh <-chan struct{}, coalescePeriod time.Duration, quiescentPeriod time.Duration, c coalescer) { var quiescent <-chan time.Time var quantum <-chan time.Time shutdown := false INGEST: // Reset the timers quantum = nil quiescent = nil for { selec...
go
func coalesceLoop(inCh <-chan Event, outCh chan<- Event, shutdownCh <-chan struct{}, coalescePeriod time.Duration, quiescentPeriod time.Duration, c coalescer) { var quiescent <-chan time.Time var quantum <-chan time.Time shutdown := false INGEST: // Reset the timers quantum = nil quiescent = nil for { selec...
[ "func", "coalesceLoop", "(", "inCh", "<-", "chan", "Event", ",", "outCh", "chan", "<-", "Event", ",", "shutdownCh", "<-", "chan", "struct", "{", "}", ",", "coalescePeriod", "time", ".", "Duration", ",", "quiescentPeriod", "time", ".", "Duration", ",", "c",...
// coalesceLoop is a simple long-running routine that manages the high-level // flow of coalescing based on quiescence and a maximum quantum period.
[ "coalesceLoop", "is", "a", "simple", "long", "-", "running", "routine", "that", "manages", "the", "high", "-", "level", "flow", "of", "coalescing", "based", "on", "quiescence", "and", "a", "maximum", "quantum", "period", "." ]
15cfd05de3dffb3664aa37b06e91f970b825e380
https://github.com/hashicorp/serf/blob/15cfd05de3dffb3664aa37b06e91f970b825e380/serf/coalesce.go#L32-L80
166,247
swaggo/swag
gen/gen.go
Build
func (g *Gen) Build(config *Config) error { if _, err := os.Stat(config.SearchDir); os.IsNotExist(err) { return fmt.Errorf("dir: %s is not exist", config.SearchDir) } log.Println("Generate swagger docs....") p := swag.New() p.PropNamingStrategy = config.PropNamingStrategy p.ParseVendor = config.ParseVendor i...
go
func (g *Gen) Build(config *Config) error { if _, err := os.Stat(config.SearchDir); os.IsNotExist(err) { return fmt.Errorf("dir: %s is not exist", config.SearchDir) } log.Println("Generate swagger docs....") p := swag.New() p.PropNamingStrategy = config.PropNamingStrategy p.ParseVendor = config.ParseVendor i...
[ "func", "(", "g", "*", "Gen", ")", "Build", "(", "config", "*", "Config", ")", "error", "{", "if", "_", ",", "err", ":=", "os", ".", "Stat", "(", "config", ".", "SearchDir", ")", ";", "os", ".", "IsNotExist", "(", "err", ")", "{", "return", "fm...
// Build builds swagger json file for gived searchDir and mainAPIFile. Returns json
[ "Build", "builds", "swagger", "json", "file", "for", "gived", "searchDir", "and", "mainAPIFile", ".", "Returns", "json" ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/gen/gen.go#L45-L108
166,248
swaggo/swag
operation.go
ParseComment
func (operation *Operation) ParseComment(comment string, astFile *ast.File) error { commentLine := strings.TrimSpace(strings.TrimLeft(comment, "//")) if len(commentLine) == 0 { return nil } attribute := strings.Fields(commentLine)[0] lineRemainder := strings.TrimSpace(commentLine[len(attribute):]) switch strin...
go
func (operation *Operation) ParseComment(comment string, astFile *ast.File) error { commentLine := strings.TrimSpace(strings.TrimLeft(comment, "//")) if len(commentLine) == 0 { return nil } attribute := strings.Fields(commentLine)[0] lineRemainder := strings.TrimSpace(commentLine[len(attribute):]) switch strin...
[ "func", "(", "operation", "*", "Operation", ")", "ParseComment", "(", "comment", "string", ",", "astFile", "*", "ast", ".", "File", ")", "error", "{", "commentLine", ":=", "strings", ".", "TrimSpace", "(", "strings", ".", "TrimLeft", "(", "comment", ",", ...
// ParseComment parses comment for given comment string and returns error if error occurs.
[ "ParseComment", "parses", "comment", "for", "given", "comment", "string", "and", "returns", "error", "if", "error", "occurs", "." ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/operation.go#L59-L114
166,249
swaggo/swag
operation.go
ParseTagsComment
func (operation *Operation) ParseTagsComment(commentLine string) { tags := strings.Split(commentLine, ",") for _, tag := range tags { operation.Tags = append(operation.Tags, strings.TrimSpace(tag)) } }
go
func (operation *Operation) ParseTagsComment(commentLine string) { tags := strings.Split(commentLine, ",") for _, tag := range tags { operation.Tags = append(operation.Tags, strings.TrimSpace(tag)) } }
[ "func", "(", "operation", "*", "Operation", ")", "ParseTagsComment", "(", "commentLine", "string", ")", "{", "tags", ":=", "strings", ".", "Split", "(", "commentLine", ",", "\"", "\"", ")", "\n", "for", "_", ",", "tag", ":=", "range", "tags", "{", "ope...
// ParseTagsComment parses comment for given `tag` comment string.
[ "ParseTagsComment", "parses", "comment", "for", "given", "tag", "comment", "string", "." ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/operation.go#L353-L358
166,250
swaggo/swag
operation.go
ParseAcceptComment
func (operation *Operation) ParseAcceptComment(commentLine string) error { return parseMimeTypeList(commentLine, &operation.Consumes, "%v accept type can't be accepted") }
go
func (operation *Operation) ParseAcceptComment(commentLine string) error { return parseMimeTypeList(commentLine, &operation.Consumes, "%v accept type can't be accepted") }
[ "func", "(", "operation", "*", "Operation", ")", "ParseAcceptComment", "(", "commentLine", "string", ")", "error", "{", "return", "parseMimeTypeList", "(", "commentLine", ",", "&", "operation", ".", "Consumes", ",", "\"", "\"", ")", "\n", "}" ]
// ParseAcceptComment parses comment for given `accept` comment string.
[ "ParseAcceptComment", "parses", "comment", "for", "given", "accept", "comment", "string", "." ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/operation.go#L361-L363
166,251
swaggo/swag
operation.go
ParseProduceComment
func (operation *Operation) ParseProduceComment(commentLine string) error { return parseMimeTypeList(commentLine, &operation.Produces, "%v produce type can't be accepted") }
go
func (operation *Operation) ParseProduceComment(commentLine string) error { return parseMimeTypeList(commentLine, &operation.Produces, "%v produce type can't be accepted") }
[ "func", "(", "operation", "*", "Operation", ")", "ParseProduceComment", "(", "commentLine", "string", ")", "error", "{", "return", "parseMimeTypeList", "(", "commentLine", ",", "&", "operation", ".", "Produces", ",", "\"", "\"", ")", "\n", "}" ]
// ParseProduceComment parses comment for given `produce` comment string.
[ "ParseProduceComment", "parses", "comment", "for", "given", "produce", "comment", "string", "." ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/operation.go#L366-L368
166,252
swaggo/swag
operation.go
ParseRouterComment
func (operation *Operation) ParseRouterComment(commentLine string) error { var matches []string if matches = routerPattern.FindStringSubmatch(commentLine); len(matches) != 3 { return fmt.Errorf("can not parse router comment \"%s\"", commentLine) } path := matches[1] httpMethod := matches[2] operation.Path = p...
go
func (operation *Operation) ParseRouterComment(commentLine string) error { var matches []string if matches = routerPattern.FindStringSubmatch(commentLine); len(matches) != 3 { return fmt.Errorf("can not parse router comment \"%s\"", commentLine) } path := matches[1] httpMethod := matches[2] operation.Path = p...
[ "func", "(", "operation", "*", "Operation", ")", "ParseRouterComment", "(", "commentLine", "string", ")", "error", "{", "var", "matches", "[", "]", "string", "\n\n", "if", "matches", "=", "routerPattern", ".", "FindStringSubmatch", "(", "commentLine", ")", ";"...
// ParseRouterComment parses comment for gived `router` comment string.
[ "ParseRouterComment", "parses", "comment", "for", "gived", "router", "comment", "string", "." ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/operation.go#L392-L405
166,253
swaggo/swag
operation.go
ParseSecurityComment
func (operation *Operation) ParseSecurityComment(commentLine string) error { securitySource := commentLine[strings.Index(commentLine, "@Security")+1:] l := strings.Index(securitySource, "[") r := strings.Index(securitySource, "]") // exists scope if !(l == -1 && r == -1) { scopes := securitySource[l+1 : r] s :...
go
func (operation *Operation) ParseSecurityComment(commentLine string) error { securitySource := commentLine[strings.Index(commentLine, "@Security")+1:] l := strings.Index(securitySource, "[") r := strings.Index(securitySource, "]") // exists scope if !(l == -1 && r == -1) { scopes := securitySource[l+1 : r] s :...
[ "func", "(", "operation", "*", "Operation", ")", "ParseSecurityComment", "(", "commentLine", "string", ")", "error", "{", "securitySource", ":=", "commentLine", "[", "strings", ".", "Index", "(", "commentLine", ",", "\"", "\"", ")", "+", "1", ":", "]", "\n...
// ParseSecurityComment parses comment for gived `security` comment string.
[ "ParseSecurityComment", "parses", "comment", "for", "gived", "security", "comment", "string", "." ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/operation.go#L408-L431
166,254
swaggo/swag
operation.go
ParseResponseComment
func (operation *Operation) ParseResponseComment(commentLine string, astFile *ast.File) error { var matches []string if matches = responsePattern.FindStringSubmatch(commentLine); len(matches) != 5 { return fmt.Errorf("can not parse response comment \"%s\"", commentLine) } response := spec.Response{} code, _ :...
go
func (operation *Operation) ParseResponseComment(commentLine string, astFile *ast.File) error { var matches []string if matches = responsePattern.FindStringSubmatch(commentLine); len(matches) != 5 { return fmt.Errorf("can not parse response comment \"%s\"", commentLine) } response := spec.Response{} code, _ :...
[ "func", "(", "operation", "*", "Operation", ")", "ParseResponseComment", "(", "commentLine", "string", ",", "astFile", "*", "ast", ".", "File", ")", "error", "{", "var", "matches", "[", "]", "string", "\n\n", "if", "matches", "=", "responsePattern", ".", "...
// ParseResponseComment parses comment for gived `response` comment string.
[ "ParseResponseComment", "parses", "comment", "for", "gived", "response", "comment", "string", "." ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/operation.go#L491-L559
166,255
swaggo/swag
operation.go
ParseResponseHeaderComment
func (operation *Operation) ParseResponseHeaderComment(commentLine string, astFile *ast.File) error { var matches []string if matches = responsePattern.FindStringSubmatch(commentLine); len(matches) != 5 { return fmt.Errorf("can not parse response comment \"%s\"", commentLine) } response := spec.Response{} cod...
go
func (operation *Operation) ParseResponseHeaderComment(commentLine string, astFile *ast.File) error { var matches []string if matches = responsePattern.FindStringSubmatch(commentLine); len(matches) != 5 { return fmt.Errorf("can not parse response comment \"%s\"", commentLine) } response := spec.Response{} cod...
[ "func", "(", "operation", "*", "Operation", ")", "ParseResponseHeaderComment", "(", "commentLine", "string", ",", "astFile", "*", "ast", ".", "File", ")", "error", "{", "var", "matches", "[", "]", "string", "\n\n", "if", "matches", "=", "responsePattern", "....
// ParseResponseHeaderComment parses comment for gived `response header` comment string.
[ "ParseResponseHeaderComment", "parses", "comment", "for", "gived", "response", "header", "comment", "string", "." ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/operation.go#L562-L605
166,256
swaggo/swag
operation.go
createParameter
func createParameter(paramType, description, paramName, schemaType string, required bool) spec.Parameter { // //five possible parameter types. query, path, body, header, form paramProps := spec.ParamProps{ Name: paramName, Description: description, Required: required, In: paramType, } if...
go
func createParameter(paramType, description, paramName, schemaType string, required bool) spec.Parameter { // //five possible parameter types. query, path, body, header, form paramProps := spec.ParamProps{ Name: paramName, Description: description, Required: required, In: paramType, } if...
[ "func", "createParameter", "(", "paramType", ",", "description", ",", "paramName", ",", "schemaType", "string", ",", "required", "bool", ")", "spec", ".", "Parameter", "{", "// //five possible parameter types. \tquery, path, body, header, form", "paramProps", ":=", "spec"...
// createParameter returns swagger spec.Parameter for gived paramType, description, paramName, schemaType, required
[ "createParameter", "returns", "swagger", "spec", ".", "Parameter", "for", "gived", "paramType", "description", "paramName", "schemaType", "required" ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/operation.go#L658-L684
166,257
swaggo/swag
swagger.go
Register
func Register(name string, swagger Swagger) { swaggerMu.Lock() defer swaggerMu.Unlock() if swagger == nil { panic("swagger is nil") } if swag != nil { panic("Register called twice for swag: " + name) } swag = swagger }
go
func Register(name string, swagger Swagger) { swaggerMu.Lock() defer swaggerMu.Unlock() if swagger == nil { panic("swagger is nil") } if swag != nil { panic("Register called twice for swag: " + name) } swag = swagger }
[ "func", "Register", "(", "name", "string", ",", "swagger", "Swagger", ")", "{", "swaggerMu", ".", "Lock", "(", ")", "\n", "defer", "swaggerMu", ".", "Unlock", "(", ")", "\n", "if", "swagger", "==", "nil", "{", "panic", "(", "\"", "\"", ")", "\n", "...
// Register registers swagger for given name.
[ "Register", "registers", "swagger", "for", "given", "name", "." ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/swagger.go#L22-L33
166,258
swaggo/swag
swagger.go
ReadDoc
func ReadDoc() (string, error) { if swag != nil { return swag.ReadDoc(), nil } return "", errors.New("not yet registered swag") }
go
func ReadDoc() (string, error) { if swag != nil { return swag.ReadDoc(), nil } return "", errors.New("not yet registered swag") }
[ "func", "ReadDoc", "(", ")", "(", "string", ",", "error", ")", "{", "if", "swag", "!=", "nil", "{", "return", "swag", ".", "ReadDoc", "(", ")", ",", "nil", "\n", "}", "\n", "return", "\"", "\"", ",", "errors", ".", "New", "(", "\"", "\"", ")", ...
// ReadDoc reads swagger document.
[ "ReadDoc", "reads", "swagger", "document", "." ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/swagger.go#L36-L41
166,259
swaggo/swag
parser.go
New
func New() *Parser { parser := &Parser{ swagger: &spec.Swagger{ SwaggerProps: spec.SwaggerProps{ Info: &spec.Info{ InfoProps: spec.InfoProps{ Contact: &spec.ContactInfo{}, License: &spec.License{}, }, }, Paths: &spec.Paths{ Paths: make(map[string]spec.PathItem), }, D...
go
func New() *Parser { parser := &Parser{ swagger: &spec.Swagger{ SwaggerProps: spec.SwaggerProps{ Info: &spec.Info{ InfoProps: spec.InfoProps{ Contact: &spec.ContactInfo{}, License: &spec.License{}, }, }, Paths: &spec.Paths{ Paths: make(map[string]spec.PathItem), }, D...
[ "func", "New", "(", ")", "*", "Parser", "{", "parser", ":=", "&", "Parser", "{", "swagger", ":", "&", "spec", ".", "Swagger", "{", "SwaggerProps", ":", "spec", ".", "SwaggerProps", "{", "Info", ":", "&", "spec", ".", "Info", "{", "InfoProps", ":", ...
// New creates a new Parser with default properties.
[ "New", "creates", "a", "new", "Parser", "with", "default", "properties", "." ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/parser.go#L60-L82
166,260
swaggo/swag
parser.go
ParseAPI
func (parser *Parser) ParseAPI(searchDir string, mainAPIFile string) error { Println("Generate general API Info") if err := parser.getAllGoFileInfo(searchDir); err != nil { return err } parser.ParseGeneralAPIInfo(path.Join(searchDir, mainAPIFile)) for _, astFile := range parser.files { parser.ParseType(astFil...
go
func (parser *Parser) ParseAPI(searchDir string, mainAPIFile string) error { Println("Generate general API Info") if err := parser.getAllGoFileInfo(searchDir); err != nil { return err } parser.ParseGeneralAPIInfo(path.Join(searchDir, mainAPIFile)) for _, astFile := range parser.files { parser.ParseType(astFil...
[ "func", "(", "parser", "*", "Parser", ")", "ParseAPI", "(", "searchDir", "string", ",", "mainAPIFile", "string", ")", "error", "{", "Println", "(", "\"", "\"", ")", "\n", "if", "err", ":=", "parser", ".", "getAllGoFileInfo", "(", "searchDir", ")", ";", ...
// ParseAPI parses general api info for gived searchDir and mainAPIFile
[ "ParseAPI", "parses", "general", "api", "info", "for", "gived", "searchDir", "and", "mainAPIFile" ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/parser.go#L85-L105
166,261
swaggo/swag
parser.go
getSchemes
func getSchemes(commentLine string) []string { attribute := strings.ToLower(strings.Split(commentLine, " ")[0]) return strings.Split(strings.TrimSpace(commentLine[len(attribute):]), " ") }
go
func getSchemes(commentLine string) []string { attribute := strings.ToLower(strings.Split(commentLine, " ")[0]) return strings.Split(strings.TrimSpace(commentLine[len(attribute):]), " ") }
[ "func", "getSchemes", "(", "commentLine", "string", ")", "[", "]", "string", "{", "attribute", ":=", "strings", ".", "ToLower", "(", "strings", ".", "Split", "(", "commentLine", ",", "\"", "\"", ")", "[", "0", "]", ")", "\n", "return", "strings", ".", ...
// getSchemes parses swagger schemes for given commentLine
[ "getSchemes", "parses", "swagger", "schemes", "for", "given", "commentLine" ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/parser.go#L381-L384
166,262
swaggo/swag
parser.go
ParseRouterAPIInfo
func (parser *Parser) ParseRouterAPIInfo(fileName string, astFile *ast.File) error { for _, astDescription := range astFile.Decls { switch astDeclaration := astDescription.(type) { case *ast.FuncDecl: if astDeclaration.Doc != nil && astDeclaration.Doc.List != nil { operation := NewOperation() //for per 'fun...
go
func (parser *Parser) ParseRouterAPIInfo(fileName string, astFile *ast.File) error { for _, astDescription := range astFile.Decls { switch astDeclaration := astDescription.(type) { case *ast.FuncDecl: if astDeclaration.Doc != nil && astDeclaration.Doc.List != nil { operation := NewOperation() //for per 'fun...
[ "func", "(", "parser", "*", "Parser", ")", "ParseRouterAPIInfo", "(", "fileName", "string", ",", "astFile", "*", "ast", ".", "File", ")", "error", "{", "for", "_", ",", "astDescription", ":=", "range", "astFile", ".", "Decls", "{", "switch", "astDeclaratio...
// ParseRouterAPIInfo parses router api info for given astFile
[ "ParseRouterAPIInfo", "parses", "router", "api", "info", "for", "given", "astFile" ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/parser.go#L387-L428
166,263
swaggo/swag
parser.go
ParseType
func (parser *Parser) ParseType(astFile *ast.File) { if _, ok := parser.TypeDefinitions[astFile.Name.String()]; !ok { parser.TypeDefinitions[astFile.Name.String()] = make(map[string]*ast.TypeSpec) } for _, astDeclaration := range astFile.Decls { if generalDeclaration, ok := astDeclaration.(*ast.GenDecl); ok && ...
go
func (parser *Parser) ParseType(astFile *ast.File) { if _, ok := parser.TypeDefinitions[astFile.Name.String()]; !ok { parser.TypeDefinitions[astFile.Name.String()] = make(map[string]*ast.TypeSpec) } for _, astDeclaration := range astFile.Decls { if generalDeclaration, ok := astDeclaration.(*ast.GenDecl); ok && ...
[ "func", "(", "parser", "*", "Parser", ")", "ParseType", "(", "astFile", "*", "ast", ".", "File", ")", "{", "if", "_", ",", "ok", ":=", "parser", ".", "TypeDefinitions", "[", "astFile", ".", "Name", ".", "String", "(", ")", "]", ";", "!", "ok", "{...
// ParseType parses type info for given astFile.
[ "ParseType", "parses", "type", "info", "for", "given", "astFile", "." ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/parser.go#L431-L452
166,264
swaggo/swag
parser.go
ParseDefinitions
func (parser *Parser) ParseDefinitions() { // sort the typeNames so that parsing definitions is deterministic typeNames := make([]string, 0, len(parser.registerTypes)) for refTypeName := range parser.registerTypes { typeNames = append(typeNames, refTypeName) } sort.Strings(typeNames) for _, refTypeName := rang...
go
func (parser *Parser) ParseDefinitions() { // sort the typeNames so that parsing definitions is deterministic typeNames := make([]string, 0, len(parser.registerTypes)) for refTypeName := range parser.registerTypes { typeNames = append(typeNames, refTypeName) } sort.Strings(typeNames) for _, refTypeName := rang...
[ "func", "(", "parser", "*", "Parser", ")", "ParseDefinitions", "(", ")", "{", "// sort the typeNames so that parsing definitions is deterministic", "typeNames", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "parser", ".", "registerTypes", ")", ...
// ParseDefinitions parses Swagger Api definitions.
[ "ParseDefinitions", "parses", "Swagger", "Api", "definitions", "." ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/parser.go#L464-L479
166,265
swaggo/swag
parser.go
ParseDefinition
func (parser *Parser) ParseDefinition(pkgName, typeName string, typeSpec *ast.TypeSpec) error { refTypeName := fullTypeName(pkgName, typeName) if _, isParsed := parser.swagger.Definitions[refTypeName]; isParsed { Println("Skipping '" + refTypeName + "', already parsed.") return nil } if parser.isInStructStack(...
go
func (parser *Parser) ParseDefinition(pkgName, typeName string, typeSpec *ast.TypeSpec) error { refTypeName := fullTypeName(pkgName, typeName) if _, isParsed := parser.swagger.Definitions[refTypeName]; isParsed { Println("Skipping '" + refTypeName + "', already parsed.") return nil } if parser.isInStructStack(...
[ "func", "(", "parser", "*", "Parser", ")", "ParseDefinition", "(", "pkgName", ",", "typeName", "string", ",", "typeSpec", "*", "ast", ".", "TypeSpec", ")", "error", "{", "refTypeName", ":=", "fullTypeName", "(", "pkgName", ",", "typeName", ")", "\n", "if",...
// ParseDefinition parses given type spec that corresponds to the type under // given name and package, and populates swagger schema definitions registry // with a schema for the given type
[ "ParseDefinition", "parses", "given", "type", "spec", "that", "corresponds", "to", "the", "type", "under", "given", "name", "and", "package", "and", "populates", "swagger", "schema", "definitions", "registry", "with", "a", "schema", "for", "the", "given", "type"...
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/parser.go#L484-L505
166,266
swaggo/swag
parser.go
getAllGoFileInfo
func (parser *Parser) getAllGoFileInfo(searchDir string) error { return filepath.Walk(searchDir, parser.visit) }
go
func (parser *Parser) getAllGoFileInfo(searchDir string) error { return filepath.Walk(searchDir, parser.visit) }
[ "func", "(", "parser", "*", "Parser", ")", "getAllGoFileInfo", "(", "searchDir", "string", ")", "error", "{", "return", "filepath", ".", "Walk", "(", "searchDir", ",", "parser", ".", "visit", ")", "\n", "}" ]
// GetAllGoFileInfo gets all Go source files information for given searchDir.
[ "GetAllGoFileInfo", "gets", "all", "Go", "source", "files", "information", "for", "given", "searchDir", "." ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/parser.go#L1148-L1150
166,267
swaggo/swag
parser.go
Skip
func (parser *Parser) Skip(path string, f os.FileInfo) error { if !parser.ParseVendor { // ignore vendor if f.IsDir() && f.Name() == "vendor" { return filepath.SkipDir } } // exclude all hidden folder if f.IsDir() && len(f.Name()) > 1 && f.Name()[0] == '.' { return filepath.SkipDir } return nil }
go
func (parser *Parser) Skip(path string, f os.FileInfo) error { if !parser.ParseVendor { // ignore vendor if f.IsDir() && f.Name() == "vendor" { return filepath.SkipDir } } // exclude all hidden folder if f.IsDir() && len(f.Name()) > 1 && f.Name()[0] == '.' { return filepath.SkipDir } return nil }
[ "func", "(", "parser", "*", "Parser", ")", "Skip", "(", "path", "string", ",", "f", "os", ".", "FileInfo", ")", "error", "{", "if", "!", "parser", ".", "ParseVendor", "{", "// ignore vendor", "if", "f", ".", "IsDir", "(", ")", "&&", "f", ".", "Name...
// Skip returns filepath.SkipDir error if match vendor and hidden folder
[ "Skip", "returns", "filepath", ".", "SkipDir", "error", "if", "match", "vendor", "and", "hidden", "folder" ]
2a7b9f41f0361c4bf8145a5369b01b189aaa7245
https://github.com/swaggo/swag/blob/2a7b9f41f0361c4bf8145a5369b01b189aaa7245/parser.go#L1170-L1183
166,268
tidwall/gjson
gjson_ngae.go
fillIndex
func fillIndex(json string, c *parseContext) { if len(c.value.Raw) > 0 && !c.calcd { jhdr := *(*reflect.StringHeader)(unsafe.Pointer(&json)) rhdr := *(*reflect.StringHeader)(unsafe.Pointer(&(c.value.Raw))) c.value.Index = int(rhdr.Data - jhdr.Data) if c.value.Index < 0 || c.value.Index >= len(json) { c.valu...
go
func fillIndex(json string, c *parseContext) { if len(c.value.Raw) > 0 && !c.calcd { jhdr := *(*reflect.StringHeader)(unsafe.Pointer(&json)) rhdr := *(*reflect.StringHeader)(unsafe.Pointer(&(c.value.Raw))) c.value.Index = int(rhdr.Data - jhdr.Data) if c.value.Index < 0 || c.value.Index >= len(json) { c.valu...
[ "func", "fillIndex", "(", "json", "string", ",", "c", "*", "parseContext", ")", "{", "if", "len", "(", "c", ".", "value", ".", "Raw", ")", ">", "0", "&&", "!", "c", ".", "calcd", "{", "jhdr", ":=", "*", "(", "*", "reflect", ".", "StringHeader", ...
// fillIndex finds the position of Raw data and assigns it to the Index field // of the resulting value. If the position cannot be found then Index zero is // used instead.
[ "fillIndex", "finds", "the", "position", "of", "Raw", "data", "and", "assigns", "it", "to", "the", "Index", "field", "of", "the", "resulting", "value", ".", "If", "the", "position", "cannot", "be", "found", "then", "Index", "zero", "is", "used", "instead",...
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson_ngae.go#L60-L69
166,269
tidwall/gjson
gjson.go
String
func (t Type) String() string { switch t { default: return "" case Null: return "Null" case False: return "False" case Number: return "Number" case String: return "String" case True: return "True" case JSON: return "JSON" } }
go
func (t Type) String() string { switch t { default: return "" case Null: return "Null" case False: return "False" case Number: return "Number" case String: return "String" case True: return "True" case JSON: return "JSON" } }
[ "func", "(", "t", "Type", ")", "String", "(", ")", "string", "{", "switch", "t", "{", "default", ":", "return", "\"", "\"", "\n", "case", "Null", ":", "return", "\"", "\"", "\n", "case", "False", ":", "return", "\"", "\"", "\n", "case", "Number", ...
// String returns a string representation of the type.
[ "String", "returns", "a", "string", "representation", "of", "the", "type", "." ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L40-L57
166,270
tidwall/gjson
gjson.go
String
func (t Result) String() string { switch t.Type { default: return "" case False: return "false" case Number: if len(t.Raw) == 0 { // calculated result return strconv.FormatFloat(t.Num, 'f', -1, 64) } var i int if t.Raw[0] == '-' { i++ } for ; i < len(t.Raw); i++ { if t.Raw[i] < '0' || t....
go
func (t Result) String() string { switch t.Type { default: return "" case False: return "false" case Number: if len(t.Raw) == 0 { // calculated result return strconv.FormatFloat(t.Num, 'f', -1, 64) } var i int if t.Raw[0] == '-' { i++ } for ; i < len(t.Raw); i++ { if t.Raw[i] < '0' || t....
[ "func", "(", "t", "Result", ")", "String", "(", ")", "string", "{", "switch", "t", ".", "Type", "{", "default", ":", "return", "\"", "\"", "\n", "case", "False", ":", "return", "\"", "\"", "\n", "case", "Number", ":", "if", "len", "(", "t", ".", ...
// String returns a string representation of the value.
[ "String", "returns", "a", "string", "representation", "of", "the", "value", "." ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L74-L102
166,271
tidwall/gjson
gjson.go
Bool
func (t Result) Bool() bool { switch t.Type { default: return false case True: return true case String: return t.Str != "" && t.Str != "0" && t.Str != "false" case Number: return t.Num != 0 } }
go
func (t Result) Bool() bool { switch t.Type { default: return false case True: return true case String: return t.Str != "" && t.Str != "0" && t.Str != "false" case Number: return t.Num != 0 } }
[ "func", "(", "t", "Result", ")", "Bool", "(", ")", "bool", "{", "switch", "t", ".", "Type", "{", "default", ":", "return", "false", "\n", "case", "True", ":", "return", "true", "\n", "case", "String", ":", "return", "t", ".", "Str", "!=", "\"", "...
// Bool returns an boolean representation.
[ "Bool", "returns", "an", "boolean", "representation", "." ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L105-L116
166,272
tidwall/gjson
gjson.go
Int
func (t Result) Int() int64 { switch t.Type { default: return 0 case True: return 1 case String: n, _ := parseInt(t.Str) return n case Number: // try to directly convert the float64 to int64 n, ok := floatToInt(t.Num) if !ok { // now try to parse the raw string n, ok = parseInt(t.Raw) if !ok...
go
func (t Result) Int() int64 { switch t.Type { default: return 0 case True: return 1 case String: n, _ := parseInt(t.Str) return n case Number: // try to directly convert the float64 to int64 n, ok := floatToInt(t.Num) if !ok { // now try to parse the raw string n, ok = parseInt(t.Raw) if !ok...
[ "func", "(", "t", "Result", ")", "Int", "(", ")", "int64", "{", "switch", "t", ".", "Type", "{", "default", ":", "return", "0", "\n", "case", "True", ":", "return", "1", "\n", "case", "String", ":", "n", ",", "_", ":=", "parseInt", "(", "t", "....
// Int returns an integer representation.
[ "Int", "returns", "an", "integer", "representation", "." ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L119-L141
166,273
tidwall/gjson
gjson.go
Uint
func (t Result) Uint() uint64 { switch t.Type { default: return 0 case True: return 1 case String: n, _ := parseUint(t.Str) return n case Number: // try to directly convert the float64 to uint64 n, ok := floatToUint(t.Num) if !ok { // now try to parse the raw string n, ok = parseUint(t.Raw) ...
go
func (t Result) Uint() uint64 { switch t.Type { default: return 0 case True: return 1 case String: n, _ := parseUint(t.Str) return n case Number: // try to directly convert the float64 to uint64 n, ok := floatToUint(t.Num) if !ok { // now try to parse the raw string n, ok = parseUint(t.Raw) ...
[ "func", "(", "t", "Result", ")", "Uint", "(", ")", "uint64", "{", "switch", "t", ".", "Type", "{", "default", ":", "return", "0", "\n", "case", "True", ":", "return", "1", "\n", "case", "String", ":", "n", ",", "_", ":=", "parseUint", "(", "t", ...
// Uint returns an unsigned integer representation.
[ "Uint", "returns", "an", "unsigned", "integer", "representation", "." ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L144-L166
166,274
tidwall/gjson
gjson.go
Float
func (t Result) Float() float64 { switch t.Type { default: return 0 case True: return 1 case String: n, _ := strconv.ParseFloat(t.Str, 64) return n case Number: return t.Num } }
go
func (t Result) Float() float64 { switch t.Type { default: return 0 case True: return 1 case String: n, _ := strconv.ParseFloat(t.Str, 64) return n case Number: return t.Num } }
[ "func", "(", "t", "Result", ")", "Float", "(", ")", "float64", "{", "switch", "t", ".", "Type", "{", "default", ":", "return", "0", "\n", "case", "True", ":", "return", "1", "\n", "case", "String", ":", "n", ",", "_", ":=", "strconv", ".", "Parse...
// Float returns an float64 representation.
[ "Float", "returns", "an", "float64", "representation", "." ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L169-L181
166,275
tidwall/gjson
gjson.go
Time
func (t Result) Time() time.Time { res, _ := time.Parse(time.RFC3339, t.String()) return res }
go
func (t Result) Time() time.Time { res, _ := time.Parse(time.RFC3339, t.String()) return res }
[ "func", "(", "t", "Result", ")", "Time", "(", ")", "time", ".", "Time", "{", "res", ",", "_", ":=", "time", ".", "Parse", "(", "time", ".", "RFC3339", ",", "t", ".", "String", "(", ")", ")", "\n", "return", "res", "\n", "}" ]
// Time returns a time.Time representation.
[ "Time", "returns", "a", "time", ".", "Time", "representation", "." ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L184-L187
166,276
tidwall/gjson
gjson.go
Array
func (t Result) Array() []Result { if t.Type == Null { return []Result{} } if t.Type != JSON { return []Result{t} } r := t.arrayOrMap('[', false) return r.a }
go
func (t Result) Array() []Result { if t.Type == Null { return []Result{} } if t.Type != JSON { return []Result{t} } r := t.arrayOrMap('[', false) return r.a }
[ "func", "(", "t", "Result", ")", "Array", "(", ")", "[", "]", "Result", "{", "if", "t", ".", "Type", "==", "Null", "{", "return", "[", "]", "Result", "{", "}", "\n", "}", "\n", "if", "t", ".", "Type", "!=", "JSON", "{", "return", "[", "]", ...
// Array returns back an array of values. // If the result represents a non-existent value, then an empty array will be returned. // If the result is not a JSON array, the return value will be an array containing one result.
[ "Array", "returns", "back", "an", "array", "of", "values", ".", "If", "the", "result", "represents", "a", "non", "-", "existent", "value", "then", "an", "empty", "array", "will", "be", "returned", ".", "If", "the", "result", "is", "not", "a", "JSON", "...
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L192-L201
166,277
tidwall/gjson
gjson.go
IsObject
func (t Result) IsObject() bool { return t.Type == JSON && len(t.Raw) > 0 && t.Raw[0] == '{' }
go
func (t Result) IsObject() bool { return t.Type == JSON && len(t.Raw) > 0 && t.Raw[0] == '{' }
[ "func", "(", "t", "Result", ")", "IsObject", "(", ")", "bool", "{", "return", "t", ".", "Type", "==", "JSON", "&&", "len", "(", "t", ".", "Raw", ")", ">", "0", "&&", "t", ".", "Raw", "[", "0", "]", "==", "'{'", "\n", "}" ]
// IsObject returns true if the result value is a JSON object.
[ "IsObject", "returns", "true", "if", "the", "result", "value", "is", "a", "JSON", "object", "." ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L204-L206
166,278
tidwall/gjson
gjson.go
IsArray
func (t Result) IsArray() bool { return t.Type == JSON && len(t.Raw) > 0 && t.Raw[0] == '[' }
go
func (t Result) IsArray() bool { return t.Type == JSON && len(t.Raw) > 0 && t.Raw[0] == '[' }
[ "func", "(", "t", "Result", ")", "IsArray", "(", ")", "bool", "{", "return", "t", ".", "Type", "==", "JSON", "&&", "len", "(", "t", ".", "Raw", ")", ">", "0", "&&", "t", ".", "Raw", "[", "0", "]", "==", "'['", "\n", "}" ]
// IsArray returns true if the result value is a JSON array.
[ "IsArray", "returns", "true", "if", "the", "result", "value", "is", "a", "JSON", "array", "." ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L209-L211
166,279
tidwall/gjson
gjson.go
ForEach
func (t Result) ForEach(iterator func(key, value Result) bool) { if !t.Exists() { return } if t.Type != JSON { iterator(Result{}, t) return } json := t.Raw var keys bool var i int var key, value Result for ; i < len(json); i++ { if json[i] == '{' { i++ key.Type = String keys = true break ...
go
func (t Result) ForEach(iterator func(key, value Result) bool) { if !t.Exists() { return } if t.Type != JSON { iterator(Result{}, t) return } json := t.Raw var keys bool var i int var key, value Result for ; i < len(json); i++ { if json[i] == '{' { i++ key.Type = String keys = true break ...
[ "func", "(", "t", "Result", ")", "ForEach", "(", "iterator", "func", "(", "key", ",", "value", "Result", ")", "bool", ")", "{", "if", "!", "t", ".", "Exists", "(", ")", "{", "return", "\n", "}", "\n", "if", "t", ".", "Type", "!=", "JSON", "{", ...
// ForEach iterates through values. // If the result represents a non-existent value, then no values will be iterated. // If the result is an Object, the iterator will pass the key and value of each item. // If the result is an Array, the iterator will only pass the value of each item. // If the result is not a JSON ar...
[ "ForEach", "iterates", "through", "values", ".", "If", "the", "result", "represents", "a", "non", "-", "existent", "value", "then", "no", "values", "will", "be", "iterated", ".", "If", "the", "result", "is", "an", "Object", "the", "iterator", "will", "pass...
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L218-L281
166,280
tidwall/gjson
gjson.go
Map
func (t Result) Map() map[string]Result { if t.Type != JSON { return map[string]Result{} } r := t.arrayOrMap('{', false) return r.o }
go
func (t Result) Map() map[string]Result { if t.Type != JSON { return map[string]Result{} } r := t.arrayOrMap('{', false) return r.o }
[ "func", "(", "t", "Result", ")", "Map", "(", ")", "map", "[", "string", "]", "Result", "{", "if", "t", ".", "Type", "!=", "JSON", "{", "return", "map", "[", "string", "]", "Result", "{", "}", "\n", "}", "\n", "r", ":=", "t", ".", "arrayOrMap", ...
// Map returns back an map of values. The result should be a JSON array.
[ "Map", "returns", "back", "an", "map", "of", "values", ".", "The", "result", "should", "be", "a", "JSON", "array", "." ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L284-L290
166,281
tidwall/gjson
gjson.go
Get
func (t Result) Get(path string) Result { return Get(t.Raw, path) }
go
func (t Result) Get(path string) Result { return Get(t.Raw, path) }
[ "func", "(", "t", "Result", ")", "Get", "(", "path", "string", ")", "Result", "{", "return", "Get", "(", "t", ".", "Raw", ",", "path", ")", "\n", "}" ]
// Get searches result for the specified path. // The result should be a JSON array or object.
[ "Get", "searches", "result", "for", "the", "specified", "path", ".", "The", "result", "should", "be", "a", "JSON", "array", "or", "object", "." ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L294-L296
166,282
tidwall/gjson
gjson.go
Parse
func Parse(json string) Result { var value Result for i := 0; i < len(json); i++ { if json[i] == '{' || json[i] == '[' { value.Type = JSON value.Raw = json[i:] // just take the entire raw break } if json[i] <= ' ' { continue } switch json[i] { default: if (json[i] >= '0' && json[i] <= '9') ...
go
func Parse(json string) Result { var value Result for i := 0; i < len(json); i++ { if json[i] == '{' || json[i] == '[' { value.Type = JSON value.Raw = json[i:] // just take the entire raw break } if json[i] <= ' ' { continue } switch json[i] { default: if (json[i] >= '0' && json[i] <= '9') ...
[ "func", "Parse", "(", "json", "string", ")", "Result", "{", "var", "value", "Result", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "json", ")", ";", "i", "++", "{", "if", "json", "[", "i", "]", "==", "'{'", "||", "json", "[", "i", ...
// Parse parses the json and returns a result. // // This function expects that the json is well-formed, and does not validate. // Invalid json will not panic, but it may return back unexpected results. // If you are consuming JSON from an unpredictable source then you may want to // use the Valid function first.
[ "Parse", "parses", "the", "json", "and", "returns", "a", "result", ".", "This", "function", "expects", "that", "the", "json", "is", "well", "-", "formed", "and", "does", "not", "validate", ".", "Invalid", "json", "will", "not", "panic", "but", "it", "may...
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L421-L456
166,283
tidwall/gjson
gjson.go
runeit
func runeit(json string) rune { n, _ := strconv.ParseUint(json[:4], 16, 64) return rune(n) }
go
func runeit(json string) rune { n, _ := strconv.ParseUint(json[:4], 16, 64) return rune(n) }
[ "func", "runeit", "(", "json", "string", ")", "rune", "{", "n", ",", "_", ":=", "strconv", ".", "ParseUint", "(", "json", "[", ":", "4", "]", ",", "16", ",", "64", ")", "\n", "return", "rune", "(", "n", ")", "\n", "}" ]
// runeit returns the rune from the the \uXXXX
[ "runeit", "returns", "the", "rune", "from", "the", "the", "\\", "uXXXX" ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L1478-L1481
166,284
tidwall/gjson
gjson.go
unescape
func unescape(json string) string { //, error) { var str = make([]byte, 0, len(json)) for i := 0; i < len(json); i++ { switch { default: str = append(str, json[i]) case json[i] < ' ': return string(str) case json[i] == '\\': i++ if i >= len(json) { return string(str) } switch json[i] { ...
go
func unescape(json string) string { //, error) { var str = make([]byte, 0, len(json)) for i := 0; i < len(json); i++ { switch { default: str = append(str, json[i]) case json[i] < ' ': return string(str) case json[i] == '\\': i++ if i >= len(json) { return string(str) } switch json[i] { ...
[ "func", "unescape", "(", "json", "string", ")", "string", "{", "//, error) {", "var", "str", "=", "make", "(", "[", "]", "byte", ",", "0", ",", "len", "(", "json", ")", ")", "\n", "for", "i", ":=", "0", ";", "i", "<", "len", "(", "json", ")", ...
// unescape unescapes a string
[ "unescape", "unescapes", "a", "string" ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L1484-L1539
166,285
tidwall/gjson
gjson.go
GetMany
func GetMany(json string, path ...string) []Result { res := make([]Result, len(path)) for i, path := range path { res[i] = Get(json, path) } return res }
go
func GetMany(json string, path ...string) []Result { res := make([]Result, len(path)) for i, path := range path { res[i] = Get(json, path) } return res }
[ "func", "GetMany", "(", "json", "string", ",", "path", "...", "string", ")", "[", "]", "Result", "{", "res", ":=", "make", "(", "[", "]", "Result", ",", "len", "(", "path", ")", ")", "\n", "for", "i", ",", "path", ":=", "range", "path", "{", "r...
// GetMany searches json for the multiple paths. // The return value is a Result array where the number of items // will be equal to the number of input paths.
[ "GetMany", "searches", "json", "for", "the", "multiple", "paths", ".", "The", "return", "value", "is", "a", "Result", "array", "where", "the", "number", "of", "items", "will", "be", "equal", "to", "the", "number", "of", "input", "paths", "." ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L1674-L1680
166,286
tidwall/gjson
gjson.go
GetManyBytes
func GetManyBytes(json []byte, path ...string) []Result { res := make([]Result, len(path)) for i, path := range path { res[i] = GetBytes(json, path) } return res }
go
func GetManyBytes(json []byte, path ...string) []Result { res := make([]Result, len(path)) for i, path := range path { res[i] = GetBytes(json, path) } return res }
[ "func", "GetManyBytes", "(", "json", "[", "]", "byte", ",", "path", "...", "string", ")", "[", "]", "Result", "{", "res", ":=", "make", "(", "[", "]", "Result", ",", "len", "(", "path", ")", ")", "\n", "for", "i", ",", "path", ":=", "range", "p...
// GetManyBytes searches json for the multiple paths. // The return value is a Result array where the number of items // will be equal to the number of input paths.
[ "GetManyBytes", "searches", "json", "for", "the", "multiple", "paths", ".", "The", "return", "value", "is", "a", "Result", "array", "where", "the", "number", "of", "items", "will", "be", "equal", "to", "the", "number", "of", "input", "paths", "." ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L1685-L1691
166,287
tidwall/gjson
gjson.go
execModifier
func execModifier(json, path string) (pathOut, res string, ok bool) { name := path[1:] var hasArgs bool for i := 1; i < len(path); i++ { if path[i] == ':' { pathOut = path[i+1:] name = path[1:i] hasArgs = len(pathOut) > 0 break } if !DisableChaining { if path[i] == '|' { pathOut = path[i:] ...
go
func execModifier(json, path string) (pathOut, res string, ok bool) { name := path[1:] var hasArgs bool for i := 1; i < len(path); i++ { if path[i] == ':' { pathOut = path[i+1:] name = path[1:i] hasArgs = len(pathOut) > 0 break } if !DisableChaining { if path[i] == '|' { pathOut = path[i:] ...
[ "func", "execModifier", "(", "json", ",", "path", "string", ")", "(", "pathOut", ",", "res", "string", ",", "ok", "bool", ")", "{", "name", ":=", "path", "[", "1", ":", "]", "\n", "var", "hasArgs", "bool", "\n", "for", "i", ":=", "1", ";", "i", ...
// execModifier parses the path to find a matching modifier function. // then input expects that the path already starts with a '@'
[ "execModifier", "parses", "the", "path", "to", "find", "a", "matching", "modifier", "function", ".", "then", "input", "expects", "that", "the", "path", "already", "starts", "with", "a" ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L2175-L2223
166,288
tidwall/gjson
gjson.go
AddModifier
func AddModifier(name string, fn func(json, arg string) string) { modifiers[name] = fn }
go
func AddModifier(name string, fn func(json, arg string) string) { modifiers[name] = fn }
[ "func", "AddModifier", "(", "name", "string", ",", "fn", "func", "(", "json", ",", "arg", "string", ")", "string", ")", "{", "modifiers", "[", "name", "]", "=", "fn", "\n", "}" ]
// AddModifier binds a custom modifier command to the GJSON syntax. // This operation is not thread safe and should be executed prior to // using all other gjson function.
[ "AddModifier", "binds", "a", "custom", "modifier", "command", "to", "the", "GJSON", "syntax", ".", "This", "operation", "is", "not", "thread", "safe", "and", "should", "be", "executed", "prior", "to", "using", "all", "other", "gjson", "function", "." ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L2237-L2239
166,289
tidwall/gjson
gjson.go
ModifierExists
func ModifierExists(name string, fn func(json, arg string) string) bool { _, ok := modifiers[name] return ok }
go
func ModifierExists(name string, fn func(json, arg string) string) bool { _, ok := modifiers[name] return ok }
[ "func", "ModifierExists", "(", "name", "string", ",", "fn", "func", "(", "json", ",", "arg", "string", ")", "string", ")", "bool", "{", "_", ",", "ok", ":=", "modifiers", "[", "name", "]", "\n", "return", "ok", "\n", "}" ]
// ModifierExists returns true when the specified modifier exists.
[ "ModifierExists", "returns", "true", "when", "the", "specified", "modifier", "exists", "." ]
fb8e539484c9fb2df9f472bc0e3949a74c256f95
https://github.com/tidwall/gjson/blob/fb8e539484c9fb2df9f472bc0e3949a74c256f95/gjson.go#L2242-L2245
166,290
hashicorp/hcl
json/scanner/scanner.go
New
func New(src []byte) *Scanner { // even though we accept a src, we read from a io.Reader compatible type // (*bytes.Buffer). So in the future we might easily change it to streaming // read. b := bytes.NewBuffer(src) s := &Scanner{ buf: b, src: src, } // srcPosition always starts with 1 s.srcPos.Line = 1 r...
go
func New(src []byte) *Scanner { // even though we accept a src, we read from a io.Reader compatible type // (*bytes.Buffer). So in the future we might easily change it to streaming // read. b := bytes.NewBuffer(src) s := &Scanner{ buf: b, src: src, } // srcPosition always starts with 1 s.srcPos.Line = 1 r...
[ "func", "New", "(", "src", "[", "]", "byte", ")", "*", "Scanner", "{", "// even though we accept a src, we read from a io.Reader compatible type", "// (*bytes.Buffer). So in the future we might easily change it to streaming", "// read.", "b", ":=", "bytes", ".", "NewBuffer", "(...
// New creates and initializes a new instance of Scanner using src as // its source content.
[ "New", "creates", "and", "initializes", "a", "new", "instance", "of", "Scanner", "using", "src", "as", "its", "source", "content", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/scanner/scanner.go#L47-L60
166,291
hashicorp/hcl
json/scanner/scanner.go
unread
func (s *Scanner) unread() { if err := s.buf.UnreadRune(); err != nil { panic(err) // this is user fault, we should catch it } s.srcPos = s.prevPos // put back last position }
go
func (s *Scanner) unread() { if err := s.buf.UnreadRune(); err != nil { panic(err) // this is user fault, we should catch it } s.srcPos = s.prevPos // put back last position }
[ "func", "(", "s", "*", "Scanner", ")", "unread", "(", ")", "{", "if", "err", ":=", "s", ".", "buf", ".", "UnreadRune", "(", ")", ";", "err", "!=", "nil", "{", "panic", "(", "err", ")", "// this is user fault, we should catch it", "\n", "}", "\n", "s"...
// unread unreads the previous read Rune and updates the source position
[ "unread", "unreads", "the", "previous", "read", "Rune", "and", "updates", "the", "source", "position" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/scanner/scanner.go#L101-L106
166,292
hashicorp/hcl
json/scanner/scanner.go
peek
func (s *Scanner) peek() rune { peek, _, err := s.buf.ReadRune() if err != nil { return eof } s.buf.UnreadRune() return peek }
go
func (s *Scanner) peek() rune { peek, _, err := s.buf.ReadRune() if err != nil { return eof } s.buf.UnreadRune() return peek }
[ "func", "(", "s", "*", "Scanner", ")", "peek", "(", ")", "rune", "{", "peek", ",", "_", ",", "err", ":=", "s", ".", "buf", ".", "ReadRune", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "eof", "\n", "}", "\n\n", "s", ".", "buf", ...
// peek returns the next rune without advancing the reader.
[ "peek", "returns", "the", "next", "rune", "without", "advancing", "the", "reader", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/scanner/scanner.go#L109-L117
166,293
hashicorp/hcl
json/scanner/scanner.go
Scan
func (s *Scanner) Scan() token.Token { ch := s.next() // skip white space for isWhitespace(ch) { ch = s.next() } var tok token.Type // token text markings s.tokStart = s.srcPos.Offset - s.lastCharLen // token position, initial next() is moving the offset by one(size of rune // actually), though we are in...
go
func (s *Scanner) Scan() token.Token { ch := s.next() // skip white space for isWhitespace(ch) { ch = s.next() } var tok token.Type // token text markings s.tokStart = s.srcPos.Offset - s.lastCharLen // token position, initial next() is moving the offset by one(size of rune // actually), though we are in...
[ "func", "(", "s", "*", "Scanner", ")", "Scan", "(", ")", "token", ".", "Token", "{", "ch", ":=", "s", ".", "next", "(", ")", "\n\n", "// skip white space", "for", "isWhitespace", "(", "ch", ")", "{", "ch", "=", "s", ".", "next", "(", ")", "\n", ...
// Scan scans the next token and returns the token.
[ "Scan", "scans", "the", "next", "token", "and", "returns", "the", "token", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/scanner/scanner.go#L120-L214
166,294
hashicorp/hcl
json/scanner/scanner.go
scanMantissa
func (s *Scanner) scanMantissa(ch rune) rune { scanned := false for isDecimal(ch) { ch = s.next() scanned = true } if scanned && ch != eof { s.unread() } return ch }
go
func (s *Scanner) scanMantissa(ch rune) rune { scanned := false for isDecimal(ch) { ch = s.next() scanned = true } if scanned && ch != eof { s.unread() } return ch }
[ "func", "(", "s", "*", "Scanner", ")", "scanMantissa", "(", "ch", "rune", ")", "rune", "{", "scanned", ":=", "false", "\n", "for", "isDecimal", "(", "ch", ")", "{", "ch", "=", "s", ".", "next", "(", ")", "\n", "scanned", "=", "true", "\n", "}", ...
// scanMantissa scans the mantissa beginning from the rune. It returns the next // non decimal rune. It's used to determine wheter it's a fraction or exponent.
[ "scanMantissa", "scans", "the", "mantissa", "beginning", "from", "the", "rune", ".", "It", "returns", "the", "next", "non", "decimal", "rune", ".", "It", "s", "used", "to", "determine", "wheter", "it", "s", "a", "fraction", "or", "exponent", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/scanner/scanner.go#L251-L262
166,295
hashicorp/hcl
json/scanner/scanner.go
scanFraction
func (s *Scanner) scanFraction(ch rune) rune { if ch == '.' { ch = s.peek() // we peek just to see if we can move forward ch = s.scanMantissa(ch) } return ch }
go
func (s *Scanner) scanFraction(ch rune) rune { if ch == '.' { ch = s.peek() // we peek just to see if we can move forward ch = s.scanMantissa(ch) } return ch }
[ "func", "(", "s", "*", "Scanner", ")", "scanFraction", "(", "ch", "rune", ")", "rune", "{", "if", "ch", "==", "'.'", "{", "ch", "=", "s", ".", "peek", "(", ")", "// we peek just to see if we can move forward", "\n", "ch", "=", "s", ".", "scanMantissa", ...
// scanFraction scans the fraction after the '.' rune
[ "scanFraction", "scans", "the", "fraction", "after", "the", ".", "rune" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/scanner/scanner.go#L265-L271
166,296
hashicorp/hcl
json/scanner/scanner.go
scanExponent
func (s *Scanner) scanExponent(ch rune) rune { if ch == 'e' || ch == 'E' { ch = s.next() if ch == '-' || ch == '+' { ch = s.next() } ch = s.scanMantissa(ch) } return ch }
go
func (s *Scanner) scanExponent(ch rune) rune { if ch == 'e' || ch == 'E' { ch = s.next() if ch == '-' || ch == '+' { ch = s.next() } ch = s.scanMantissa(ch) } return ch }
[ "func", "(", "s", "*", "Scanner", ")", "scanExponent", "(", "ch", "rune", ")", "rune", "{", "if", "ch", "==", "'e'", "||", "ch", "==", "'E'", "{", "ch", "=", "s", ".", "next", "(", ")", "\n", "if", "ch", "==", "'-'", "||", "ch", "==", "'+'", ...
// scanExponent scans the remaining parts of an exponent after the 'e' or 'E' // rune.
[ "scanExponent", "scans", "the", "remaining", "parts", "of", "an", "exponent", "after", "the", "e", "or", "E", "rune", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/scanner/scanner.go#L275-L284
166,297
hashicorp/hcl
json/scanner/scanner.go
scanEscape
func (s *Scanner) scanEscape() rune { // http://en.cppreference.com/w/cpp/language/escape ch := s.next() // read character after '/' switch ch { case 'a', 'b', 'f', 'n', 'r', 't', 'v', '\\', '"': // nothing to do case '0', '1', '2', '3', '4', '5', '6', '7': // octal notation ch = s.scanDigits(ch, 8, 3) case...
go
func (s *Scanner) scanEscape() rune { // http://en.cppreference.com/w/cpp/language/escape ch := s.next() // read character after '/' switch ch { case 'a', 'b', 'f', 'n', 'r', 't', 'v', '\\', '"': // nothing to do case '0', '1', '2', '3', '4', '5', '6', '7': // octal notation ch = s.scanDigits(ch, 8, 3) case...
[ "func", "(", "s", "*", "Scanner", ")", "scanEscape", "(", ")", "rune", "{", "// http://en.cppreference.com/w/cpp/language/escape", "ch", ":=", "s", ".", "next", "(", ")", "// read character after '/'", "\n", "switch", "ch", "{", "case", "'a'", ",", "'b'", ",",...
// scanEscape scans an escape sequence
[ "scanEscape", "scans", "an", "escape", "sequence" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/scanner/scanner.go#L323-L345
166,298
hashicorp/hcl
json/scanner/scanner.go
scanIdentifier
func (s *Scanner) scanIdentifier() string { offs := s.srcPos.Offset - s.lastCharLen ch := s.next() for isLetter(ch) || isDigit(ch) || ch == '-' { ch = s.next() } if ch != eof { s.unread() // we got identifier, put back latest char } return string(s.src[offs:s.srcPos.Offset]) }
go
func (s *Scanner) scanIdentifier() string { offs := s.srcPos.Offset - s.lastCharLen ch := s.next() for isLetter(ch) || isDigit(ch) || ch == '-' { ch = s.next() } if ch != eof { s.unread() // we got identifier, put back latest char } return string(s.src[offs:s.srcPos.Offset]) }
[ "func", "(", "s", "*", "Scanner", ")", "scanIdentifier", "(", ")", "string", "{", "offs", ":=", "s", ".", "srcPos", ".", "Offset", "-", "s", ".", "lastCharLen", "\n", "ch", ":=", "s", ".", "next", "(", ")", "\n", "for", "isLetter", "(", "ch", ")"...
// scanIdentifier scans an identifier and returns the literal string
[ "scanIdentifier", "scans", "an", "identifier", "and", "returns", "the", "literal", "string" ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/scanner/scanner.go#L364-L376
166,299
hashicorp/hcl
json/scanner/scanner.go
recentPosition
func (s *Scanner) recentPosition() (pos token.Pos) { pos.Offset = s.srcPos.Offset - s.lastCharLen switch { case s.srcPos.Column > 0: // common case: last character was not a '\n' pos.Line = s.srcPos.Line pos.Column = s.srcPos.Column case s.lastLineLen > 0: // last character was a '\n' // (we cannot be at ...
go
func (s *Scanner) recentPosition() (pos token.Pos) { pos.Offset = s.srcPos.Offset - s.lastCharLen switch { case s.srcPos.Column > 0: // common case: last character was not a '\n' pos.Line = s.srcPos.Line pos.Column = s.srcPos.Column case s.lastLineLen > 0: // last character was a '\n' // (we cannot be at ...
[ "func", "(", "s", "*", "Scanner", ")", "recentPosition", "(", ")", "(", "pos", "token", ".", "Pos", ")", "{", "pos", ".", "Offset", "=", "s", ".", "srcPos", ".", "Offset", "-", "s", ".", "lastCharLen", "\n", "switch", "{", "case", "s", ".", "srcP...
// recentPosition returns the position of the character immediately after the // character or token returned by the last call to Scan.
[ "recentPosition", "returns", "the", "position", "of", "the", "character", "immediately", "after", "the", "character", "or", "token", "returned", "by", "the", "last", "call", "to", "Scan", "." ]
99e2f22d1c94b272184d97dd9d252866409100ab
https://github.com/hashicorp/hcl/blob/99e2f22d1c94b272184d97dd9d252866409100ab/json/scanner/scanner.go#L380-L399