id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
127,000
itsabot/itsabot
core/handlers.go
hapiAdminsUpdate
func hapiAdminsUpdate(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } if !isValidCSRF(w, r) { return } } var req struct { ID uint64 Email string Admin bool } if err := json.NewDecoder(r.Body).D...
go
func hapiAdminsUpdate(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } if !isValidCSRF(w, r) { return } } var req struct { ID uint64 Email string Admin bool } if err := json.NewDecoder(r.Body).D...
[ "func", "hapiAdminsUpdate", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "os", ".", "Getenv", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "if", "!", "isAdmin", "(", "w", ",", "r", ")", "{", "r...
// hapiAdminsUpdate adds or removes admin permission from a given user.
[ "hapiAdminsUpdate", "adds", "or", "removes", "admin", "permission", "from", "a", "given", "user", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L886-L944
127,001
itsabot/itsabot
core/handlers.go
hapiRemoteTokens
func hapiRemoteTokens(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } } // We initialize the variable here because we want empty slices to // marshal to [], not null auths := []struct { Token string E...
go
func hapiRemoteTokens(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } } // We initialize the variable here because we want empty slices to // marshal to [], not null auths := []struct { Token string E...
[ "func", "hapiRemoteTokens", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "os", ".", "Getenv", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "if", "!", "isAdmin", "(", "w", ",", "r", ")", "{", "r...
// hapiRemoteTokens returns the final six bytes of each auth token used to // authenticate to the remote service and when.
[ "hapiRemoteTokens", "returns", "the", "final", "six", "bytes", "of", "each", "auth", "token", "used", "to", "authenticate", "to", "the", "remote", "service", "and", "when", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L948-L981
127,002
itsabot/itsabot
core/handlers.go
hapiRemoteTokensSubmit
func hapiRemoteTokensSubmit(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } if !isValidCSRF(w, r) { return } } var req struct { Token string PluginIDs dt.Uint64Slice } if err := json.NewDecoder(...
go
func hapiRemoteTokensSubmit(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } if !isValidCSRF(w, r) { return } } var req struct { Token string PluginIDs dt.Uint64Slice } if err := json.NewDecoder(...
[ "func", "hapiRemoteTokensSubmit", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "os", ".", "Getenv", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "if", "!", "isAdmin", "(", "w", ",", "r", ")", "{"...
// hapiRemoteTokensSubmit adds a remote token for modifying ITSABOT_URL's // plugin training data.
[ "hapiRemoteTokensSubmit", "adds", "a", "remote", "token", "for", "modifying", "ITSABOT_URL", "s", "plugin", "training", "data", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L985-L1022
127,003
itsabot/itsabot
core/handlers.go
hapiRemoteTokensDelete
func hapiRemoteTokensDelete(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } if !isValidCSRF(w, r) { return } } var req struct { Token string Email string } if err := json.NewDecoder(r.Body).Decode(&...
go
func hapiRemoteTokensDelete(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } if !isValidCSRF(w, r) { return } } var req struct { Token string Email string } if err := json.NewDecoder(r.Body).Decode(&...
[ "func", "hapiRemoteTokensDelete", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "os", ".", "Getenv", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "if", "!", "isAdmin", "(", "w", ",", "r", ")", "{"...
// hapiRemoteTokensDelete removes a remote token from the DB and responds with // 200 OK.
[ "hapiRemoteTokensDelete", "removes", "a", "remote", "token", "from", "the", "DB", "and", "responds", "with", "200", "OK", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L1026-L1062
127,004
itsabot/itsabot
core/handlers.go
hapiSettingsUpdate
func hapiSettingsUpdate(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } } var req map[string]map[string]string if err := json.NewDecoder(r.Body).Decode(&req); err != nil { writeErrorBadRequest(w, err) retur...
go
func hapiSettingsUpdate(w http.ResponseWriter, r *http.Request) { if os.Getenv("ABOT_ENV") != "test" { if !isAdmin(w, r) { return } if !isLoggedIn(w, r) { return } } var req map[string]map[string]string if err := json.NewDecoder(r.Body).Decode(&req); err != nil { writeErrorBadRequest(w, err) retur...
[ "func", "hapiSettingsUpdate", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "if", "os", ".", "Getenv", "(", "\"", "\"", ")", "!=", "\"", "\"", "{", "if", "!", "isAdmin", "(", "w", ",", "r", ")", "{", ...
// hapiSettingsUpdate updates settings in the database for plugins.
[ "hapiSettingsUpdate", "updates", "settings", "in", "the", "database", "for", "plugins", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L1065-L1102
127,005
itsabot/itsabot
core/handlers.go
createCSRFToken
func createCSRFToken(u *dt.User) (token string, err error) { q := `INSERT INTO sessions (token, userid, label) VALUES ($1, $2, 'csrfToken') ON CONFLICT (userid, label) DO UPDATE SET token=$1` token = RandSeq(32) if _, err := db.Exec(q, token, u.ID); err != nil { return "", err } return token, nil }
go
func createCSRFToken(u *dt.User) (token string, err error) { q := `INSERT INTO sessions (token, userid, label) VALUES ($1, $2, 'csrfToken') ON CONFLICT (userid, label) DO UPDATE SET token=$1` token = RandSeq(32) if _, err := db.Exec(q, token, u.ID); err != nil { return "", err } return token, nil }
[ "func", "createCSRFToken", "(", "u", "*", "dt", ".", "User", ")", "(", "token", "string", ",", "err", "error", ")", "{", "q", ":=", "`INSERT INTO sessions (token, userid, label)\n\t VALUES ($1, $2, 'csrfToken')\n\t ON CONFLICT (userid, label) DO UPDATE SET token=$1`",...
// createCSRFToken creates a new token, invalidating any existing token.
[ "createCSRFToken", "creates", "a", "new", "token", "invalidating", "any", "existing", "token", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L1196-L1205
127,006
itsabot/itsabot
core/handlers.go
getAuthToken
func getAuthToken(u *dt.User) (header *Header, authToken string, err error) { scopes := []string{} if u.Admin { scopes = append(scopes, "admin") } header = &Header{ ID: u.ID, Email: u.Email, Scopes: scopes, IssuedAt: time.Now().Unix(), } byt, err := json.Marshal(header) if err != nil { ret...
go
func getAuthToken(u *dt.User) (header *Header, authToken string, err error) { scopes := []string{} if u.Admin { scopes = append(scopes, "admin") } header = &Header{ ID: u.ID, Email: u.Email, Scopes: scopes, IssuedAt: time.Now().Unix(), } byt, err := json.Marshal(header) if err != nil { ret...
[ "func", "getAuthToken", "(", "u", "*", "dt", ".", "User", ")", "(", "header", "*", "Header", ",", "authToken", "string", ",", "err", "error", ")", "{", "scopes", ":=", "[", "]", "string", "{", "}", "\n", "if", "u", ".", "Admin", "{", "scopes", "=...
// getAuthToken returns a token used for future client authorization with a CSRF // token.
[ "getAuthToken", "returns", "a", "token", "used", "for", "future", "client", "authorization", "with", "a", "CSRF", "token", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L1209-L1231
127,007
itsabot/itsabot
core/handlers.go
isValidCSRF
func isValidCSRF(w http.ResponseWriter, r *http.Request) bool { // TODO look into other session-based temporary storage systems for // these csrf tokens to prevent hitting the database. Whatever is // selected must *not* introduce an external (system) dependency like // memcached/Redis. Bolt might be an option. l...
go
func isValidCSRF(w http.ResponseWriter, r *http.Request) bool { // TODO look into other session-based temporary storage systems for // these csrf tokens to prevent hitting the database. Whatever is // selected must *not* introduce an external (system) dependency like // memcached/Redis. Bolt might be an option. l...
[ "func", "isValidCSRF", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "bool", "{", "// TODO look into other session-based temporary storage systems for", "// these csrf tokens to prevent hitting the database. Whatever is", "// selected must ...
// isValidCSRF ensures that any forms posted to Abot are protected against // Cross-Site Request Forgery. Without this function, Abot would be vulnerable // to the attack because tokens are stored client-side in cookies.
[ "isValidCSRF", "ensures", "that", "any", "forms", "posted", "to", "Abot", "are", "protected", "against", "Cross", "-", "Site", "Request", "Forgery", ".", "Without", "this", "function", "Abot", "would", "be", "vulnerable", "to", "the", "attack", "because", "tok...
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/handlers.go#L1414-L1453
127,008
itsabot/itsabot
shared/language/extract.go
ExtractCurrency
func ExtractCurrency(s string) (int64, error) { s = regexCurrency.FindString(s) if len(s) == 0 { return 0, ErrNotFound } val, err := strconv.ParseFloat(s, 64) if err != nil { return 0, err } log.Debug("found value", val) // Convert parsed float into an int64 with precision of 2 decimal places return int64(...
go
func ExtractCurrency(s string) (int64, error) { s = regexCurrency.FindString(s) if len(s) == 0 { return 0, ErrNotFound } val, err := strconv.ParseFloat(s, 64) if err != nil { return 0, err } log.Debug("found value", val) // Convert parsed float into an int64 with precision of 2 decimal places return int64(...
[ "func", "ExtractCurrency", "(", "s", "string", ")", "(", "int64", ",", "error", ")", "{", "s", "=", "regexCurrency", ".", "FindString", "(", "s", ")", "\n", "if", "len", "(", "s", ")", "==", "0", "{", "return", "0", ",", "ErrNotFound", "\n", "}", ...
// ExtractCurrency returns an int64 if a currency is found, and throws an // error if one isn't.
[ "ExtractCurrency", "returns", "an", "int64", "if", "a", "currency", "is", "found", "and", "throws", "an", "error", "if", "one", "isn", "t", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/language/extract.go#L30-L42
127,009
itsabot/itsabot
shared/language/extract.go
ExtractCities
func ExtractCities(db *sqlx.DB, in *dt.Msg) ([]dt.City, error) { // Interface type is used to expand the args in db.Select below. // Although we're only storing strings, []string{} doesn't work. var args []interface{} // Look for "at", "in", "on" prepositions to signal that locations // follow, skipping everythin...
go
func ExtractCities(db *sqlx.DB, in *dt.Msg) ([]dt.City, error) { // Interface type is used to expand the args in db.Select below. // Although we're only storing strings, []string{} doesn't work. var args []interface{} // Look for "at", "in", "on" prepositions to signal that locations // follow, skipping everythin...
[ "func", "ExtractCities", "(", "db", "*", "sqlx", ".", "DB", ",", "in", "*", "dt", ".", "Msg", ")", "(", "[", "]", "dt", ".", "City", ",", "error", ")", "{", "// Interface type is used to expand the args in db.Select below.", "// Although we're only storing strings...
// ExtractCities efficiently from a user's message.
[ "ExtractCities", "efficiently", "from", "a", "user", "s", "message", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/language/extract.go#L168-L226
127,010
itsabot/itsabot
shared/language/extract.go
ExtractEmails
func ExtractEmails(s string) ([]string, error) { emails := regexEmail.FindAllString(s, -1) if emails == nil { return []string{}, ErrNotFound } return emails, nil }
go
func ExtractEmails(s string) ([]string, error) { emails := regexEmail.FindAllString(s, -1) if emails == nil { return []string{}, ErrNotFound } return emails, nil }
[ "func", "ExtractEmails", "(", "s", "string", ")", "(", "[", "]", "string", ",", "error", ")", "{", "emails", ":=", "regexEmail", ".", "FindAllString", "(", "s", ",", "-", "1", ")", "\n", "if", "emails", "==", "nil", "{", "return", "[", "]", "string...
// ExtractEmails from a user's message.
[ "ExtractEmails", "from", "a", "user", "s", "message", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/language/extract.go#L229-L235
127,011
itsabot/itsabot
core/scheduled_event.go
sendEvents
func sendEvents(evtChan chan *dt.ScheduledEvent, interval time.Duration) { t := time.NewTicker(time.Minute) select { case now := <-t.C: sendEventsTick(evtChan, now) sendEvents(evtChan, interval) } }
go
func sendEvents(evtChan chan *dt.ScheduledEvent, interval time.Duration) { t := time.NewTicker(time.Minute) select { case now := <-t.C: sendEventsTick(evtChan, now) sendEvents(evtChan, interval) } }
[ "func", "sendEvents", "(", "evtChan", "chan", "*", "dt", ".", "ScheduledEvent", ",", "interval", "time", ".", "Duration", ")", "{", "t", ":=", "time", ".", "NewTicker", "(", "time", ".", "Minute", ")", "\n", "select", "{", "case", "now", ":=", "<-", ...
// sendEvents recursively calls itself to continue running.
[ "sendEvents", "recursively", "calls", "itself", "to", "continue", "running", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/core/scheduled_event.go#L11-L18
127,012
itsabot/itsabot
shared/datatypes/state_machine.go
NewStateMachine
func NewStateMachine(p *Plugin) *StateMachine { sm := StateMachine{ state: 0, plugin: p, } sm.states = map[string]int{} sm.resetFn = func(*Msg) {} return &sm }
go
func NewStateMachine(p *Plugin) *StateMachine { sm := StateMachine{ state: 0, plugin: p, } sm.states = map[string]int{} sm.resetFn = func(*Msg) {} return &sm }
[ "func", "NewStateMachine", "(", "p", "*", "Plugin", ")", "*", "StateMachine", "{", "sm", ":=", "StateMachine", "{", "state", ":", "0", ",", "plugin", ":", "p", ",", "}", "\n", "sm", ".", "states", "=", "map", "[", "string", "]", "int", "{", "}", ...
// NewStateMachine initializes a stateMachine to its starting state.
[ "NewStateMachine", "initializes", "a", "stateMachine", "to", "its", "starting", "state", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/state_machine.go#L79-L87
127,013
itsabot/itsabot
shared/datatypes/state_machine.go
LoadState
func (sm *StateMachine) LoadState(in *Msg) { tmp, err := json.Marshal(sm.state) if err != nil { sm.plugin.Log.Info("failed to marshal state for db.", err) return } // Using upsert to either insert and return a value or on conflict to // update and return a value doesn't work, leading to this longer form. // ...
go
func (sm *StateMachine) LoadState(in *Msg) { tmp, err := json.Marshal(sm.state) if err != nil { sm.plugin.Log.Info("failed to marshal state for db.", err) return } // Using upsert to either insert and return a value or on conflict to // update and return a value doesn't work, leading to this longer form. // ...
[ "func", "(", "sm", "*", "StateMachine", ")", "LoadState", "(", "in", "*", "Msg", ")", "{", "tmp", ",", "err", ":=", "json", ".", "Marshal", "(", "sm", ".", "state", ")", "\n", "if", "err", "!=", "nil", "{", "sm", ".", "plugin", ".", "Log", ".",...
// LoadState upserts state into the database. If there is an existing state for // a given user and plugin, the stateMachine will load it. If not, the // stateMachine will insert a starting state into the database.
[ "LoadState", "upserts", "state", "into", "the", "database", ".", "If", "there", "is", "an", "existing", "state", "for", "a", "given", "user", "and", "plugin", "the", "stateMachine", "will", "load", "it", ".", "If", "not", "the", "stateMachine", "will", "in...
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/state_machine.go#L109-L163
127,014
itsabot/itsabot
shared/datatypes/state_machine.go
setEntered
func (sm *StateMachine) setEntered(in *Msg) { sm.stateEntered = true sm.plugin.SetMemory(in, stateEnteredKey, true) }
go
func (sm *StateMachine) setEntered(in *Msg) { sm.stateEntered = true sm.plugin.SetMemory(in, stateEnteredKey, true) }
[ "func", "(", "sm", "*", "StateMachine", ")", "setEntered", "(", "in", "*", "Msg", ")", "{", "sm", ".", "stateEntered", "=", "true", "\n", "sm", ".", "plugin", ".", "SetMemory", "(", "in", ",", "stateEnteredKey", ",", "true", ")", "\n", "}" ]
// setEntered is used internally to set a state as having been entered both in // memory and persisted to the database. This ensures that a stateMachine does // not run a state's OnEntry function twice.
[ "setEntered", "is", "used", "internally", "to", "set", "a", "state", "as", "having", "been", "entered", "both", "in", "memory", "and", "persisted", "to", "the", "database", ".", "This", "ensures", "that", "a", "stateMachine", "does", "not", "run", "a", "st...
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/state_machine.go#L248-L251
127,015
itsabot/itsabot
shared/plugin/plugin.go
New
func New(url string) (*dt.Plugin, error) { if err := core.LoadEnvVars(); err != nil { log.Fatal(err) } db, err := core.ConnectDB("") if err != nil { return nil, err } // Read plugin.json data from within plugins.go, unmarshal into struct c := dt.PluginConfig{} if len(os.Getenv("ABOT_PATH")) > 0 { p := fi...
go
func New(url string) (*dt.Plugin, error) { if err := core.LoadEnvVars(); err != nil { log.Fatal(err) } db, err := core.ConnectDB("") if err != nil { return nil, err } // Read plugin.json data from within plugins.go, unmarshal into struct c := dt.PluginConfig{} if len(os.Getenv("ABOT_PATH")) > 0 { p := fi...
[ "func", "New", "(", "url", "string", ")", "(", "*", "dt", ".", "Plugin", ",", "error", ")", "{", "if", "err", ":=", "core", ".", "LoadEnvVars", "(", ")", ";", "err", "!=", "nil", "{", "log", ".", "Fatal", "(", "err", ")", "\n", "}", "\n", "db...
// New builds a Plugin with its trigger, RPC, and configuration settings from // its plugin.json.
[ "New", "builds", "a", "Plugin", "with", "its", "trigger", "RPC", "and", "configuration", "settings", "from", "its", "plugin", ".", "json", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/plugin/plugin.go#L31-L104
127,016
itsabot/itsabot
shared/plugin/plugin.go
SetKeywords
func SetKeywords(p *dt.Plugin, khs ...dt.KeywordHandler) { p.Keywords = &dt.Keywords{ Dict: map[string]dt.KeywordFn{}, } for _, kh := range khs { for _, intent := range kh.Trigger.Intents { intent = strings.ToLower(intent) if !language.Contains(p.Trigger.Intents, intent) { p.Trigger.Intents = append(p....
go
func SetKeywords(p *dt.Plugin, khs ...dt.KeywordHandler) { p.Keywords = &dt.Keywords{ Dict: map[string]dt.KeywordFn{}, } for _, kh := range khs { for _, intent := range kh.Trigger.Intents { intent = strings.ToLower(intent) if !language.Contains(p.Trigger.Intents, intent) { p.Trigger.Intents = append(p....
[ "func", "SetKeywords", "(", "p", "*", "dt", ".", "Plugin", ",", "khs", "...", "dt", ".", "KeywordHandler", ")", "{", "p", ".", "Keywords", "=", "&", "dt", ".", "Keywords", "{", "Dict", ":", "map", "[", "string", "]", "dt", ".", "KeywordFn", "{", ...
// SetKeywords processes and registers keywords with Abot's core for routing.
[ "SetKeywords", "processes", "and", "registers", "keywords", "with", "Abot", "s", "core", "for", "routing", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/plugin/plugin.go#L151-L184
127,017
itsabot/itsabot
shared/plugin/plugin.go
SetStates
func SetStates(p *dt.Plugin, states [][]dt.State) { p.States = []dt.State{} for _, ss := range states { p.States = append(p.States, ss...) } }
go
func SetStates(p *dt.Plugin, states [][]dt.State) { p.States = []dt.State{} for _, ss := range states { p.States = append(p.States, ss...) } }
[ "func", "SetStates", "(", "p", "*", "dt", ".", "Plugin", ",", "states", "[", "]", "[", "]", "dt", ".", "State", ")", "{", "p", ".", "States", "=", "[", "]", "dt", ".", "State", "{", "}", "\n", "for", "_", ",", "ss", ":=", "range", "states", ...
// SetStates is a convenience function provided to match the API of NewKeywords // and AppendTrigger.
[ "SetStates", "is", "a", "convenience", "function", "provided", "to", "match", "the", "API", "of", "NewKeywords", "and", "AppendTrigger", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/plugin/plugin.go#L188-L193
127,018
itsabot/itsabot
shared/plugin/plugin.go
AppendTrigger
func AppendTrigger(p *dt.Plugin, t *dt.StructuredInput) { eng := porter2.Stemmer for _, cmd := range t.Commands { cmd = eng.Stem(cmd) if !language.Contains(p.Trigger.Commands, cmd) { p.Trigger.Commands = append(p.Trigger.Commands, cmd) } } for _, obj := range t.Objects { obj = eng.Stem(obj) if !languag...
go
func AppendTrigger(p *dt.Plugin, t *dt.StructuredInput) { eng := porter2.Stemmer for _, cmd := range t.Commands { cmd = eng.Stem(cmd) if !language.Contains(p.Trigger.Commands, cmd) { p.Trigger.Commands = append(p.Trigger.Commands, cmd) } } for _, obj := range t.Objects { obj = eng.Stem(obj) if !languag...
[ "func", "AppendTrigger", "(", "p", "*", "dt", ".", "Plugin", ",", "t", "*", "dt", ".", "StructuredInput", ")", "{", "eng", ":=", "porter2", ".", "Stemmer", "\n", "for", "_", ",", "cmd", ":=", "range", "t", ".", "Commands", "{", "cmd", "=", "eng", ...
// AppendTrigger appends the StructuredInput's modified contents to a plugin. // All Commands and Objects stemmed using the Porter2 Snowball algorithm.
[ "AppendTrigger", "appends", "the", "StructuredInput", "s", "modified", "contents", "to", "a", "plugin", ".", "All", "Commands", "and", "Objects", "stemmed", "using", "the", "Porter2", "Snowball", "algorithm", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/plugin/plugin.go#L197-L211
127,019
itsabot/itsabot
shared/datatypes/user.go
GetUser
func GetUser(db *sqlx.DB, req *Request) (*User, error) { u := &User{} u.FlexID = req.FlexID u.FlexIDType = req.FlexIDType if req.UserID == 0 { if req.FlexID == "" { return nil, ErrMissingFlexID } switch req.FlexIDType { case FIDTEmail, FIDTPhone, FIDTSession: // Do nothing default: return nil, Er...
go
func GetUser(db *sqlx.DB, req *Request) (*User, error) { u := &User{} u.FlexID = req.FlexID u.FlexIDType = req.FlexIDType if req.UserID == 0 { if req.FlexID == "" { return nil, ErrMissingFlexID } switch req.FlexIDType { case FIDTEmail, FIDTPhone, FIDTSession: // Do nothing default: return nil, Er...
[ "func", "GetUser", "(", "db", "*", "sqlx", ".", "DB", ",", "req", "*", "Request", ")", "(", "*", "User", ",", "error", ")", "{", "u", ":=", "&", "User", "{", "}", "\n", "u", ".", "FlexID", "=", "req", ".", "FlexID", "\n", "u", ".", "FlexIDTyp...
// GetUser from an HTTP request.
[ "GetUser", "from", "an", "HTTP", "request", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/user.go#L63-L99
127,020
itsabot/itsabot
shared/datatypes/user.go
Create
func (u *User) Create(db *sqlx.DB, fidT FlexIDType, fid string) error { // Create the password hash hpw, err := bcrypt.GenerateFromPassword([]byte(u.Password), 10) if err != nil { return err } tx, err := db.Beginx() if err != nil { return err } q := `INSERT INTO users (name, email, password, locationid, adm...
go
func (u *User) Create(db *sqlx.DB, fidT FlexIDType, fid string) error { // Create the password hash hpw, err := bcrypt.GenerateFromPassword([]byte(u.Password), 10) if err != nil { return err } tx, err := db.Beginx() if err != nil { return err } q := `INSERT INTO users (name, email, password, locationid, adm...
[ "func", "(", "u", "*", "User", ")", "Create", "(", "db", "*", "sqlx", ".", "DB", ",", "fidT", "FlexIDType", ",", "fid", "string", ")", "error", "{", "// Create the password hash", "hpw", ",", "err", ":=", "bcrypt", ".", "GenerateFromPassword", "(", "[", ...
// Create a new user in the database.
[ "Create", "a", "new", "user", "in", "the", "database", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/user.go#L102-L143
127,021
itsabot/itsabot
shared/datatypes/user.go
DeleteSessions
func (u *User) DeleteSessions(db *sqlx.DB) error { q := `DELETE FROM sessions WHERE userid=$1` _, err := db.Exec(q, u.ID) if err != nil && err != sql.ErrNoRows { return err } return nil }
go
func (u *User) DeleteSessions(db *sqlx.DB) error { q := `DELETE FROM sessions WHERE userid=$1` _, err := db.Exec(q, u.ID) if err != nil && err != sql.ErrNoRows { return err } return nil }
[ "func", "(", "u", "*", "User", ")", "DeleteSessions", "(", "db", "*", "sqlx", ".", "DB", ")", "error", "{", "q", ":=", "`DELETE FROM sessions WHERE userid=$1`", "\n", "_", ",", "err", ":=", "db", ".", "Exec", "(", "q", ",", "u", ".", "ID", ")", "\n...
// DeleteSessions removes any open sessions by the user. This enables "logging // out" of the web-based client.
[ "DeleteSessions", "removes", "any", "open", "sessions", "by", "the", "user", ".", "This", "enables", "logging", "out", "of", "the", "web", "-", "based", "client", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/user.go#L147-L154
127,022
itsabot/itsabot
shared/datatypes/keywords.go
handle
func (k *Keywords) handle(m *Msg) string { if k == nil { return "" } for _, intent := range m.StructuredInput.Intents { fn, ok := k.Dict["I_"+intent] if !ok { continue } // If we find an intent function, use that. return fn(m) } // No matching intent was found, so check for both Command and Object...
go
func (k *Keywords) handle(m *Msg) string { if k == nil { return "" } for _, intent := range m.StructuredInput.Intents { fn, ok := k.Dict["I_"+intent] if !ok { continue } // If we find an intent function, use that. return fn(m) } // No matching intent was found, so check for both Command and Object...
[ "func", "(", "k", "*", "Keywords", ")", "handle", "(", "m", "*", "Msg", ")", "string", "{", "if", "k", "==", "nil", "{", "return", "\"", "\"", "\n", "}", "\n", "for", "_", ",", "intent", ":=", "range", "m", ".", "StructuredInput", ".", "Intents",...
// handle runs the first matching KeywordFn in the sentence.
[ "handle", "runs", "the", "first", "matching", "KeywordFn", "in", "the", "sentence", "." ]
48a5b1e70afca321d0c522922746b667c29a6070
https://github.com/itsabot/itsabot/blob/48a5b1e70afca321d0c522922746b667c29a6070/shared/datatypes/keywords.go#L29-L57
127,023
mdlayher/arp
client.go
Dial
func Dial(ifi *net.Interface) (*Client, error) { // Open raw socket to send and receive ARP packets using ethernet frames // we build ourselves. p, err := raw.ListenPacket(ifi, protocolARP, nil) if err != nil { return nil, err } return New(ifi, p) }
go
func Dial(ifi *net.Interface) (*Client, error) { // Open raw socket to send and receive ARP packets using ethernet frames // we build ourselves. p, err := raw.ListenPacket(ifi, protocolARP, nil) if err != nil { return nil, err } return New(ifi, p) }
[ "func", "Dial", "(", "ifi", "*", "net", ".", "Interface", ")", "(", "*", "Client", ",", "error", ")", "{", "// Open raw socket to send and receive ARP packets using ethernet frames", "// we build ourselves.", "p", ",", "err", ":=", "raw", ".", "ListenPacket", "(", ...
// Dial creates a new Client using the specified network interface. // Dial retrieves the IPv4 address of the interface and binds a raw socket // to send and receive ARP packets.
[ "Dial", "creates", "a", "new", "Client", "using", "the", "specified", "network", "interface", ".", "Dial", "retrieves", "the", "IPv4", "address", "of", "the", "interface", "and", "binds", "a", "raw", "socket", "to", "send", "and", "receive", "ARP", "packets"...
98a83c8a27177c5179d02d41ad50b0cce8e59338
https://github.com/mdlayher/arp/blob/98a83c8a27177c5179d02d41ad50b0cce8e59338/client.go#L33-L41
127,024
mdlayher/arp
client.go
newClient
func newClient(ifi *net.Interface, p net.PacketConn, addrs []net.Addr) (*Client, error) { ip, err := firstIPv4Addr(addrs) if err != nil { return nil, err } return &Client{ ifi: ifi, ip: ip, p: p, }, nil }
go
func newClient(ifi *net.Interface, p net.PacketConn, addrs []net.Addr) (*Client, error) { ip, err := firstIPv4Addr(addrs) if err != nil { return nil, err } return &Client{ ifi: ifi, ip: ip, p: p, }, nil }
[ "func", "newClient", "(", "ifi", "*", "net", ".", "Interface", ",", "p", "net", ".", "PacketConn", ",", "addrs", "[", "]", "net", ".", "Addr", ")", "(", "*", "Client", ",", "error", ")", "{", "ip", ",", "err", ":=", "firstIPv4Addr", "(", "addrs", ...
// newClient is the internal, generic implementation of newClient. It is used // to allow an arbitrary net.PacketConn to be used in a Client, so testing // is easier to accomplish.
[ "newClient", "is", "the", "internal", "generic", "implementation", "of", "newClient", ".", "It", "is", "used", "to", "allow", "an", "arbitrary", "net", ".", "PacketConn", "to", "be", "used", "in", "a", "Client", "so", "testing", "is", "easier", "to", "acco...
98a83c8a27177c5179d02d41ad50b0cce8e59338
https://github.com/mdlayher/arp/blob/98a83c8a27177c5179d02d41ad50b0cce8e59338/client.go#L61-L72
127,025
mdlayher/arp
client.go
Request
func (c *Client) Request(ip net.IP) error { if c.ip == nil { return errNoIPv4Addr } // Create ARP packet for broadcast address to attempt to find the // hardware address of the input IP address arp, err := NewPacket(OperationRequest, c.ifi.HardwareAddr, c.ip, ethernet.Broadcast, ip) if err != nil { return er...
go
func (c *Client) Request(ip net.IP) error { if c.ip == nil { return errNoIPv4Addr } // Create ARP packet for broadcast address to attempt to find the // hardware address of the input IP address arp, err := NewPacket(OperationRequest, c.ifi.HardwareAddr, c.ip, ethernet.Broadcast, ip) if err != nil { return er...
[ "func", "(", "c", "*", "Client", ")", "Request", "(", "ip", "net", ".", "IP", ")", "error", "{", "if", "c", ".", "ip", "==", "nil", "{", "return", "errNoIPv4Addr", "\n", "}", "\n\n", "// Create ARP packet for broadcast address to attempt to find the", "// hard...
// Request sends an ARP request, asking for the hardware address // associated with an IPv4 address. The response, if any, can be read // with the Read method. // // Unlike Resolve, which provides an easier interface for getting the // hardware address, Request allows sending many requests in a row, // retrieving the r...
[ "Request", "sends", "an", "ARP", "request", "asking", "for", "the", "hardware", "address", "associated", "with", "an", "IPv4", "address", ".", "The", "response", "if", "any", "can", "be", "read", "with", "the", "Read", "method", ".", "Unlike", "Resolve", "...
98a83c8a27177c5179d02d41ad50b0cce8e59338
https://github.com/mdlayher/arp/blob/98a83c8a27177c5179d02d41ad50b0cce8e59338/client.go#L87-L99
127,026
mdlayher/arp
client.go
Read
func (c *Client) Read() (*Packet, *ethernet.Frame, error) { buf := make([]byte, 128) for { n, _, err := c.p.ReadFrom(buf) if err != nil { return nil, nil, err } p, eth, err := parsePacket(buf[:n]) if err != nil { if err == errInvalidARPPacket { continue } return nil, nil, err } return p...
go
func (c *Client) Read() (*Packet, *ethernet.Frame, error) { buf := make([]byte, 128) for { n, _, err := c.p.ReadFrom(buf) if err != nil { return nil, nil, err } p, eth, err := parsePacket(buf[:n]) if err != nil { if err == errInvalidARPPacket { continue } return nil, nil, err } return p...
[ "func", "(", "c", "*", "Client", ")", "Read", "(", ")", "(", "*", "Packet", ",", "*", "ethernet", ".", "Frame", ",", "error", ")", "{", "buf", ":=", "make", "(", "[", "]", "byte", ",", "128", ")", "\n", "for", "{", "n", ",", "_", ",", "err"...
// Read reads a single ARP packet and returns it, together with its // ethernet frame.
[ "Read", "reads", "a", "single", "ARP", "packet", "and", "returns", "it", "together", "with", "its", "ethernet", "frame", "." ]
98a83c8a27177c5179d02d41ad50b0cce8e59338
https://github.com/mdlayher/arp/blob/98a83c8a27177c5179d02d41ad50b0cce8e59338/client.go#L129-L146
127,027
mdlayher/arp
client.go
WriteTo
func (c *Client) WriteTo(p *Packet, addr net.HardwareAddr) error { pb, err := p.MarshalBinary() if err != nil { return err } f := &ethernet.Frame{ Destination: p.TargetHardwareAddr, Source: p.SenderHardwareAddr, EtherType: ethernet.EtherTypeARP, Payload: pb, } fb, err := f.MarshalBinary() ...
go
func (c *Client) WriteTo(p *Packet, addr net.HardwareAddr) error { pb, err := p.MarshalBinary() if err != nil { return err } f := &ethernet.Frame{ Destination: p.TargetHardwareAddr, Source: p.SenderHardwareAddr, EtherType: ethernet.EtherTypeARP, Payload: pb, } fb, err := f.MarshalBinary() ...
[ "func", "(", "c", "*", "Client", ")", "WriteTo", "(", "p", "*", "Packet", ",", "addr", "net", ".", "HardwareAddr", ")", "error", "{", "pb", ",", "err", ":=", "p", ".", "MarshalBinary", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err...
// WriteTo writes a single ARP packet to addr. Note that addr should, // but doesn't have to, match the target hardware address of the ARP // packet.
[ "WriteTo", "writes", "a", "single", "ARP", "packet", "to", "addr", ".", "Note", "that", "addr", "should", "but", "doesn", "t", "have", "to", "match", "the", "target", "hardware", "address", "of", "the", "ARP", "packet", "." ]
98a83c8a27177c5179d02d41ad50b0cce8e59338
https://github.com/mdlayher/arp/blob/98a83c8a27177c5179d02d41ad50b0cce8e59338/client.go#L151-L171
127,028
mdlayher/arp
client.go
Reply
func (c *Client) Reply(req *Packet, hwAddr net.HardwareAddr, ip net.IP) error { p, err := NewPacket(OperationReply, hwAddr, ip, req.SenderHardwareAddr, req.SenderIP) if err != nil { return err } return c.WriteTo(p, req.SenderHardwareAddr) }
go
func (c *Client) Reply(req *Packet, hwAddr net.HardwareAddr, ip net.IP) error { p, err := NewPacket(OperationReply, hwAddr, ip, req.SenderHardwareAddr, req.SenderIP) if err != nil { return err } return c.WriteTo(p, req.SenderHardwareAddr) }
[ "func", "(", "c", "*", "Client", ")", "Reply", "(", "req", "*", "Packet", ",", "hwAddr", "net", ".", "HardwareAddr", ",", "ip", "net", ".", "IP", ")", "error", "{", "p", ",", "err", ":=", "NewPacket", "(", "OperationReply", ",", "hwAddr", ",", "ip"...
// Reply constructs and sends a reply to an ARP request. On the ARP // layer, it will be addressed to the sender address of the packet. On // the ethernet layer, it will be sent to the actual remote address // from which the request was received. // // For more fine-grained control, use WriteTo to write a custom // res...
[ "Reply", "constructs", "and", "sends", "a", "reply", "to", "an", "ARP", "request", ".", "On", "the", "ARP", "layer", "it", "will", "be", "addressed", "to", "the", "sender", "address", "of", "the", "packet", ".", "On", "the", "ethernet", "layer", "it", ...
98a83c8a27177c5179d02d41ad50b0cce8e59338
https://github.com/mdlayher/arp/blob/98a83c8a27177c5179d02d41ad50b0cce8e59338/client.go#L180-L186
127,029
mdlayher/arp
client.go
firstIPv4Addr
func firstIPv4Addr(addrs []net.Addr) (net.IP, error) { for _, a := range addrs { if a.Network() != "ip+net" { continue } ip, _, err := net.ParseCIDR(a.String()) if err != nil { return nil, err } // "If ip is not an IPv4 address, To4 returns nil." // Reference: http://golang.org/pkg/net/#IP.To4 ...
go
func firstIPv4Addr(addrs []net.Addr) (net.IP, error) { for _, a := range addrs { if a.Network() != "ip+net" { continue } ip, _, err := net.ParseCIDR(a.String()) if err != nil { return nil, err } // "If ip is not an IPv4 address, To4 returns nil." // Reference: http://golang.org/pkg/net/#IP.To4 ...
[ "func", "firstIPv4Addr", "(", "addrs", "[", "]", "net", ".", "Addr", ")", "(", "net", ".", "IP", ",", "error", ")", "{", "for", "_", ",", "a", ":=", "range", "addrs", "{", "if", "a", ".", "Network", "(", ")", "!=", "\"", "\"", "{", "continue", ...
// firstIPv4Addr attempts to retrieve the first detected IPv4 address from an // input slice of network addresses.
[ "firstIPv4Addr", "attempts", "to", "retrieve", "the", "first", "detected", "IPv4", "address", "from", "an", "input", "slice", "of", "network", "addresses", "." ]
98a83c8a27177c5179d02d41ad50b0cce8e59338
https://github.com/mdlayher/arp/blob/98a83c8a27177c5179d02d41ad50b0cce8e59338/client.go#L228-L247
127,030
mdlayher/arp
packet.go
MarshalBinary
func (p *Packet) MarshalBinary() ([]byte, error) { // 2 bytes: hardware type // 2 bytes: protocol type // 1 byte : hardware address length // 1 byte : protocol length // 2 bytes: operation // N bytes: source hardware address // N bytes: source protocol address // N bytes: target hardware address // N bytes: ta...
go
func (p *Packet) MarshalBinary() ([]byte, error) { // 2 bytes: hardware type // 2 bytes: protocol type // 1 byte : hardware address length // 1 byte : protocol length // 2 bytes: operation // N bytes: source hardware address // N bytes: source protocol address // N bytes: target hardware address // N bytes: ta...
[ "func", "(", "p", "*", "Packet", ")", "MarshalBinary", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "// 2 bytes: hardware type", "// 2 bytes: protocol type", "// 1 byte : hardware address length", "// 1 byte : protocol length", "// 2 bytes: operation", "// N b...
// MarshalBinary allocates a byte slice containing the data from a Packet. // // MarshalBinary never returns an error.
[ "MarshalBinary", "allocates", "a", "byte", "slice", "containing", "the", "data", "from", "a", "Packet", ".", "MarshalBinary", "never", "returns", "an", "error", "." ]
98a83c8a27177c5179d02d41ad50b0cce8e59338
https://github.com/mdlayher/arp/blob/98a83c8a27177c5179d02d41ad50b0cce8e59338/packet.go#L127-L172
127,031
mdlayher/arp
packet.go
UnmarshalBinary
func (p *Packet) UnmarshalBinary(b []byte) error { // Must have enough room to retrieve hardware address and IP lengths if len(b) < 8 { return io.ErrUnexpectedEOF } // Retrieve fixed length data p.HardwareType = binary.BigEndian.Uint16(b[0:2]) p.ProtocolType = binary.BigEndian.Uint16(b[2:4]) p.HardwareAddrL...
go
func (p *Packet) UnmarshalBinary(b []byte) error { // Must have enough room to retrieve hardware address and IP lengths if len(b) < 8 { return io.ErrUnexpectedEOF } // Retrieve fixed length data p.HardwareType = binary.BigEndian.Uint16(b[0:2]) p.ProtocolType = binary.BigEndian.Uint16(b[2:4]) p.HardwareAddrL...
[ "func", "(", "p", "*", "Packet", ")", "UnmarshalBinary", "(", "b", "[", "]", "byte", ")", "error", "{", "// Must have enough room to retrieve hardware address and IP lengths", "if", "len", "(", "b", ")", "<", "8", "{", "return", "io", ".", "ErrUnexpectedEOF", ...
// UnmarshalBinary unmarshals a raw byte slice into a Packet.
[ "UnmarshalBinary", "unmarshals", "a", "raw", "byte", "slice", "into", "a", "Packet", "." ]
98a83c8a27177c5179d02d41ad50b0cce8e59338
https://github.com/mdlayher/arp/blob/98a83c8a27177c5179d02d41ad50b0cce8e59338/packet.go#L175-L232
127,032
nleof/goyesql
goyesql.go
ParseFile
func ParseFile(path string) (Queries, error) { file, err := os.Open(path) if err != nil { return nil, err } defer file.Close() return ParseReader(file) }
go
func ParseFile(path string) (Queries, error) { file, err := os.Open(path) if err != nil { return nil, err } defer file.Close() return ParseReader(file) }
[ "func", "ParseFile", "(", "path", "string", ")", "(", "Queries", ",", "error", ")", "{", "file", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", "defer", ...
// Some helpers to read files // ParseFile reads a file and return Queries or an error
[ "Some", "helpers", "to", "read", "files", "ParseFile", "reads", "a", "file", "and", "return", "Queries", "or", "an", "error" ]
531a8afe09e9f59b27f7988fae377ecdc015eb11
https://github.com/nleof/goyesql/blob/531a8afe09e9f59b27f7988fae377ecdc015eb11/goyesql.go#L16-L24
127,033
nleof/goyesql
goyesql.go
MustParseFile
func MustParseFile(path string) Queries { queries, err := ParseFile(path) if err != nil { panic(err) } return queries }
go
func MustParseFile(path string) Queries { queries, err := ParseFile(path) if err != nil { panic(err) } return queries }
[ "func", "MustParseFile", "(", "path", "string", ")", "Queries", "{", "queries", ",", "err", ":=", "ParseFile", "(", "path", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n\n", "return", "queries", "\n", "}" ]
// MustParseFile calls ParseFile but panic if an error occurs
[ "MustParseFile", "calls", "ParseFile", "but", "panic", "if", "an", "error", "occurs" ]
531a8afe09e9f59b27f7988fae377ecdc015eb11
https://github.com/nleof/goyesql/blob/531a8afe09e9f59b27f7988fae377ecdc015eb11/goyesql.go#L27-L34
127,034
nleof/goyesql
goyesql.go
MustParseBytes
func MustParseBytes(b []byte) Queries { queries, err := ParseBytes(b) if err != nil { panic(err) } return queries }
go
func MustParseBytes(b []byte) Queries { queries, err := ParseBytes(b) if err != nil { panic(err) } return queries }
[ "func", "MustParseBytes", "(", "b", "[", "]", "byte", ")", "Queries", "{", "queries", ",", "err", ":=", "ParseBytes", "(", "b", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n\n", "return", "queries", "\n", "}" ]
// MustParseBytes parses bytes but panics if an error occurs.
[ "MustParseBytes", "parses", "bytes", "but", "panics", "if", "an", "error", "occurs", "." ]
531a8afe09e9f59b27f7988fae377ecdc015eb11
https://github.com/nleof/goyesql/blob/531a8afe09e9f59b27f7988fae377ecdc015eb11/goyesql.go#L42-L49
127,035
nleof/goyesql
scanner.go
ParseReader
func ParseReader(reader io.Reader) (Queries, error) { var ( lastTag Tag lastLine parsedLine ) queries := make(Queries) scanner := bufio.NewScanner(reader) for scanner.Scan() { line := parseLine(scanner.Text()) switch line.Type { case lineBlank, lineComment: // we don't care about blank and commen...
go
func ParseReader(reader io.Reader) (Queries, error) { var ( lastTag Tag lastLine parsedLine ) queries := make(Queries) scanner := bufio.NewScanner(reader) for scanner.Scan() { line := parseLine(scanner.Text()) switch line.Type { case lineBlank, lineComment: // we don't care about blank and commen...
[ "func", "ParseReader", "(", "reader", "io", ".", "Reader", ")", "(", "Queries", ",", "error", ")", "{", "var", "(", "lastTag", "Tag", "\n", "lastLine", "parsedLine", "\n", ")", "\n\n", "queries", ":=", "make", "(", "Queries", ")", "\n", "scanner", ":="...
// ParseReader takes an io.Reader and returns Queries or an error.
[ "ParseReader", "takes", "an", "io", ".", "Reader", "and", "returns", "Queries", "or", "an", "error", "." ]
531a8afe09e9f59b27f7988fae377ecdc015eb11
https://github.com/nleof/goyesql/blob/531a8afe09e9f59b27f7988fae377ecdc015eb11/scanner.go#L24-L73
127,036
cactus/go-statsd-client
statsd/client.go
Close
func (s *Client) Close() error { if s == nil { return nil } err := s.sender.Close() return err }
go
func (s *Client) Close() error { if s == nil { return nil } err := s.sender.Close() return err }
[ "func", "(", "s", "*", "Client", ")", "Close", "(", ")", "error", "{", "if", "s", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "err", ":=", "s", ".", "sender", ".", "Close", "(", ")", "\n", "return", "err", "\n", "}" ]
// Close closes the connection and cleans up.
[ "Close", "closes", "the", "connection", "and", "cleans", "up", "." ]
9a76926395884c24387e06773401e4d54cdee9df
https://github.com/cactus/go-statsd-client/blob/9a76926395884c24387e06773401e4d54cdee9df/statsd/client.go#L68-L75
127,037
cactus/go-statsd-client
statsd/client.go
submit
func (s *Client) submit(stat, vprefix string, value interface{}, suffix string, rate float32) error { data := bufPool.Get() defer bufPool.Put(data) if s.prefix != "" { data.WriteString(s.prefix) data.WriteString(".") } data.WriteString(stat) data.WriteString(":") if vprefix != "" { data.WriteString(vpre...
go
func (s *Client) submit(stat, vprefix string, value interface{}, suffix string, rate float32) error { data := bufPool.Get() defer bufPool.Put(data) if s.prefix != "" { data.WriteString(s.prefix) data.WriteString(".") } data.WriteString(stat) data.WriteString(":") if vprefix != "" { data.WriteString(vpre...
[ "func", "(", "s", "*", "Client", ")", "submit", "(", "stat", ",", "vprefix", "string", ",", "value", "interface", "{", "}", ",", "suffix", "string", ",", "rate", "float32", ")", "error", "{", "data", ":=", "bufPool", ".", "Get", "(", ")", "\n", "de...
// submit an already sampled raw stat
[ "submit", "an", "already", "sampled", "raw", "stat" ]
9a76926395884c24387e06773401e4d54cdee9df
https://github.com/cactus/go-statsd-client/blob/9a76926395884c24387e06773401e4d54cdee9df/statsd/client.go#L200-L243
127,038
cactus/go-statsd-client
statsd/client.go
includeStat
func (s *Client) includeStat(rate float32) bool { if s == nil { return false } // test for nil in case someone builds their own // client without calling new (result is nil sampler) if s.sampler != nil { return s.sampler(rate) } return DefaultSampler(rate) }
go
func (s *Client) includeStat(rate float32) bool { if s == nil { return false } // test for nil in case someone builds their own // client without calling new (result is nil sampler) if s.sampler != nil { return s.sampler(rate) } return DefaultSampler(rate) }
[ "func", "(", "s", "*", "Client", ")", "includeStat", "(", "rate", "float32", ")", "bool", "{", "if", "s", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "// test for nil in case someone builds their own", "// client without calling new (result is nil sampler)...
// check for nil client, and perform sampling calculation
[ "check", "for", "nil", "client", "and", "perform", "sampling", "calculation" ]
9a76926395884c24387e06773401e4d54cdee9df
https://github.com/cactus/go-statsd-client/blob/9a76926395884c24387e06773401e4d54cdee9df/statsd/client.go#L246-L257
127,039
cactus/go-statsd-client
statsd/client.go
NewSubStatter
func (s *Client) NewSubStatter(prefix string) SubStatter { var c *Client if s != nil { c = &Client{ prefix: joinPathComp(s.prefix, prefix), sender: s.sender, sampler: s.sampler, } } return c }
go
func (s *Client) NewSubStatter(prefix string) SubStatter { var c *Client if s != nil { c = &Client{ prefix: joinPathComp(s.prefix, prefix), sender: s.sender, sampler: s.sampler, } } return c }
[ "func", "(", "s", "*", "Client", ")", "NewSubStatter", "(", "prefix", "string", ")", "SubStatter", "{", "var", "c", "*", "Client", "\n", "if", "s", "!=", "nil", "{", "c", "=", "&", "Client", "{", "prefix", ":", "joinPathComp", "(", "s", ".", "prefi...
// NewSubStatter returns a SubStatter with appended prefix
[ "NewSubStatter", "returns", "a", "SubStatter", "with", "appended", "prefix" ]
9a76926395884c24387e06773401e4d54cdee9df
https://github.com/cactus/go-statsd-client/blob/9a76926395884c24387e06773401e4d54cdee9df/statsd/client.go#L270-L280
127,040
cactus/go-statsd-client
statsd/client.go
NewClientWithSender
func NewClientWithSender(sender Sender, prefix string) (Statter, error) { if sender == nil { return nil, fmt.Errorf("Client sender may not be nil") } return &Client{prefix: prefix, sender: sender}, nil }
go
func NewClientWithSender(sender Sender, prefix string) (Statter, error) { if sender == nil { return nil, fmt.Errorf("Client sender may not be nil") } return &Client{prefix: prefix, sender: sender}, nil }
[ "func", "NewClientWithSender", "(", "sender", "Sender", ",", "prefix", "string", ")", "(", "Statter", ",", "error", ")", "{", "if", "sender", "==", "nil", "{", "return", "nil", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n", "}", "\n\n", "retu...
// NewClientWithSender returns a pointer to a new Client and an error. // // sender is an instance of a statsd.Sender interface and may not be nil // // prefix is the stastd client prefix. Can be "" if no prefix is desired.
[ "NewClientWithSender", "returns", "a", "pointer", "to", "a", "new", "Client", "and", "an", "error", ".", "sender", "is", "an", "instance", "of", "a", "statsd", ".", "Sender", "interface", "and", "may", "not", "be", "nil", "prefix", "is", "the", "stastd", ...
9a76926395884c24387e06773401e4d54cdee9df
https://github.com/cactus/go-statsd-client/blob/9a76926395884c24387e06773401e4d54cdee9df/statsd/client.go#L302-L308
127,041
cactus/go-statsd-client
statsd/client.go
joinPathComp
func joinPathComp(prefix, suffix string) string { suffix = strings.TrimLeft(suffix, ".") if prefix != "" && suffix != "" { return prefix + "." + suffix } return prefix + suffix }
go
func joinPathComp(prefix, suffix string) string { suffix = strings.TrimLeft(suffix, ".") if prefix != "" && suffix != "" { return prefix + "." + suffix } return prefix + suffix }
[ "func", "joinPathComp", "(", "prefix", ",", "suffix", "string", ")", "string", "{", "suffix", "=", "strings", ".", "TrimLeft", "(", "suffix", ",", "\"", "\"", ")", "\n", "if", "prefix", "!=", "\"", "\"", "&&", "suffix", "!=", "\"", "\"", "{", "return...
// joinPathComp is a helper that ensures we combine path components with a dot // when it's appropriate to do so; prefix is the existing prefix and suffix is // the new component being added. // // It returns the joined prefix.
[ "joinPathComp", "is", "a", "helper", "that", "ensures", "we", "combine", "path", "components", "with", "a", "dot", "when", "it", "s", "appropriate", "to", "do", "so", ";", "prefix", "is", "the", "existing", "prefix", "and", "suffix", "is", "the", "new", ...
9a76926395884c24387e06773401e4d54cdee9df
https://github.com/cactus/go-statsd-client/blob/9a76926395884c24387e06773401e4d54cdee9df/statsd/client.go#L315-L321
127,042
cactus/go-statsd-client
statsd/sender_buffered.go
Send
func (s *BufferedSender) Send(data []byte) (int, error) { s.runmx.RLock() if !s.running { s.runmx.RUnlock() return 0, fmt.Errorf("BufferedSender is not running") } s.withBufferLock(func() { blen := s.buffer.Len() if blen > 0 && blen+len(data)+1 >= s.flushBytes { s.swapnqueue() } s.buffer.Write(data...
go
func (s *BufferedSender) Send(data []byte) (int, error) { s.runmx.RLock() if !s.running { s.runmx.RUnlock() return 0, fmt.Errorf("BufferedSender is not running") } s.withBufferLock(func() { blen := s.buffer.Len() if blen > 0 && blen+len(data)+1 >= s.flushBytes { s.swapnqueue() } s.buffer.Write(data...
[ "func", "(", "s", "*", "BufferedSender", ")", "Send", "(", "data", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "s", ".", "runmx", ".", "RLock", "(", ")", "\n", "if", "!", "s", ".", "running", "{", "s", ".", "runmx", ".", "RUnlo...
// Send bytes.
[ "Send", "bytes", "." ]
9a76926395884c24387e06773401e4d54cdee9df
https://github.com/cactus/go-statsd-client/blob/9a76926395884c24387e06773401e4d54cdee9df/statsd/sender_buffered.go#L33-L55
127,043
cactus/go-statsd-client
statsd/sender_buffered.go
Close
func (s *BufferedSender) Close() error { // since we are running, write lock during cleanup s.runmx.Lock() defer s.runmx.Unlock() if !s.running { return nil } errChan := make(chan error) s.running = false s.shutdown <- errChan return <-errChan }
go
func (s *BufferedSender) Close() error { // since we are running, write lock during cleanup s.runmx.Lock() defer s.runmx.Unlock() if !s.running { return nil } errChan := make(chan error) s.running = false s.shutdown <- errChan return <-errChan }
[ "func", "(", "s", "*", "BufferedSender", ")", "Close", "(", ")", "error", "{", "// since we are running, write lock during cleanup", "s", ".", "runmx", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "runmx", ".", "Unlock", "(", ")", "\n", "if", "!", "s"...
// Close Buffered Sender
[ "Close", "Buffered", "Sender" ]
9a76926395884c24387e06773401e4d54cdee9df
https://github.com/cactus/go-statsd-client/blob/9a76926395884c24387e06773401e4d54cdee9df/statsd/sender_buffered.go#L58-L70
127,044
cactus/go-statsd-client
statsd/sender_buffered.go
Start
func (s *BufferedSender) Start() { // write lock to start running s.runmx.Lock() defer s.runmx.Unlock() if s.running { return } s.running = true s.bufs = make(chan *bytes.Buffer, 32) go s.run() }
go
func (s *BufferedSender) Start() { // write lock to start running s.runmx.Lock() defer s.runmx.Unlock() if s.running { return } s.running = true s.bufs = make(chan *bytes.Buffer, 32) go s.run() }
[ "func", "(", "s", "*", "BufferedSender", ")", "Start", "(", ")", "{", "// write lock to start running", "s", ".", "runmx", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "runmx", ".", "Unlock", "(", ")", "\n", "if", "s", ".", "running", "{", "return...
// Start Buffered Sender // Begins ticker and read loop
[ "Start", "Buffered", "Sender", "Begins", "ticker", "and", "read", "loop" ]
9a76926395884c24387e06773401e4d54cdee9df
https://github.com/cactus/go-statsd-client/blob/9a76926395884c24387e06773401e4d54cdee9df/statsd/sender_buffered.go#L74-L85
127,045
cactus/go-statsd-client
statsd/sender_buffered.go
flush
func (s *BufferedSender) flush(b *bytes.Buffer) (int, error) { bb := b.Bytes() bbl := len(bb) if bb[bbl-1] == '\n' { bb = bb[:bbl-1] } //n, err := s.sender.Send(bytes.TrimSuffix(b.Bytes(), []byte("\n"))) n, err := s.sender.Send(bb) b.Truncate(0) // clear the buffer return n, err }
go
func (s *BufferedSender) flush(b *bytes.Buffer) (int, error) { bb := b.Bytes() bbl := len(bb) if bb[bbl-1] == '\n' { bb = bb[:bbl-1] } //n, err := s.sender.Send(bytes.TrimSuffix(b.Bytes(), []byte("\n"))) n, err := s.sender.Send(bb) b.Truncate(0) // clear the buffer return n, err }
[ "func", "(", "s", "*", "BufferedSender", ")", "flush", "(", "b", "*", "bytes", ".", "Buffer", ")", "(", "int", ",", "error", ")", "{", "bb", ":=", "b", ".", "Bytes", "(", ")", "\n", "bbl", ":=", "len", "(", "bb", ")", "\n", "if", "bb", "[", ...
// send to remove endpoint and truncate buffer
[ "send", "to", "remove", "endpoint", "and", "truncate", "buffer" ]
9a76926395884c24387e06773401e4d54cdee9df
https://github.com/cactus/go-statsd-client/blob/9a76926395884c24387e06773401e4d54cdee9df/statsd/sender_buffered.go#L135-L145
127,046
cactus/go-statsd-client
statsd/validator.go
CheckName
func CheckName(stat string) error { if !safeName.MatchString(stat) { return fmt.Errorf("invalid stat name: %s", stat) } return nil }
go
func CheckName(stat string) error { if !safeName.MatchString(stat) { return fmt.Errorf("invalid stat name: %s", stat) } return nil }
[ "func", "CheckName", "(", "stat", "string", ")", "error", "{", "if", "!", "safeName", ".", "MatchString", "(", "stat", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "stat", ")", "\n", "}", "\n", "return", "nil", "\n", "}" ]
// CheckName may be used to validate whether a stat name contains invalid // characters. If invalid characters are found, the function will return an // error.
[ "CheckName", "may", "be", "used", "to", "validate", "whether", "a", "stat", "name", "contains", "invalid", "characters", ".", "If", "invalid", "characters", "are", "found", "the", "function", "will", "return", "an", "error", "." ]
9a76926395884c24387e06773401e4d54cdee9df
https://github.com/cactus/go-statsd-client/blob/9a76926395884c24387e06773401e4d54cdee9df/statsd/validator.go#L21-L26
127,047
cactus/go-statsd-client
statsd/sender.go
Send
func (s *SimpleSender) Send(data []byte) (int, error) { // no need for locking here, as the underlying fdNet // already serialized writes n, err := s.c.(*net.UDPConn).WriteToUDP(data, s.ra) if err != nil { return 0, err } if n == 0 { return n, errors.New("Wrote no bytes") } return n, nil }
go
func (s *SimpleSender) Send(data []byte) (int, error) { // no need for locking here, as the underlying fdNet // already serialized writes n, err := s.c.(*net.UDPConn).WriteToUDP(data, s.ra) if err != nil { return 0, err } if n == 0 { return n, errors.New("Wrote no bytes") } return n, nil }
[ "func", "(", "s", "*", "SimpleSender", ")", "Send", "(", "data", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "// no need for locking here, as the underlying fdNet", "// already serialized writes", "n", ",", "err", ":=", "s", ".", "c", ".", "("...
// Send sends the data to the server endpoint.
[ "Send", "sends", "the", "data", "to", "the", "server", "endpoint", "." ]
9a76926395884c24387e06773401e4d54cdee9df
https://github.com/cactus/go-statsd-client/blob/9a76926395884c24387e06773401e4d54cdee9df/statsd/sender.go#L27-L38
127,048
gobuffalo/validate
validate.go
NewErrors
func NewErrors() *Errors { return &Errors{ Errors: make(map[string][]string), Lock: new(sync.RWMutex), } }
go
func NewErrors() *Errors { return &Errors{ Errors: make(map[string][]string), Lock: new(sync.RWMutex), } }
[ "func", "NewErrors", "(", ")", "*", "Errors", "{", "return", "&", "Errors", "{", "Errors", ":", "make", "(", "map", "[", "string", "]", "[", "]", "string", ")", ",", "Lock", ":", "new", "(", "sync", ".", "RWMutex", ")", ",", "}", "\n", "}" ]
// NewErrors returns a pointer to a Errors // object that has been primed and ready to go.
[ "NewErrors", "returns", "a", "pointer", "to", "a", "Errors", "object", "that", "has", "been", "primed", "and", "ready", "to", "go", "." ]
2ada686bcfc51eb528382b5134818852f918fe24
https://github.com/gobuffalo/validate/blob/2ada686bcfc51eb528382b5134818852f918fe24/validate.go#L69-L74
127,049
gobuffalo/validate
validate.go
Append
func (v *Errors) Append(ers *Errors) { for key, value := range ers.Errors { for _, msg := range value { v.Add(key, msg) } } }
go
func (v *Errors) Append(ers *Errors) { for key, value := range ers.Errors { for _, msg := range value { v.Add(key, msg) } } }
[ "func", "(", "v", "*", "Errors", ")", "Append", "(", "ers", "*", "Errors", ")", "{", "for", "key", ",", "value", ":=", "range", "ers", ".", "Errors", "{", "for", "_", ",", "msg", ":=", "range", "value", "{", "v", ".", "Add", "(", "key", ",", ...
// Append concatenates two Errors objects together. // This will modify the first object in place.
[ "Append", "concatenates", "two", "Errors", "objects", "together", ".", "This", "will", "modify", "the", "first", "object", "in", "place", "." ]
2ada686bcfc51eb528382b5134818852f918fe24
https://github.com/gobuffalo/validate/blob/2ada686bcfc51eb528382b5134818852f918fe24/validate.go#L98-L104
127,050
gobuffalo/validate
validate.go
Add
func (v *Errors) Add(key string, msg string) { v.Lock.Lock() v.Errors[key] = append(v.Errors[key], msg) v.Lock.Unlock() }
go
func (v *Errors) Add(key string, msg string) { v.Lock.Lock() v.Errors[key] = append(v.Errors[key], msg) v.Lock.Unlock() }
[ "func", "(", "v", "*", "Errors", ")", "Add", "(", "key", "string", ",", "msg", "string", ")", "{", "v", ".", "Lock", ".", "Lock", "(", ")", "\n", "v", ".", "Errors", "[", "key", "]", "=", "append", "(", "v", ".", "Errors", "[", "key", "]", ...
// Add will add a new message to the list of errors using // the given key. If the key already exists the message will // be appended to the array of the existing messages.
[ "Add", "will", "add", "a", "new", "message", "to", "the", "list", "of", "errors", "using", "the", "given", "key", ".", "If", "the", "key", "already", "exists", "the", "message", "will", "be", "appended", "to", "the", "array", "of", "the", "existing", "...
2ada686bcfc51eb528382b5134818852f918fe24
https://github.com/gobuffalo/validate/blob/2ada686bcfc51eb528382b5134818852f918fe24/validate.go#L109-L113
127,051
gobuffalo/validate
validate.go
Keys
func (v *Errors) Keys() []string { keys := []string{} for key := range v.Errors { keys = append(keys, key) } return keys }
go
func (v *Errors) Keys() []string { keys := []string{} for key := range v.Errors { keys = append(keys, key) } return keys }
[ "func", "(", "v", "*", "Errors", ")", "Keys", "(", ")", "[", "]", "string", "{", "keys", ":=", "[", "]", "string", "{", "}", "\n", "for", "key", ":=", "range", "v", ".", "Errors", "{", "keys", "=", "append", "(", "keys", ",", "key", ")", "\n"...
// Keys return all field names which have error
[ "Keys", "return", "all", "field", "names", "which", "have", "error" ]
2ada686bcfc51eb528382b5134818852f918fe24
https://github.com/gobuffalo/validate/blob/2ada686bcfc51eb528382b5134818852f918fe24/validate.go#L126-L133
127,052
gobuffalo/validate
validators/strings_match.go
IsValid
func (v *StringsMatch) IsValid(errors *validate.Errors) { if strings.TrimSpace(v.Field) != strings.TrimSpace(v.Field2) { if v.Message == "" { v.Message = fmt.Sprintf("%s does not equal %s.", v.Field, v.Field2) } errors.Add(GenerateKey(v.Name), v.Message) } }
go
func (v *StringsMatch) IsValid(errors *validate.Errors) { if strings.TrimSpace(v.Field) != strings.TrimSpace(v.Field2) { if v.Message == "" { v.Message = fmt.Sprintf("%s does not equal %s.", v.Field, v.Field2) } errors.Add(GenerateKey(v.Name), v.Message) } }
[ "func", "(", "v", "*", "StringsMatch", ")", "IsValid", "(", "errors", "*", "validate", ".", "Errors", ")", "{", "if", "strings", ".", "TrimSpace", "(", "v", ".", "Field", ")", "!=", "strings", ".", "TrimSpace", "(", "v", ".", "Field2", ")", "{", "i...
// IsValid performs the validation equality of two strings.
[ "IsValid", "performs", "the", "validation", "equality", "of", "two", "strings", "." ]
2ada686bcfc51eb528382b5134818852f918fe24
https://github.com/gobuffalo/validate/blob/2ada686bcfc51eb528382b5134818852f918fe24/validators/strings_match.go#L18-L25
127,053
gobuffalo/validate
validators/int_is_present.go
IsValid
func (v *IntIsPresent) IsValid(errors *validate.Errors) { if v.Field != 0 { return } if len(v.Message) > 0 { errors.Add(GenerateKey(v.Name), v.Message) return } errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name)) }
go
func (v *IntIsPresent) IsValid(errors *validate.Errors) { if v.Field != 0 { return } if len(v.Message) > 0 { errors.Add(GenerateKey(v.Name), v.Message) return } errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name)) }
[ "func", "(", "v", "*", "IntIsPresent", ")", "IsValid", "(", "errors", "*", "validate", ".", "Errors", ")", "{", "if", "v", ".", "Field", "!=", "0", "{", "return", "\n", "}", "\n\n", "if", "len", "(", "v", ".", "Message", ")", ">", "0", "{", "er...
// IsValid adds an error if the field equals 0.
[ "IsValid", "adds", "an", "error", "if", "the", "field", "equals", "0", "." ]
2ada686bcfc51eb528382b5134818852f918fe24
https://github.com/gobuffalo/validate/blob/2ada686bcfc51eb528382b5134818852f918fe24/validators/int_is_present.go#L16-L27
127,054
gobuffalo/validate
validators/uuid_is_present.go
IsValid
func (v *UUIDIsPresent) IsValid(errors *validate.Errors) { s := v.Field.String() if strings.TrimSpace(s) != "" && v.Field != uuid.Nil { return } if len(v.Message) > 0 { errors.Add(GenerateKey(v.Name), v.Message) return } errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name)) }
go
func (v *UUIDIsPresent) IsValid(errors *validate.Errors) { s := v.Field.String() if strings.TrimSpace(s) != "" && v.Field != uuid.Nil { return } if len(v.Message) > 0 { errors.Add(GenerateKey(v.Name), v.Message) return } errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name)) }
[ "func", "(", "v", "*", "UUIDIsPresent", ")", "IsValid", "(", "errors", "*", "validate", ".", "Errors", ")", "{", "s", ":=", "v", ".", "Field", ".", "String", "(", ")", "\n", "if", "strings", ".", "TrimSpace", "(", "s", ")", "!=", "\"", "\"", "&&"...
// IsValid adds an error if the field is not a valid uuid.
[ "IsValid", "adds", "an", "error", "if", "the", "field", "is", "not", "a", "valid", "uuid", "." ]
2ada686bcfc51eb528382b5134818852f918fe24
https://github.com/gobuffalo/validate/blob/2ada686bcfc51eb528382b5134818852f918fe24/validators/uuid_is_present.go#L18-L30
127,055
gobuffalo/validate
validators/time_is_before_time.go
IsValid
func (v *TimeIsBeforeTime) IsValid(errors *validate.Errors) { if v.FirstTime.UnixNano() <= v.SecondTime.UnixNano() { return } if len(v.Message) > 0 { errors.Add(GenerateKey(v.FirstName), v.Message) return } errors.Add(GenerateKey(v.FirstName), fmt.Sprintf("%s must be before %s.", v.FirstName, v.SecondName)...
go
func (v *TimeIsBeforeTime) IsValid(errors *validate.Errors) { if v.FirstTime.UnixNano() <= v.SecondTime.UnixNano() { return } if len(v.Message) > 0 { errors.Add(GenerateKey(v.FirstName), v.Message) return } errors.Add(GenerateKey(v.FirstName), fmt.Sprintf("%s must be before %s.", v.FirstName, v.SecondName)...
[ "func", "(", "v", "*", "TimeIsBeforeTime", ")", "IsValid", "(", "errors", "*", "validate", ".", "Errors", ")", "{", "if", "v", ".", "FirstTime", ".", "UnixNano", "(", ")", "<=", "v", ".", "SecondTime", ".", "UnixNano", "(", ")", "{", "return", "\n", ...
// IsValid adds an error if the FirstTime is after the SecondTime.
[ "IsValid", "adds", "an", "error", "if", "the", "FirstTime", "is", "after", "the", "SecondTime", "." ]
2ada686bcfc51eb528382b5134818852f918fe24
https://github.com/gobuffalo/validate/blob/2ada686bcfc51eb528382b5134818852f918fe24/validators/time_is_before_time.go#L19-L30
127,056
gobuffalo/validate
validators/time_is_present.go
IsValid
func (v *TimeIsPresent) IsValid(errors *validate.Errors) { t := time.Time{} if v.Field.UnixNano() != t.UnixNano() { return } if len(v.Message) > 0 { errors.Add(GenerateKey(v.Name), v.Message) return } errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name)) }
go
func (v *TimeIsPresent) IsValid(errors *validate.Errors) { t := time.Time{} if v.Field.UnixNano() != t.UnixNano() { return } if len(v.Message) > 0 { errors.Add(GenerateKey(v.Name), v.Message) return } errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name)) }
[ "func", "(", "v", "*", "TimeIsPresent", ")", "IsValid", "(", "errors", "*", "validate", ".", "Errors", ")", "{", "t", ":=", "time", ".", "Time", "{", "}", "\n", "if", "v", ".", "Field", ".", "UnixNano", "(", ")", "!=", "t", ".", "UnixNano", "(", ...
// IsValid adds an error if the field is not a valid time.
[ "IsValid", "adds", "an", "error", "if", "the", "field", "is", "not", "a", "valid", "time", "." ]
2ada686bcfc51eb528382b5134818852f918fe24
https://github.com/gobuffalo/validate/blob/2ada686bcfc51eb528382b5134818852f918fe24/validators/time_is_present.go#L17-L29
127,057
gobuffalo/validate
validators/string_is_present.go
IsValid
func (v *StringIsPresent) IsValid(errors *validate.Errors) { if strings.TrimSpace(v.Field) != "" { return } if len(v.Message) > 0 { errors.Add(GenerateKey(v.Name), v.Message) return } errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name)) }
go
func (v *StringIsPresent) IsValid(errors *validate.Errors) { if strings.TrimSpace(v.Field) != "" { return } if len(v.Message) > 0 { errors.Add(GenerateKey(v.Name), v.Message) return } errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s can not be blank.", v.Name)) }
[ "func", "(", "v", "*", "StringIsPresent", ")", "IsValid", "(", "errors", "*", "validate", ".", "Errors", ")", "{", "if", "strings", ".", "TrimSpace", "(", "v", ".", "Field", ")", "!=", "\"", "\"", "{", "return", "\n", "}", "\n\n", "if", "len", "(",...
// IsValid adds an error if the field is empty.
[ "IsValid", "adds", "an", "error", "if", "the", "field", "is", "empty", "." ]
2ada686bcfc51eb528382b5134818852f918fe24
https://github.com/gobuffalo/validate/blob/2ada686bcfc51eb528382b5134818852f918fe24/validators/string_is_present.go#L17-L28
127,058
gobuffalo/validate
validators/email_is_present.go
IsValid
func (v *EmailIsPresent) IsValid(errors *validate.Errors) { if !rxEmail.Match([]byte(v.Field)) { if v.Message == "" { v.Message = fmt.Sprintf("%s does not match the email format.", v.Name) } errors.Add(GenerateKey(v.Name), v.Message) } }
go
func (v *EmailIsPresent) IsValid(errors *validate.Errors) { if !rxEmail.Match([]byte(v.Field)) { if v.Message == "" { v.Message = fmt.Sprintf("%s does not match the email format.", v.Name) } errors.Add(GenerateKey(v.Name), v.Message) } }
[ "func", "(", "v", "*", "EmailIsPresent", ")", "IsValid", "(", "errors", "*", "validate", ".", "Errors", ")", "{", "if", "!", "rxEmail", ".", "Match", "(", "[", "]", "byte", "(", "v", ".", "Field", ")", ")", "{", "if", "v", ".", "Message", "==", ...
// IsValid performs the validation based on the email regexp match.
[ "IsValid", "performs", "the", "validation", "based", "on", "the", "email", "regexp", "match", "." ]
2ada686bcfc51eb528382b5134818852f918fe24
https://github.com/gobuffalo/validate/blob/2ada686bcfc51eb528382b5134818852f918fe24/validators/email_is_present.go#L24-L31
127,059
gobuffalo/validate
validators/email_is_present.go
IsValid
func (v *EmailLike) IsValid(errors *validate.Errors) { parts := strings.Split(v.Field, "@") if len(parts) != 2 || len(parts[0]) == 0 || len(parts[1]) == 0 { if v.Message == "" { v.Message = fmt.Sprintf("%s does not match the email format.", v.Name) } errors.Add(GenerateKey(v.Name), v.Message) } else if len(...
go
func (v *EmailLike) IsValid(errors *validate.Errors) { parts := strings.Split(v.Field, "@") if len(parts) != 2 || len(parts[0]) == 0 || len(parts[1]) == 0 { if v.Message == "" { v.Message = fmt.Sprintf("%s does not match the email format.", v.Name) } errors.Add(GenerateKey(v.Name), v.Message) } else if len(...
[ "func", "(", "v", "*", "EmailLike", ")", "IsValid", "(", "errors", "*", "validate", ".", "Errors", ")", "{", "parts", ":=", "strings", ".", "Split", "(", "v", ".", "Field", ",", "\"", "\"", ")", "\n", "if", "len", "(", "parts", ")", "!=", "2", ...
// IsValid performs the validation based on email struct (username@domain)
[ "IsValid", "performs", "the", "validation", "based", "on", "email", "struct", "(", "username" ]
2ada686bcfc51eb528382b5134818852f918fe24
https://github.com/gobuffalo/validate/blob/2ada686bcfc51eb528382b5134818852f918fe24/validators/email_is_present.go#L42-L59
127,060
gobuffalo/validate
validators/regex_match.go
IsValid
func (v *RegexMatch) IsValid(errors *validate.Errors) { r := regexp.MustCompile(v.Expr) if r.Match([]byte(v.Field)) { return } if len(v.Message) > 0 { errors.Add(GenerateKey(v.Name), v.Message) return } errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s does not match the expected format.", v.Name)) }
go
func (v *RegexMatch) IsValid(errors *validate.Errors) { r := regexp.MustCompile(v.Expr) if r.Match([]byte(v.Field)) { return } if len(v.Message) > 0 { errors.Add(GenerateKey(v.Name), v.Message) return } errors.Add(GenerateKey(v.Name), fmt.Sprintf("%s does not match the expected format.", v.Name)) }
[ "func", "(", "v", "*", "RegexMatch", ")", "IsValid", "(", "errors", "*", "validate", ".", "Errors", ")", "{", "r", ":=", "regexp", ".", "MustCompile", "(", "v", ".", "Expr", ")", "\n", "if", "r", ".", "Match", "(", "[", "]", "byte", "(", "v", "...
// IsValid performs the validation based on the regexp match.
[ "IsValid", "performs", "the", "validation", "based", "on", "the", "regexp", "match", "." ]
2ada686bcfc51eb528382b5134818852f918fe24
https://github.com/gobuffalo/validate/blob/2ada686bcfc51eb528382b5134818852f918fe24/validators/regex_match.go#L19-L31
127,061
PuerkitoBio/purell
purell.go
MustNormalizeURLString
func MustNormalizeURLString(u string, f NormalizationFlags) string { result, e := NormalizeURLString(u, f) if e != nil { panic(e) } return result }
go
func MustNormalizeURLString(u string, f NormalizationFlags) string { result, e := NormalizeURLString(u, f) if e != nil { panic(e) } return result }
[ "func", "MustNormalizeURLString", "(", "u", "string", ",", "f", "NormalizationFlags", ")", "string", "{", "result", ",", "e", ":=", "NormalizeURLString", "(", "u", ",", "f", ")", "\n", "if", "e", "!=", "nil", "{", "panic", "(", "e", ")", "\n", "}", "...
// MustNormalizeURLString returns the normalized string, and panics if an error occurs. // It takes an URL string as input, as well as the normalization flags.
[ "MustNormalizeURLString", "returns", "the", "normalized", "string", "and", "panics", "if", "an", "error", "occurs", ".", "It", "takes", "an", "URL", "string", "as", "input", "as", "well", "as", "the", "normalization", "flags", "." ]
44968752391892e1b0d0b821ee79e9a85fa13049
https://github.com/PuerkitoBio/purell/blob/44968752391892e1b0d0b821ee79e9a85fa13049/purell.go#L142-L148
127,062
PuerkitoBio/purell
purell.go
NormalizeURLString
func NormalizeURLString(u string, f NormalizationFlags) (string, error) { parsed, err := url.Parse(u) if err != nil { return "", err } if f&FlagLowercaseHost == FlagLowercaseHost { parsed.Host = strings.ToLower(parsed.Host) } // The idna package doesn't fully conform to RFC 5895 // (https://tools.ietf.org/...
go
func NormalizeURLString(u string, f NormalizationFlags) (string, error) { parsed, err := url.Parse(u) if err != nil { return "", err } if f&FlagLowercaseHost == FlagLowercaseHost { parsed.Host = strings.ToLower(parsed.Host) } // The idna package doesn't fully conform to RFC 5895 // (https://tools.ietf.org/...
[ "func", "NormalizeURLString", "(", "u", "string", ",", "f", "NormalizationFlags", ")", "(", "string", ",", "error", ")", "{", "parsed", ",", "err", ":=", "url", ".", "Parse", "(", "u", ")", "\n", "if", "err", "!=", "nil", "{", "return", "\"", "\"", ...
// NormalizeURLString returns the normalized string, or an error if it can't be parsed into an URL object. // It takes an URL string as input, as well as the normalization flags.
[ "NormalizeURLString", "returns", "the", "normalized", "string", "or", "an", "error", "if", "it", "can", "t", "be", "parsed", "into", "an", "URL", "object", ".", "It", "takes", "an", "URL", "string", "as", "input", "as", "well", "as", "the", "normalization"...
44968752391892e1b0d0b821ee79e9a85fa13049
https://github.com/PuerkitoBio/purell/blob/44968752391892e1b0d0b821ee79e9a85fa13049/purell.go#L152-L173
127,063
PuerkitoBio/purell
purell.go
NormalizeURL
func NormalizeURL(u *url.URL, f NormalizationFlags) string { for _, k := range flagsOrder { if f&k == k { flags[k](u) } } return urlesc.Escape(u) }
go
func NormalizeURL(u *url.URL, f NormalizationFlags) string { for _, k := range flagsOrder { if f&k == k { flags[k](u) } } return urlesc.Escape(u) }
[ "func", "NormalizeURL", "(", "u", "*", "url", ".", "URL", ",", "f", "NormalizationFlags", ")", "string", "{", "for", "_", ",", "k", ":=", "range", "flagsOrder", "{", "if", "f", "&", "k", "==", "k", "{", "flags", "[", "k", "]", "(", "u", ")", "\...
// NormalizeURL returns the normalized string. // It takes a parsed URL object as input, as well as the normalization flags.
[ "NormalizeURL", "returns", "the", "normalized", "string", ".", "It", "takes", "a", "parsed", "URL", "object", "as", "input", "as", "well", "as", "the", "normalization", "flags", "." ]
44968752391892e1b0d0b821ee79e9a85fa13049
https://github.com/PuerkitoBio/purell/blob/44968752391892e1b0d0b821ee79e9a85fa13049/purell.go#L177-L184
127,064
rexray/gocsi
middleware/serialvolume/serial_volume_locker.go
WithTimeout
func WithTimeout(t time.Duration) Option { return func(o *opts) { o.timeout = t } }
go
func WithTimeout(t time.Duration) Option { return func(o *opts) { o.timeout = t } }
[ "func", "WithTimeout", "(", "t", "time", ".", "Duration", ")", "Option", "{", "return", "func", "(", "o", "*", "opts", ")", "{", "o", ".", "timeout", "=", "t", "\n", "}", "\n", "}" ]
// WithTimeout is an Option that sets the timeout used by the interceptor.
[ "WithTimeout", "is", "an", "Option", "that", "sets", "the", "timeout", "used", "by", "the", "interceptor", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/middleware/serialvolume/serial_volume_locker.go#L29-L33
127,065
rexray/gocsi
middleware/serialvolume/serial_volume_locker.go
WithLockProvider
func WithLockProvider(p mwtypes.VolumeLockerProvider) Option { return func(o *opts) { o.locker = p } }
go
func WithLockProvider(p mwtypes.VolumeLockerProvider) Option { return func(o *opts) { o.locker = p } }
[ "func", "WithLockProvider", "(", "p", "mwtypes", ".", "VolumeLockerProvider", ")", "Option", "{", "return", "func", "(", "o", "*", "opts", ")", "{", "o", ".", "locker", "=", "p", "\n", "}", "\n", "}" ]
// WithLockProvider is an Option that sets the lock provider used by the // interceptor.
[ "WithLockProvider", "is", "an", "Option", "that", "sets", "the", "lock", "provider", "used", "by", "the", "interceptor", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/middleware/serialvolume/serial_volume_locker.go#L37-L41
127,066
rexray/gocsi
middleware/serialvolume/etcd/etcd_lock_provider.go
New
func New( ctx context.Context, domain string, ttl time.Duration, config *etcd.Config) (mwtypes.VolumeLockerProvider, error) { fields := map[string]interface{}{} if domain == "" { domain = csictx.Getenv(ctx, EnvVarDomain) } domain = path.Join("/", domain) fields["serialvol.etcd.domain"] = domain if ttl ==...
go
func New( ctx context.Context, domain string, ttl time.Duration, config *etcd.Config) (mwtypes.VolumeLockerProvider, error) { fields := map[string]interface{}{} if domain == "" { domain = csictx.Getenv(ctx, EnvVarDomain) } domain = path.Join("/", domain) fields["serialvol.etcd.domain"] = domain if ttl ==...
[ "func", "New", "(", "ctx", "context", ".", "Context", ",", "domain", "string", ",", "ttl", "time", ".", "Duration", ",", "config", "*", "etcd", ".", "Config", ")", "(", "mwtypes", ".", "VolumeLockerProvider", ",", "error", ")", "{", "fields", ":=", "ma...
// New returns a new etcd volume lock provider.
[ "New", "returns", "a", "new", "etcd", "volume", "lock", "provider", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/middleware/serialvolume/etcd/etcd_lock_provider.go#L21-L62
127,067
rexray/gocsi
middleware/serialvolume/etcd/etcd_lock_provider.go
Lock
func (m *TryMutex) Lock() { //log.Debug("TryMutex: lock") ctx := m.LockCtx if ctx == nil { ctx = m.ctx } if err := m.mtx.Lock(ctx); err != nil { log.Debugf("TryMutex: lock err: %v", err) if err != context.Canceled && err != context.DeadlineExceeded { log.Panicf("TryMutex: lock panic: %v", err) } } }
go
func (m *TryMutex) Lock() { //log.Debug("TryMutex: lock") ctx := m.LockCtx if ctx == nil { ctx = m.ctx } if err := m.mtx.Lock(ctx); err != nil { log.Debugf("TryMutex: lock err: %v", err) if err != context.Canceled && err != context.DeadlineExceeded { log.Panicf("TryMutex: lock panic: %v", err) } } }
[ "func", "(", "m", "*", "TryMutex", ")", "Lock", "(", ")", "{", "//log.Debug(\"TryMutex: lock\")", "ctx", ":=", "m", ".", "LockCtx", "\n", "if", "ctx", "==", "nil", "{", "ctx", "=", "m", ".", "ctx", "\n", "}", "\n", "if", "err", ":=", "m", ".", "m...
// Lock locks m. If the lock is already in use, the calling goroutine blocks // until the mutex is available.
[ "Lock", "locks", "m", ".", "If", "the", "lock", "is", "already", "in", "use", "the", "calling", "goroutine", "blocks", "until", "the", "mutex", "is", "available", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/middleware/serialvolume/etcd/etcd_lock_provider.go#L231-L243
127,068
rexray/gocsi
middleware/serialvolume/etcd/etcd_lock_provider.go
Unlock
func (m *TryMutex) Unlock() { //log.Debug("TryMutex: unlock") ctx := m.UnlockCtx if ctx == nil { ctx = m.ctx } if err := m.mtx.Unlock(ctx); err != nil { log.Debugf("TryMutex: unlock err: %v", err) if err != context.Canceled && err != context.DeadlineExceeded { log.Panicf("TryMutex: unlock panic: %v", err)...
go
func (m *TryMutex) Unlock() { //log.Debug("TryMutex: unlock") ctx := m.UnlockCtx if ctx == nil { ctx = m.ctx } if err := m.mtx.Unlock(ctx); err != nil { log.Debugf("TryMutex: unlock err: %v", err) if err != context.Canceled && err != context.DeadlineExceeded { log.Panicf("TryMutex: unlock panic: %v", err)...
[ "func", "(", "m", "*", "TryMutex", ")", "Unlock", "(", ")", "{", "//log.Debug(\"TryMutex: unlock\")", "ctx", ":=", "m", ".", "UnlockCtx", "\n", "if", "ctx", "==", "nil", "{", "ctx", "=", "m", ".", "ctx", "\n", "}", "\n", "if", "err", ":=", "m", "."...
// Unlock unlocks m. It is a run-time error if m is not locked on entry to // Unlock. // // A locked TryMutex is not associated with a particular goroutine. It is // allowed for one goroutine to lock a Mutex and then arrange for another // goroutine to unlock it.
[ "Unlock", "unlocks", "m", ".", "It", "is", "a", "run", "-", "time", "error", "if", "m", "is", "not", "locked", "on", "entry", "to", "Unlock", ".", "A", "locked", "TryMutex", "is", "not", "associated", "with", "a", "particular", "goroutine", ".", "It", ...
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/middleware/serialvolume/etcd/etcd_lock_provider.go#L251-L263
127,069
rexray/gocsi
middleware/serialvolume/etcd/etcd_lock_provider.go
Close
func (m *TryMutex) Close() error { //log.Debug("TryMutex: close") if err := m.sess.Close(); err != nil { log.Errorf("TryMutex: close err: %v", err) return err } return nil }
go
func (m *TryMutex) Close() error { //log.Debug("TryMutex: close") if err := m.sess.Close(); err != nil { log.Errorf("TryMutex: close err: %v", err) return err } return nil }
[ "func", "(", "m", "*", "TryMutex", ")", "Close", "(", ")", "error", "{", "//log.Debug(\"TryMutex: close\")", "if", "err", ":=", "m", ".", "sess", ".", "Close", "(", ")", ";", "err", "!=", "nil", "{", "log", ".", "Errorf", "(", "\"", "\"", ",", "err...
// Close closes and cleans up the underlying concurrency session.
[ "Close", "closes", "and", "cleans", "up", "the", "underlying", "concurrency", "session", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/middleware/serialvolume/etcd/etcd_lock_provider.go#L266-L273
127,070
rexray/gocsi
middleware/serialvolume/etcd/etcd_lock_provider.go
TryLock
func (m *TryMutex) TryLock(timeout time.Duration) bool { ctx := m.TryLockCtx if ctx == nil { ctx = m.ctx } // Create a timeout context only if the timeout is greater than zero. if timeout > 0 { var cancel context.CancelFunc ctx, cancel = context.WithTimeout(ctx, timeout) defer cancel() } if err := m.m...
go
func (m *TryMutex) TryLock(timeout time.Duration) bool { ctx := m.TryLockCtx if ctx == nil { ctx = m.ctx } // Create a timeout context only if the timeout is greater than zero. if timeout > 0 { var cancel context.CancelFunc ctx, cancel = context.WithTimeout(ctx, timeout) defer cancel() } if err := m.m...
[ "func", "(", "m", "*", "TryMutex", ")", "TryLock", "(", "timeout", "time", ".", "Duration", ")", "bool", "{", "ctx", ":=", "m", ".", "TryLockCtx", "\n", "if", "ctx", "==", "nil", "{", "ctx", "=", "m", ".", "ctx", "\n", "}", "\n\n", "// Create a tim...
// TryLock attempts to lock m. If no lock can be obtained in the specified // duration then a false value is returned.
[ "TryLock", "attempts", "to", "lock", "m", ".", "If", "no", "lock", "can", "be", "obtained", "in", "the", "specified", "duration", "then", "a", "false", "value", "is", "returned", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/middleware/serialvolume/etcd/etcd_lock_provider.go#L277-L299
127,071
rexray/gocsi
gocsi.go
Serve
func (sp *StoragePlugin) Serve(ctx context.Context, lis net.Listener) error { var err error sp.serveOnce.Do(func() { // Please note that the order of the below init functions is // important and should not be altered unless by someone aware // of how they work. // Adding this function to the context allows `...
go
func (sp *StoragePlugin) Serve(ctx context.Context, lis net.Listener) error { var err error sp.serveOnce.Do(func() { // Please note that the order of the below init functions is // important and should not be altered unless by someone aware // of how they work. // Adding this function to the context allows `...
[ "func", "(", "sp", "*", "StoragePlugin", ")", "Serve", "(", "ctx", "context", ".", "Context", ",", "lis", "net", ".", "Listener", ")", "error", "{", "var", "err", "error", "\n", "sp", ".", "serveOnce", ".", "Do", "(", "func", "(", ")", "{", "// Ple...
// Serve accepts incoming connections on the listener lis, creating // a new ServerTransport and service goroutine for each. The service // goroutine read gRPC requests and then call the registered handlers // to reply to them. Serve returns when lis.Accept fails with fatal // errors. lis will be closed when this meth...
[ "Serve", "accepts", "incoming", "connections", "on", "the", "listener", "lis", "creating", "a", "new", "ServerTransport", "and", "service", "goroutine", "for", "each", ".", "The", "service", "goroutine", "read", "gRPC", "requests", "and", "then", "call", "the", ...
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/gocsi.go#L209-L314
127,072
rexray/gocsi
gocsi.go
isExitSignal
func isExitSignal(s os.Signal) (bool, bool) { switch s { case syscall.SIGTERM, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT: return true, true default: return false, false } }
go
func isExitSignal(s os.Signal) (bool, bool) { switch s { case syscall.SIGTERM, syscall.SIGHUP, syscall.SIGINT, syscall.SIGQUIT: return true, true default: return false, false } }
[ "func", "isExitSignal", "(", "s", "os", ".", "Signal", ")", "(", "bool", ",", "bool", ")", "{", "switch", "s", "{", "case", "syscall", ".", "SIGTERM", ",", "syscall", ".", "SIGHUP", ",", "syscall", ".", "SIGINT", ",", "syscall", ".", "SIGQUIT", ":", ...
// isExitSignal returns a flag indicating whether a signal SIGHUP, // SIGINT, SIGTERM, or SIGQUIT. The second return value is whether it is a // graceful exit. This flag is true for SIGTERM, SIGHUP, SIGINT, and SIGQUIT.
[ "isExitSignal", "returns", "a", "flag", "indicating", "whether", "a", "signal", "SIGHUP", "SIGINT", "SIGTERM", "or", "SIGQUIT", ".", "The", "second", "return", "value", "is", "whether", "it", "is", "a", "graceful", "exit", ".", "This", "flag", "is", "true", ...
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/gocsi.go#L512-L522
127,073
rexray/gocsi
middleware/logging/logging_interceptor.go
WithRequestLogging
func WithRequestLogging(w io.Writer) Option { return func(o *opts) { if w == nil { w = os.Stdout } o.reqw = w } }
go
func WithRequestLogging(w io.Writer) Option { return func(o *opts) { if w == nil { w = os.Stdout } o.reqw = w } }
[ "func", "WithRequestLogging", "(", "w", "io", ".", "Writer", ")", "Option", "{", "return", "func", "(", "o", "*", "opts", ")", "{", "if", "w", "==", "nil", "{", "w", "=", "os", ".", "Stdout", "\n", "}", "\n", "o", ".", "reqw", "=", "w", "\n", ...
// WithRequestLogging is a Option that enables request logging // for the logging interceptor.
[ "WithRequestLogging", "is", "a", "Option", "that", "enables", "request", "logging", "for", "the", "logging", "interceptor", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/middleware/logging/logging_interceptor.go#L29-L36
127,074
rexray/gocsi
middleware/logging/logging_interceptor.go
WithResponseLogging
func WithResponseLogging(w io.Writer) Option { return func(o *opts) { if w == nil { w = os.Stdout } o.repw = w } }
go
func WithResponseLogging(w io.Writer) Option { return func(o *opts) { if w == nil { w = os.Stdout } o.repw = w } }
[ "func", "WithResponseLogging", "(", "w", "io", ".", "Writer", ")", "Option", "{", "return", "func", "(", "o", "*", "opts", ")", "{", "if", "w", "==", "nil", "{", "w", "=", "os", ".", "Stdout", "\n", "}", "\n", "o", ".", "repw", "=", "w", "\n", ...
// WithResponseLogging is a Option that enables response logging // for the logging interceptor.
[ "WithResponseLogging", "is", "a", "Option", "that", "enables", "response", "logging", "for", "the", "logging", "interceptor", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/middleware/logging/logging_interceptor.go#L40-L47
127,075
rexray/gocsi
middleware/logging/logging_interceptor.go
rprintReqOrRep
func rprintReqOrRep(w io.Writer, obj interface{}) { rv := reflect.ValueOf(obj).Elem() tv := rv.Type() nf := tv.NumField() printedColon := false printComma := false for i := 0; i < nf; i++ { name := tv.Field(i).Name if strings.Contains(name, "Secrets") { continue } sv := fmt.Sprintf("%v", rv.Field(i).In...
go
func rprintReqOrRep(w io.Writer, obj interface{}) { rv := reflect.ValueOf(obj).Elem() tv := rv.Type() nf := tv.NumField() printedColon := false printComma := false for i := 0; i < nf; i++ { name := tv.Field(i).Name if strings.Contains(name, "Secrets") { continue } sv := fmt.Sprintf("%v", rv.Field(i).In...
[ "func", "rprintReqOrRep", "(", "w", "io", ".", "Writer", ",", "obj", "interface", "{", "}", ")", "{", "rv", ":=", "reflect", ".", "ValueOf", "(", "obj", ")", ".", "Elem", "(", ")", "\n", "tv", ":=", "rv", ".", "Type", "(", ")", "\n", "nf", ":="...
// rprintReqOrRep is used by the server-side interceptors that log // requests and responses.
[ "rprintReqOrRep", "is", "used", "by", "the", "server", "-", "side", "interceptors", "that", "log", "requests", "and", "responses", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/middleware/logging/logging_interceptor.go#L162-L187
127,076
rexray/gocsi
mock/service/service.go
New
func New() Service { s := &service{nodeID: Name} s.vols = []csi.Volume{ s.newVolume("Mock Volume 1", gib100), s.newVolume("Mock Volume 2", gib100), s.newVolume("Mock Volume 3", gib100), } return s }
go
func New() Service { s := &service{nodeID: Name} s.vols = []csi.Volume{ s.newVolume("Mock Volume 1", gib100), s.newVolume("Mock Volume 2", gib100), s.newVolume("Mock Volume 3", gib100), } return s }
[ "func", "New", "(", ")", "Service", "{", "s", ":=", "&", "service", "{", "nodeID", ":", "Name", "}", "\n", "s", ".", "vols", "=", "[", "]", "csi", ".", "Volume", "{", "s", ".", "newVolume", "(", "\"", "\"", ",", "gib100", ")", ",", "s", ".", ...
// New returns a new Service.
[ "New", "returns", "a", "new", "Service", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/mock/service/service.go#L47-L55
127,077
rexray/gocsi
utils/utils.go
GetCSIEndpoint
func GetCSIEndpoint() (network, addr string, err error) { protoAddr := os.Getenv(CSIEndpoint) if emptyRX.MatchString(protoAddr) { return "", "", errors.New("missing CSI_ENDPOINT") } return ParseProtoAddr(protoAddr) }
go
func GetCSIEndpoint() (network, addr string, err error) { protoAddr := os.Getenv(CSIEndpoint) if emptyRX.MatchString(protoAddr) { return "", "", errors.New("missing CSI_ENDPOINT") } return ParseProtoAddr(protoAddr) }
[ "func", "GetCSIEndpoint", "(", ")", "(", "network", ",", "addr", "string", ",", "err", "error", ")", "{", "protoAddr", ":=", "os", ".", "Getenv", "(", "CSIEndpoint", ")", "\n", "if", "emptyRX", ".", "MatchString", "(", "protoAddr", ")", "{", "return", ...
// GetCSIEndpoint returns the network address specified by the // environment variable CSI_ENDPOINT.
[ "GetCSIEndpoint", "returns", "the", "network", "address", "specified", "by", "the", "environment", "variable", "CSI_ENDPOINT", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/utils/utils.go#L31-L37
127,078
rexray/gocsi
utils/utils.go
GetCSIEndpointListener
func GetCSIEndpointListener() (net.Listener, error) { proto, addr, err := GetCSIEndpoint() if err != nil { return nil, err } return net.Listen(proto, addr) }
go
func GetCSIEndpointListener() (net.Listener, error) { proto, addr, err := GetCSIEndpoint() if err != nil { return nil, err } return net.Listen(proto, addr) }
[ "func", "GetCSIEndpointListener", "(", ")", "(", "net", ".", "Listener", ",", "error", ")", "{", "proto", ",", "addr", ",", "err", ":=", "GetCSIEndpoint", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "\n", "}", "\n", ...
// GetCSIEndpointListener returns the net.Listener for the endpoint // specified by the environment variable CSI_ENDPOINT.
[ "GetCSIEndpointListener", "returns", "the", "net", ".", "Listener", "for", "the", "endpoint", "specified", "by", "the", "environment", "variable", "CSI_ENDPOINT", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/utils/utils.go#L41-L47
127,079
rexray/gocsi
utils/utils.go
ParseProtoAddr
func ParseProtoAddr(protoAddr string) (proto string, addr string, err error) { if emptyRX.MatchString(protoAddr) { return "", "", ErrParseProtoAddrRequired } // If the provided network address does not begin with one // of the valid network protocols then treat the string as a // file path. // // First check...
go
func ParseProtoAddr(protoAddr string) (proto string, addr string, err error) { if emptyRX.MatchString(protoAddr) { return "", "", ErrParseProtoAddrRequired } // If the provided network address does not begin with one // of the valid network protocols then treat the string as a // file path. // // First check...
[ "func", "ParseProtoAddr", "(", "protoAddr", "string", ")", "(", "proto", "string", ",", "addr", "string", ",", "err", "error", ")", "{", "if", "emptyRX", ".", "MatchString", "(", "protoAddr", ")", "{", "return", "\"", "\"", ",", "\"", "\"", ",", "ErrPa...
// ParseProtoAddr parses a Golang network address.
[ "ParseProtoAddr", "parses", "a", "Golang", "network", "address", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/utils/utils.go#L68-L114
127,080
rexray/gocsi
utils/utils.go
PageVolumes
func PageVolumes( ctx context.Context, client csi.ControllerClient, req csi.ListVolumesRequest, opts ...grpc.CallOption) (<-chan csi.Volume, <-chan error) { var ( cvol = make(chan csi.Volume) cerr = make(chan error) ) // Execute the RPC in a goroutine, looping until there are no // more volumes available....
go
func PageVolumes( ctx context.Context, client csi.ControllerClient, req csi.ListVolumesRequest, opts ...grpc.CallOption) (<-chan csi.Volume, <-chan error) { var ( cvol = make(chan csi.Volume) cerr = make(chan error) ) // Execute the RPC in a goroutine, looping until there are no // more volumes available....
[ "func", "PageVolumes", "(", "ctx", "context", ".", "Context", ",", "client", "csi", ".", "ControllerClient", ",", "req", "csi", ".", "ListVolumesRequest", ",", "opts", "...", "grpc", ".", "CallOption", ")", "(", "<-", "chan", "csi", ".", "Volume", ",", "...
// PageVolumes issues one or more ListVolumes requests to retrieve // all available volumes, returning them over a Go channel.
[ "PageVolumes", "issues", "one", "or", "more", "ListVolumes", "requests", "to", "retrieve", "all", "available", "volumes", "returning", "them", "over", "a", "Go", "channel", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/utils/utils.go#L307-L410
127,081
rexray/gocsi
utils/utils.go
PageSnapshots
func PageSnapshots( ctx context.Context, client csi.ControllerClient, req csi.ListSnapshotsRequest, opts ...grpc.CallOption) (<-chan csi.Snapshot, <-chan error) { var ( csnap = make(chan csi.Snapshot) cerr = make(chan error) ) // Execute the RPC in a goroutine, looping until there are no // more snaphsot...
go
func PageSnapshots( ctx context.Context, client csi.ControllerClient, req csi.ListSnapshotsRequest, opts ...grpc.CallOption) (<-chan csi.Snapshot, <-chan error) { var ( csnap = make(chan csi.Snapshot) cerr = make(chan error) ) // Execute the RPC in a goroutine, looping until there are no // more snaphsot...
[ "func", "PageSnapshots", "(", "ctx", "context", ".", "Context", ",", "client", "csi", ".", "ControllerClient", ",", "req", "csi", ".", "ListSnapshotsRequest", ",", "opts", "...", "grpc", ".", "CallOption", ")", "(", "<-", "chan", "csi", ".", "Snapshot", ",...
// PageSnapshots issues one or more ListSnapshots requests to retrieve // all available snaphsots, returning them over a Go channel.
[ "PageSnapshots", "issues", "one", "or", "more", "ListSnapshots", "requests", "to", "retrieve", "all", "available", "snaphsots", "returning", "them", "over", "a", "Go", "channel", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/utils/utils.go#L414-L517
127,082
rexray/gocsi
utils/utils.go
AreVolumeCapabilitiesCompatible
func AreVolumeCapabilitiesCompatible( a, b []*csi.VolumeCapability) (bool, error) { if len(a) > len(b) { return false, status.Error( codes.AlreadyExists, "requested capabilities exceed existing") } var i int for _, va := range a { for _, vb := range b { if EqualVolumeCapability(va, vb) { i++ ...
go
func AreVolumeCapabilitiesCompatible( a, b []*csi.VolumeCapability) (bool, error) { if len(a) > len(b) { return false, status.Error( codes.AlreadyExists, "requested capabilities exceed existing") } var i int for _, va := range a { for _, vb := range b { if EqualVolumeCapability(va, vb) { i++ ...
[ "func", "AreVolumeCapabilitiesCompatible", "(", "a", ",", "b", "[", "]", "*", "csi", ".", "VolumeCapability", ")", "(", "bool", ",", "error", ")", "{", "if", "len", "(", "a", ")", ">", "len", "(", "b", ")", "{", "return", "false", ",", "status", "....
// AreVolumeCapabilitiesCompatible returns a flag indicating whether // the volume capability array "a" is compatible with "b". A true value // indicates that "a" and "b" are equivalent or "b" is a superset of "a".
[ "AreVolumeCapabilitiesCompatible", "returns", "a", "flag", "indicating", "whether", "the", "volume", "capability", "array", "a", "is", "compatible", "with", "b", ".", "A", "true", "value", "indicates", "that", "a", "and", "b", "are", "equivalent", "or", "b", "...
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/utils/utils.go#L550-L570
127,083
rexray/gocsi
utils/utils.go
IsVolumeCapabilityCompatible
func IsVolumeCapabilityCompatible( a *csi.VolumeCapability, b []*csi.VolumeCapability) (bool, error) { return AreVolumeCapabilitiesCompatible([]*csi.VolumeCapability{a}, b) }
go
func IsVolumeCapabilityCompatible( a *csi.VolumeCapability, b []*csi.VolumeCapability) (bool, error) { return AreVolumeCapabilitiesCompatible([]*csi.VolumeCapability{a}, b) }
[ "func", "IsVolumeCapabilityCompatible", "(", "a", "*", "csi", ".", "VolumeCapability", ",", "b", "[", "]", "*", "csi", ".", "VolumeCapability", ")", "(", "bool", ",", "error", ")", "{", "return", "AreVolumeCapabilitiesCompatible", "(", "[", "]", "*", "csi", ...
// IsVolumeCapabilityCompatible returns a flag indicating whether // the volume capability "a" is compatible with the set "b". A true value // indicates that "a" and "b" are equivalent or "b" is a superset of "a".
[ "IsVolumeCapabilityCompatible", "returns", "a", "flag", "indicating", "whether", "the", "volume", "capability", "a", "is", "compatible", "with", "the", "set", "b", ".", "A", "true", "value", "indicates", "that", "a", "and", "b", "are", "equivalent", "or", "b",...
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/utils/utils.go#L575-L579
127,084
rexray/gocsi
utils/utils.go
EqualVolumeCapability
func EqualVolumeCapability(a, b *csi.VolumeCapability) bool { if a == nil || b == nil { return false } // Compare access modes. if a.AccessMode != nil && b.AccessMode == nil { return false } if a.AccessMode == nil && b.AccessMode != nil { return false } if a.AccessMode != nil && b.AccessMode != nil && ...
go
func EqualVolumeCapability(a, b *csi.VolumeCapability) bool { if a == nil || b == nil { return false } // Compare access modes. if a.AccessMode != nil && b.AccessMode == nil { return false } if a.AccessMode == nil && b.AccessMode != nil { return false } if a.AccessMode != nil && b.AccessMode != nil && ...
[ "func", "EqualVolumeCapability", "(", "a", ",", "b", "*", "csi", ".", "VolumeCapability", ")", "bool", "{", "if", "a", "==", "nil", "||", "b", "==", "nil", "{", "return", "false", "\n", "}", "\n\n", "// Compare access modes.", "if", "a", ".", "AccessMode...
// EqualVolumeCapability returns a flag indicating if two csi.VolumeCapability // objects are equal. If a and b are both nil then false is returned.
[ "EqualVolumeCapability", "returns", "a", "flag", "indicating", "if", "two", "csi", ".", "VolumeCapability", "objects", "are", "equal", ".", "If", "a", "and", "b", "are", "both", "nil", "then", "false", "is", "returned", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/utils/utils.go#L583-L640
127,085
rexray/gocsi
utils/utils.go
EqualVolume
func EqualVolume(a, b *csi.Volume) bool { if a == nil || b == nil { return false } return CompareVolume(*a, *b) == 0 }
go
func EqualVolume(a, b *csi.Volume) bool { if a == nil || b == nil { return false } return CompareVolume(*a, *b) == 0 }
[ "func", "EqualVolume", "(", "a", ",", "b", "*", "csi", ".", "Volume", ")", "bool", "{", "if", "a", "==", "nil", "||", "b", "==", "nil", "{", "return", "false", "\n", "}", "\n", "return", "CompareVolume", "(", "*", "a", ",", "*", "b", ")", "==",...
// EqualVolume returns a flag indicating if two csi.Volume // objects are equal. If a and b are both nil then false is returned.
[ "EqualVolume", "returns", "a", "flag", "indicating", "if", "two", "csi", ".", "Volume", "objects", "are", "equal", ".", "If", "a", "and", "b", "are", "both", "nil", "then", "false", "is", "returned", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/utils/utils.go#L644-L649
127,086
rexray/gocsi
context/context.go
GetRequestID
func GetRequestID(ctx context.Context) (uint64, bool) { var ( szID []string szIDOK bool ) // Prefer the incoming context, but look in both types. if md, ok := metadata.FromIncomingContext(ctx); ok { szID, szIDOK = md[RequestIDKey] } else if md, ok := metadata.FromOutgoingContext(ctx); ok { szID, szIDOK ...
go
func GetRequestID(ctx context.Context) (uint64, bool) { var ( szID []string szIDOK bool ) // Prefer the incoming context, but look in both types. if md, ok := metadata.FromIncomingContext(ctx); ok { szID, szIDOK = md[RequestIDKey] } else if md, ok := metadata.FromOutgoingContext(ctx); ok { szID, szIDOK ...
[ "func", "GetRequestID", "(", "ctx", "context", ".", "Context", ")", "(", "uint64", ",", "bool", ")", "{", "var", "(", "szID", "[", "]", "string", "\n", "szIDOK", "bool", "\n", ")", "\n\n", "// Prefer the incoming context, but look in both types.", "if", "md", ...
// GetRequestID inspects the context for gRPC metadata and returns // its request ID if available.
[ "GetRequestID", "inspects", "the", "context", "for", "gRPC", "metadata", "and", "returns", "its", "request", "ID", "if", "available", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/context/context.go#L43-L63
127,087
rexray/gocsi
context/context.go
WithEnviron
func WithEnviron(ctx context.Context, v []string) context.Context { return context.WithValue(ctx, ctxOSEnviron, v) }
go
func WithEnviron(ctx context.Context, v []string) context.Context { return context.WithValue(ctx, ctxOSEnviron, v) }
[ "func", "WithEnviron", "(", "ctx", "context", ".", "Context", ",", "v", "[", "]", "string", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "ctxOSEnviron", ",", "v", ")", "\n", "}" ]
// WithEnviron returns a new Context with the provided environment variable // string slice.
[ "WithEnviron", "returns", "a", "new", "Context", "with", "the", "provided", "environment", "variable", "string", "slice", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/context/context.go#L67-L69
127,088
rexray/gocsi
context/context.go
WithLookupEnv
func WithLookupEnv(ctx context.Context, f lookupEnvFunc) context.Context { return context.WithValue(ctx, ctxOSLookupEnvKey, f) }
go
func WithLookupEnv(ctx context.Context, f lookupEnvFunc) context.Context { return context.WithValue(ctx, ctxOSLookupEnvKey, f) }
[ "func", "WithLookupEnv", "(", "ctx", "context", ".", "Context", ",", "f", "lookupEnvFunc", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "ctxOSLookupEnvKey", ",", "f", ")", "\n", "}" ]
// WithLookupEnv returns a new Context with the provided function.
[ "WithLookupEnv", "returns", "a", "new", "Context", "with", "the", "provided", "function", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/context/context.go#L72-L74
127,089
rexray/gocsi
context/context.go
WithSetenv
func WithSetenv(ctx context.Context, f setenvFunc) context.Context { return context.WithValue(ctx, ctxOSSetenvKey, f) }
go
func WithSetenv(ctx context.Context, f setenvFunc) context.Context { return context.WithValue(ctx, ctxOSSetenvKey, f) }
[ "func", "WithSetenv", "(", "ctx", "context", ".", "Context", ",", "f", "setenvFunc", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "ctxOSSetenvKey", ",", "f", ")", "\n", "}" ]
// WithSetenv returns a new Context with the provided function.
[ "WithSetenv", "returns", "a", "new", "Context", "with", "the", "provided", "function", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/context/context.go#L77-L79
127,090
rexray/gocsi
context/context.go
Getenv
func Getenv(ctx context.Context, key string) string { val, _ := LookupEnv(ctx, key) return val }
go
func Getenv(ctx context.Context, key string) string { val, _ := LookupEnv(ctx, key) return val }
[ "func", "Getenv", "(", "ctx", "context", ".", "Context", ",", "key", "string", ")", "string", "{", "val", ",", "_", ":=", "LookupEnv", "(", "ctx", ",", "key", ")", "\n", "return", "val", "\n", "}" ]
// Getenv is an alias for LookupEnv and drops the boolean return value.
[ "Getenv", "is", "an", "alias", "for", "LookupEnv", "and", "drops", "the", "boolean", "return", "value", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/context/context.go#L114-L117
127,091
rexray/gocsi
mock/provider/provider.go
New
func New() gocsi.StoragePluginProvider { svc := service.New() return &gocsi.StoragePlugin{ Controller: svc, Identity: svc, Node: svc, // BeforeServe allows the SP to participate in the startup // sequence. This function is invoked directly before the // gRPC server is created, giving the callback...
go
func New() gocsi.StoragePluginProvider { svc := service.New() return &gocsi.StoragePlugin{ Controller: svc, Identity: svc, Node: svc, // BeforeServe allows the SP to participate in the startup // sequence. This function is invoked directly before the // gRPC server is created, giving the callback...
[ "func", "New", "(", ")", "gocsi", ".", "StoragePluginProvider", "{", "svc", ":=", "service", ".", "New", "(", ")", "\n", "return", "&", "gocsi", ".", "StoragePlugin", "{", "Controller", ":", "svc", ",", "Identity", ":", "svc", ",", "Node", ":", "svc", ...
// New returns a new Mock Storage Plug-in Provider.
[ "New", "returns", "a", "new", "Mock", "Storage", "Plug", "-", "in", "Provider", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/mock/provider/provider.go#L14-L53
127,092
rexray/gocsi
utils/utils_middleware.go
ChainUnaryClient
func ChainUnaryClient( i ...grpc.UnaryClientInterceptor) grpc.UnaryClientInterceptor { switch len(i) { case 0: return func( ctx context.Context, method string, req, rep interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { return invoker(ctx, method, re...
go
func ChainUnaryClient( i ...grpc.UnaryClientInterceptor) grpc.UnaryClientInterceptor { switch len(i) { case 0: return func( ctx context.Context, method string, req, rep interface{}, cc *grpc.ClientConn, invoker grpc.UnaryInvoker, opts ...grpc.CallOption) error { return invoker(ctx, method, re...
[ "func", "ChainUnaryClient", "(", "i", "...", "grpc", ".", "UnaryClientInterceptor", ")", "grpc", ".", "UnaryClientInterceptor", "{", "switch", "len", "(", "i", ")", "{", "case", "0", ":", "return", "func", "(", "ctx", "context", ".", "Context", ",", "metho...
// ChainUnaryClient chains one or more unary, client interceptors // together into a left-to-right series that can be provided to a // new gRPC client.
[ "ChainUnaryClient", "chains", "one", "or", "more", "unary", "client", "interceptors", "together", "into", "a", "left", "-", "to", "-", "right", "series", "that", "can", "be", "provided", "to", "a", "new", "gRPC", "client", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/utils/utils_middleware.go#L13-L66
127,093
rexray/gocsi
utils/utils_middleware.go
ChainUnaryServer
func ChainUnaryServer( i ...grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor { switch len(i) { case 0: return func( ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { return handler(ctx, req) } case 1: return i[0] } retur...
go
func ChainUnaryServer( i ...grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor { switch len(i) { case 0: return func( ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { return handler(ctx, req) } case 1: return i[0] } retur...
[ "func", "ChainUnaryServer", "(", "i", "...", "grpc", ".", "UnaryServerInterceptor", ")", "grpc", ".", "UnaryServerInterceptor", "{", "switch", "len", "(", "i", ")", "{", "case", "0", ":", "return", "func", "(", "ctx", "context", ".", "Context", ",", "req",...
// ChainUnaryServer chains one or more unary, server interceptors // together into a left-to-right series that can be provided to a // new gRPC server.
[ "ChainUnaryServer", "chains", "one", "or", "more", "unary", "server", "interceptors", "together", "into", "a", "left", "-", "to", "-", "right", "series", "that", "can", "be", "provided", "to", "a", "new", "gRPC", "server", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/utils/utils_middleware.go#L71-L108
127,094
rexray/gocsi
utils/utils_middleware.go
IsNilResponse
func IsNilResponse(rep interface{}) bool { // Determine whether or not the resposne is nil. Otherwise it // will no longer be possible to perform a nil equality check on the // response to the interface{} rules for nil comparison. For more info // please see https://golang.org/doc/faq#nil_error and // https://gith...
go
func IsNilResponse(rep interface{}) bool { // Determine whether or not the resposne is nil. Otherwise it // will no longer be possible to perform a nil equality check on the // response to the interface{} rules for nil comparison. For more info // please see https://golang.org/doc/faq#nil_error and // https://gith...
[ "func", "IsNilResponse", "(", "rep", "interface", "{", "}", ")", "bool", "{", "// Determine whether or not the resposne is nil. Otherwise it", "// will no longer be possible to perform a nil equality check on the", "// response to the interface{} rules for nil comparison. For more info", "...
// IsNilResponse returns a flag indicating whether or not the provided // response object is a nil object wrapped inside a non-nil interface.
[ "IsNilResponse", "returns", "a", "flag", "indicating", "whether", "or", "not", "the", "provided", "response", "object", "is", "a", "nil", "object", "wrapped", "inside", "a", "non", "-", "nil", "interface", "." ]
9407f5f4ed38592fe11b57c1c9d3621df05b753b
https://github.com/rexray/gocsi/blob/9407f5f4ed38592fe11b57c1c9d3621df05b753b/utils/utils_middleware.go#L112-L132
127,095
dustin/go-broadcast
broadcaster.go
NewBroadcaster
func NewBroadcaster(buflen int) Broadcaster { b := &broadcaster{ input: make(chan interface{}, buflen), reg: make(chan chan<- interface{}), unreg: make(chan chan<- interface{}), outputs: make(map[chan<- interface{}]bool), } go b.run() return b }
go
func NewBroadcaster(buflen int) Broadcaster { b := &broadcaster{ input: make(chan interface{}, buflen), reg: make(chan chan<- interface{}), unreg: make(chan chan<- interface{}), outputs: make(map[chan<- interface{}]bool), } go b.run() return b }
[ "func", "NewBroadcaster", "(", "buflen", "int", ")", "Broadcaster", "{", "b", ":=", "&", "broadcaster", "{", "input", ":", "make", "(", "chan", "interface", "{", "}", ",", "buflen", ")", ",", "reg", ":", "make", "(", "chan", "chan", "<-", "interface", ...
// NewBroadcaster creates a new broadcaster with the given input // channel buffer length.
[ "NewBroadcaster", "creates", "a", "new", "broadcaster", "with", "the", "given", "input", "channel", "buffer", "length", "." ]
f664265f5a662fb4d1df7f3533b1e8d0e0277120
https://github.com/dustin/go-broadcast/blob/f664265f5a662fb4d1df7f3533b1e8d0e0277120/broadcaster.go#L56-L67
127,096
tomasen/fcgi_client
fcgiclient.go
Dial
func Dial(network, address string) (fcgi *FCGIClient, err error) { var conn net.Conn conn, err = net.Dial(network, address) if err != nil { return } fcgi = &FCGIClient{ rwc: conn, keepAlive: false, reqId: 1, } return }
go
func Dial(network, address string) (fcgi *FCGIClient, err error) { var conn net.Conn conn, err = net.Dial(network, address) if err != nil { return } fcgi = &FCGIClient{ rwc: conn, keepAlive: false, reqId: 1, } return }
[ "func", "Dial", "(", "network", ",", "address", "string", ")", "(", "fcgi", "*", "FCGIClient", ",", "err", "error", ")", "{", "var", "conn", "net", ".", "Conn", "\n\n", "conn", ",", "err", "=", "net", ".", "Dial", "(", "network", ",", "address", ")...
// Connects to the fcgi responder at the specified network address. // See func net.Dial for a description of the network and address parameters.
[ "Connects", "to", "the", "fcgi", "responder", "at", "the", "specified", "network", "address", ".", "See", "func", "net", ".", "Dial", "for", "a", "description", "of", "the", "network", "and", "address", "parameters", "." ]
2bb3d819fd19569919d3b9ccf746e1bb9938fa8d
https://github.com/tomasen/fcgi_client/blob/2bb3d819fd19569919d3b9ccf746e1bb9938fa8d/fcgiclient.go#L136-L151
127,097
tomasen/fcgi_client
fcgiclient.go
Post
func (this *FCGIClient) Post(p map[string]string, bodyType string, body io.Reader, l int) (resp *http.Response, err error) { if len(p["REQUEST_METHOD"]) == 0 || p["REQUEST_METHOD"] == "GET" { p["REQUEST_METHOD"] = "POST" } p["CONTENT_LENGTH"] = strconv.Itoa(l) if len(bodyType) > 0 { p["CONTENT_TYPE"] = bodyTyp...
go
func (this *FCGIClient) Post(p map[string]string, bodyType string, body io.Reader, l int) (resp *http.Response, err error) { if len(p["REQUEST_METHOD"]) == 0 || p["REQUEST_METHOD"] == "GET" { p["REQUEST_METHOD"] = "POST" } p["CONTENT_LENGTH"] = strconv.Itoa(l) if len(bodyType) > 0 { p["CONTENT_TYPE"] = bodyTyp...
[ "func", "(", "this", "*", "FCGIClient", ")", "Post", "(", "p", "map", "[", "string", "]", "string", ",", "bodyType", "string", ",", "body", "io", ".", "Reader", ",", "l", "int", ")", "(", "resp", "*", "http", ".", "Response", ",", "err", "error", ...
// Get issues a Post request to the fcgi responder. with request body // in the format that bodyType specified
[ "Get", "issues", "a", "Post", "request", "to", "the", "fcgi", "responder", ".", "with", "request", "body", "in", "the", "format", "that", "bodyType", "specified" ]
2bb3d819fd19569919d3b9ccf746e1bb9938fa8d
https://github.com/tomasen/fcgi_client/blob/2bb3d819fd19569919d3b9ccf746e1bb9938fa8d/fcgiclient.go#L453-L466
127,098
kung-foo/freki
netfilter/netfilter.go
New
func New(queueID uint16, maxPacketsInQueue uint32, packetSize uint32) (nfq *Queue, err error) { nfq = &Queue{ ID: queueID, // TODO: what should the chan size be? packets: make(chan *RawPacket, 1024), } var ret C.int defer func() { if err != nil && nfq != nil { if nfq.qh != nil { C.nfq_destroy_queue(...
go
func New(queueID uint16, maxPacketsInQueue uint32, packetSize uint32) (nfq *Queue, err error) { nfq = &Queue{ ID: queueID, // TODO: what should the chan size be? packets: make(chan *RawPacket, 1024), } var ret C.int defer func() { if err != nil && nfq != nil { if nfq.qh != nil { C.nfq_destroy_queue(...
[ "func", "New", "(", "queueID", "uint16", ",", "maxPacketsInQueue", "uint32", ",", "packetSize", "uint32", ")", "(", "nfq", "*", "Queue", ",", "err", "error", ")", "{", "nfq", "=", "&", "Queue", "{", "ID", ":", "queueID", ",", "// TODO: what should the chan...
// New creates a new Queue with the given queue id.
[ "New", "creates", "a", "new", "Queue", "with", "the", "given", "queue", "id", "." ]
37bf522904e242e4b820d9c52667937ea90e24f7
https://github.com/kung-foo/freki/blob/37bf522904e242e4b820d9c52667937ea90e24f7/netfilter/netfilter.go#L80-L144
127,099
kung-foo/freki
netfilter/netfilter.go
SetVerdict
func (nfq *Queue) SetVerdict(packet *RawPacket, verdict Verdict) (err error) { // TODO: make functions explicit. for example: SetVerdictAccept, SetVerdictDrop // TODO: get error C.nfq_set_verdict( nfq.qh, C.u_int32_t(packet.ID), C.u_int32_t(verdict), 0, nil, ) return }
go
func (nfq *Queue) SetVerdict(packet *RawPacket, verdict Verdict) (err error) { // TODO: make functions explicit. for example: SetVerdictAccept, SetVerdictDrop // TODO: get error C.nfq_set_verdict( nfq.qh, C.u_int32_t(packet.ID), C.u_int32_t(verdict), 0, nil, ) return }
[ "func", "(", "nfq", "*", "Queue", ")", "SetVerdict", "(", "packet", "*", "RawPacket", ",", "verdict", "Verdict", ")", "(", "err", "error", ")", "{", "// TODO: make functions explicit. for example: SetVerdictAccept, SetVerdictDrop", "// TODO: get error", "C", ".", "nfq...
// SetVerdict tells nfq how to handle the packet.
[ "SetVerdict", "tells", "nfq", "how", "to", "handle", "the", "packet", "." ]
37bf522904e242e4b820d9c52667937ea90e24f7
https://github.com/kung-foo/freki/blob/37bf522904e242e4b820d9c52667937ea90e24f7/netfilter/netfilter.go#L161-L172