id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
144,200 | TheThingsNetwork/go-account-lib | account/gateways.go | GatewayCollaborators | func (a *Account) GatewayCollaborators(gwID string) ([]Collaborator, error) {
collaborators := make([]Collaborator, 0)
err := a.get(a.auth.WithScope(scope.Gateway(gwID)), fmt.Sprintf("/api/v2/gateways/%s/collaborators", gwID), &collaborators)
if err != nil {
return nil, err
}
return collaborators, nil
} | go | func (a *Account) GatewayCollaborators(gwID string) ([]Collaborator, error) {
collaborators := make([]Collaborator, 0)
err := a.get(a.auth.WithScope(scope.Gateway(gwID)), fmt.Sprintf("/api/v2/gateways/%s/collaborators", gwID), &collaborators)
if err != nil {
return nil, err
}
return collaborators, nil
} | [
"func",
"(",
"a",
"*",
"Account",
")",
"GatewayCollaborators",
"(",
"gwID",
"string",
")",
"(",
"[",
"]",
"Collaborator",
",",
"error",
")",
"{",
"collaborators",
":=",
"make",
"(",
"[",
"]",
"Collaborator",
",",
"0",
")",
"\n",
"err",
":=",
"a",
"."... | // GatewayCollaborators fetches the gateway collaborators | [
"GatewayCollaborators",
"fetches",
"the",
"gateway",
"collaborators"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/account/gateways.go#L254-L262 |
144,201 | TheThingsNetwork/go-account-lib | tokens/redis_store.go | hash | func hash(parent string) string {
res := md5.Sum([]byte(parent))
return string(res[:])
} | go | func hash(parent string) string {
res := md5.Sum([]byte(parent))
return string(res[:])
} | [
"func",
"hash",
"(",
"parent",
"string",
")",
"string",
"{",
"res",
":=",
"md5",
".",
"Sum",
"(",
"[",
"]",
"byte",
"(",
"parent",
")",
")",
"\n",
"return",
"string",
"(",
"res",
"[",
":",
"]",
")",
"\n",
"}"
] | // hash hashes the parent token to make shorter redis keys | [
"hash",
"hashes",
"the",
"parent",
"token",
"to",
"make",
"shorter",
"redis",
"keys"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/tokens/redis_store.go#L22-L25 |
144,202 | TheThingsNetwork/go-account-lib | tokens/redis_store.go | RedisStore | func RedisStore(client *redis.Client) TokenStore {
if client == nil {
panic("RedisStore: redis client is nil")
}
return &redisStore{
client: client,
}
} | go | func RedisStore(client *redis.Client) TokenStore {
if client == nil {
panic("RedisStore: redis client is nil")
}
return &redisStore{
client: client,
}
} | [
"func",
"RedisStore",
"(",
"client",
"*",
"redis",
".",
"Client",
")",
"TokenStore",
"{",
"if",
"client",
"==",
"nil",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"&",
"redisStore",
"{",
"client",
":",
"client",
",",
"}",
"\n",
"... | // RedisStore returns a TokenStore that stores tokens in redis | [
"RedisStore",
"returns",
"a",
"TokenStore",
"that",
"stores",
"tokens",
"in",
"redis"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/tokens/redis_store.go#L38-L45 |
144,203 | TheThingsNetwork/go-account-lib | tokens/redis_store.go | Get | func (s *redisStore) Get(parent, scope string) (string, error) {
token, err := s.client.Get(key(parent, scope)).Result()
if err != nil {
if err == redis.Nil {
return "", nil
}
return "", err
}
return token, err
} | go | func (s *redisStore) Get(parent, scope string) (string, error) {
token, err := s.client.Get(key(parent, scope)).Result()
if err != nil {
if err == redis.Nil {
return "", nil
}
return "", err
}
return token, err
} | [
"func",
"(",
"s",
"*",
"redisStore",
")",
"Get",
"(",
"parent",
",",
"scope",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"token",
",",
"err",
":=",
"s",
".",
"client",
".",
"Get",
"(",
"key",
"(",
"parent",
",",
"scope",
")",
")",
".... | // Get gets a token that was derived from parent for the specified scope
// if it exists in redis | [
"Get",
"gets",
"a",
"token",
"that",
"was",
"derived",
"from",
"parent",
"for",
"the",
"specified",
"scope",
"if",
"it",
"exists",
"in",
"redis"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/tokens/redis_store.go#L49-L59 |
144,204 | TheThingsNetwork/go-account-lib | tokens/redis_store.go | Set | func (s *redisStore) Set(parent string, scopes []string, token string, TTL time.Duration) (err error) {
// use expiry from parent token
claims, err := claims.FromTokenWithoutValidation(parent)
if err != nil {
return err
}
// get ttl from token
ttl := time.Unix(claims.ExpiresAt, 0).Sub(time.Now()) - TTLMargin
... | go | func (s *redisStore) Set(parent string, scopes []string, token string, TTL time.Duration) (err error) {
// use expiry from parent token
claims, err := claims.FromTokenWithoutValidation(parent)
if err != nil {
return err
}
// get ttl from token
ttl := time.Unix(claims.ExpiresAt, 0).Sub(time.Now()) - TTLMargin
... | [
"func",
"(",
"s",
"*",
"redisStore",
")",
"Set",
"(",
"parent",
"string",
",",
"scopes",
"[",
"]",
"string",
",",
"token",
"string",
",",
"TTL",
"time",
".",
"Duration",
")",
"(",
"err",
"error",
")",
"{",
"// use expiry from parent token",
"claims",
","... | // Set saves the token that is derived from parent and that has the specified
// scopes to the redis store | [
"Set",
"saves",
"the",
"token",
"that",
"is",
"derived",
"from",
"parent",
"and",
"that",
"has",
"the",
"specified",
"scopes",
"to",
"the",
"redis",
"store"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/tokens/redis_store.go#L63-L90 |
144,205 | TheThingsNetwork/go-account-lib | tokenkey/const_provider.go | ConstProvider | func ConstProvider(key, algorithm string) Provider {
return &constProvider{
key: &TokenKey{
Algorithm: algorithm,
Key: key,
},
}
} | go | func ConstProvider(key, algorithm string) Provider {
return &constProvider{
key: &TokenKey{
Algorithm: algorithm,
Key: key,
},
}
} | [
"func",
"ConstProvider",
"(",
"key",
",",
"algorithm",
"string",
")",
"Provider",
"{",
"return",
"&",
"constProvider",
"{",
"key",
":",
"&",
"TokenKey",
"{",
"Algorithm",
":",
"algorithm",
",",
"Key",
":",
"key",
",",
"}",
",",
"}",
"\n",
"}"
] | // ConstProvider creates Provider that always resturns the same TokenKey | [
"ConstProvider",
"creates",
"Provider",
"that",
"always",
"resturns",
"the",
"same",
"TokenKey"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/tokenkey/const_provider.go#L12-L19 |
144,206 | TheThingsNetwork/go-account-lib | claims/parse_gateway.go | FromGatewayToken | func FromGatewayToken(provider tokenkey.Provider, gatewayToken string) (*GatewayClaims, error) {
claims := &GatewayClaims{}
if err := fromToken(provider, gatewayToken, claims); err != nil {
return nil, err
}
if claims.Type != "gateway" {
return nil, fmt.Errorf("Expected gateway token to have type 'gateway', bu... | go | func FromGatewayToken(provider tokenkey.Provider, gatewayToken string) (*GatewayClaims, error) {
claims := &GatewayClaims{}
if err := fromToken(provider, gatewayToken, claims); err != nil {
return nil, err
}
if claims.Type != "gateway" {
return nil, fmt.Errorf("Expected gateway token to have type 'gateway', bu... | [
"func",
"FromGatewayToken",
"(",
"provider",
"tokenkey",
".",
"Provider",
",",
"gatewayToken",
"string",
")",
"(",
"*",
"GatewayClaims",
",",
"error",
")",
"{",
"claims",
":=",
"&",
"GatewayClaims",
"{",
"}",
"\n",
"if",
"err",
":=",
"fromToken",
"(",
"pro... | // FromGatewayToken uses the tokenkey provider to parse and validate a gateway token into its
// corresponding claims | [
"FromGatewayToken",
"uses",
"the",
"tokenkey",
"provider",
"to",
"parse",
"and",
"validate",
"a",
"gateway",
"token",
"into",
"its",
"corresponding",
"claims"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/claims/parse_gateway.go#L14-L25 |
144,207 | TheThingsNetwork/go-account-lib | claims/parse_gateway.go | FromGatewayTokenWithoutValidation | func FromGatewayTokenWithoutValidation(gatewayToken string) (*GatewayClaims, error) {
claims := &GatewayClaims{}
return claims, fromTokenWithoutValidation(gatewayToken, claims)
} | go | func FromGatewayTokenWithoutValidation(gatewayToken string) (*GatewayClaims, error) {
claims := &GatewayClaims{}
return claims, fromTokenWithoutValidation(gatewayToken, claims)
} | [
"func",
"FromGatewayTokenWithoutValidation",
"(",
"gatewayToken",
"string",
")",
"(",
"*",
"GatewayClaims",
",",
"error",
")",
"{",
"claims",
":=",
"&",
"GatewayClaims",
"{",
"}",
"\n",
"return",
"claims",
",",
"fromTokenWithoutValidation",
"(",
"gatewayToken",
",... | // FromGatewayTokenWithoutValidation parses a token into its corresponding
// gateway claims, without checking the token signature | [
"FromGatewayTokenWithoutValidation",
"parses",
"a",
"token",
"into",
"its",
"corresponding",
"gateway",
"claims",
"without",
"checking",
"the",
"token",
"signature"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/claims/parse_gateway.go#L29-L32 |
144,208 | TheThingsNetwork/go-account-lib | cache/writetrough_cache.go | WriteTroughCache | func WriteTroughCache(dirname string) Cache {
return &writeTroughCache{
memory: MemoryCache(),
file: FileCache(dirname),
}
} | go | func WriteTroughCache(dirname string) Cache {
return &writeTroughCache{
memory: MemoryCache(),
file: FileCache(dirname),
}
} | [
"func",
"WriteTroughCache",
"(",
"dirname",
"string",
")",
"Cache",
"{",
"return",
"&",
"writeTroughCache",
"{",
"memory",
":",
"MemoryCache",
"(",
")",
",",
"file",
":",
"FileCache",
"(",
"dirname",
")",
",",
"}",
"\n",
"}"
] | // WriteTroughCache creates a cache that stores keys in memory
// and uses disk as fallback | [
"WriteTroughCache",
"creates",
"a",
"cache",
"that",
"stores",
"keys",
"in",
"memory",
"and",
"uses",
"disk",
"as",
"fallback"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/cache/writetrough_cache.go#L13-L18 |
144,209 | TheThingsNetwork/go-account-lib | cache/writetrough_cache.go | WriteTroughCacheWithNameFn | func WriteTroughCacheWithNameFn(dirname string, fn func(string) string) Cache {
return &writeTroughCache{
memory: MemoryCache(),
file: FileCacheWithNameFn(dirname, fn),
}
} | go | func WriteTroughCacheWithNameFn(dirname string, fn func(string) string) Cache {
return &writeTroughCache{
memory: MemoryCache(),
file: FileCacheWithNameFn(dirname, fn),
}
} | [
"func",
"WriteTroughCacheWithNameFn",
"(",
"dirname",
"string",
",",
"fn",
"func",
"(",
"string",
")",
"string",
")",
"Cache",
"{",
"return",
"&",
"writeTroughCache",
"{",
"memory",
":",
"MemoryCache",
"(",
")",
",",
"file",
":",
"FileCacheWithNameFn",
"(",
... | // WriteTroughCacheWithNameFn creates a cache that stores keys in memory
// and uses disk as fallback. It generates filenames based on the passed in
// function. | [
"WriteTroughCacheWithNameFn",
"creates",
"a",
"cache",
"that",
"stores",
"keys",
"in",
"memory",
"and",
"uses",
"disk",
"as",
"fallback",
".",
"It",
"generates",
"filenames",
"based",
"on",
"the",
"passed",
"in",
"function",
"."
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/cache/writetrough_cache.go#L23-L28 |
144,210 | TheThingsNetwork/go-account-lib | cache/writetrough_cache.go | WriteTroughCacheWithFormat | func WriteTroughCacheWithFormat(dirname, format string) Cache {
return &writeTroughCache{
memory: MemoryCache(),
file: FileCacheWithFormat(dirname, format),
}
} | go | func WriteTroughCacheWithFormat(dirname, format string) Cache {
return &writeTroughCache{
memory: MemoryCache(),
file: FileCacheWithFormat(dirname, format),
}
} | [
"func",
"WriteTroughCacheWithFormat",
"(",
"dirname",
",",
"format",
"string",
")",
"Cache",
"{",
"return",
"&",
"writeTroughCache",
"{",
"memory",
":",
"MemoryCache",
"(",
")",
",",
"file",
":",
"FileCacheWithFormat",
"(",
"dirname",
",",
"format",
")",
",",
... | // WriteTroughCacheWithFormat creates a cache that stores keys in memory
// and uses disk as fallback and that generates filenames based on the format | [
"WriteTroughCacheWithFormat",
"creates",
"a",
"cache",
"that",
"stores",
"keys",
"in",
"memory",
"and",
"uses",
"disk",
"as",
"fallback",
"and",
"that",
"generates",
"filenames",
"based",
"on",
"the",
"format"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/cache/writetrough_cache.go#L32-L37 |
144,211 | TheThingsNetwork/go-account-lib | cache/writetrough_cache.go | Get | func (c *writeTroughCache) Get(key string) ([]byte, error) {
// Try to read from memory cache
data, err := c.memory.Get(key)
if err != nil {
return nil, err
}
if data != nil {
return data, nil
}
// Try to read from cache file
data, err = c.file.Get(key)
if err != nil {
return nil, err
}
// Store in ... | go | func (c *writeTroughCache) Get(key string) ([]byte, error) {
// Try to read from memory cache
data, err := c.memory.Get(key)
if err != nil {
return nil, err
}
if data != nil {
return data, nil
}
// Try to read from cache file
data, err = c.file.Get(key)
if err != nil {
return nil, err
}
// Store in ... | [
"func",
"(",
"c",
"*",
"writeTroughCache",
")",
"Get",
"(",
"key",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"// Try to read from memory cache",
"data",
",",
"err",
":=",
"c",
".",
"memory",
".",
"Get",
"(",
"key",
")",
"\n",
"if"... | // Get gets the data from memory, and tries to read from disk
// if not there, caching the result | [
"Get",
"gets",
"the",
"data",
"from",
"memory",
"and",
"tries",
"to",
"read",
"from",
"disk",
"if",
"not",
"there",
"caching",
"the",
"result"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/cache/writetrough_cache.go#L41-L65 |
144,212 | TheThingsNetwork/go-account-lib | cache/writetrough_cache.go | Set | func (c *writeTroughCache) Set(key string, data []byte) error {
err := c.memory.Set(key, data)
if err != nil {
return err
}
err = c.file.Set(key, data)
if err != nil {
return err
}
return nil
} | go | func (c *writeTroughCache) Set(key string, data []byte) error {
err := c.memory.Set(key, data)
if err != nil {
return err
}
err = c.file.Set(key, data)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"c",
"*",
"writeTroughCache",
")",
"Set",
"(",
"key",
"string",
",",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"err",
":=",
"c",
".",
"memory",
".",
"Set",
"(",
"key",
",",
"data",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"retu... | // Set stores the data in memory and on disk | [
"Set",
"stores",
"the",
"data",
"in",
"memory",
"and",
"on",
"disk"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/cache/writetrough_cache.go#L68-L80 |
144,213 | TheThingsNetwork/go-account-lib | auth/access_token.go | DecorateRequest | func (a *accessToken) DecorateRequest(req *http.Request) {
var token string
// try to get new token and fall back to parent token
if a.scope != "" {
token, _ = a.manager.TokenForScope(a.scope)
}
if token == "" {
token = a.accessToken
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
} | go | func (a *accessToken) DecorateRequest(req *http.Request) {
var token string
// try to get new token and fall back to parent token
if a.scope != "" {
token, _ = a.manager.TokenForScope(a.scope)
}
if token == "" {
token = a.accessToken
}
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", token))
} | [
"func",
"(",
"a",
"*",
"accessToken",
")",
"DecorateRequest",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"{",
"var",
"token",
"string",
"\n\n",
"// try to get new token and fall back to parent token",
"if",
"a",
".",
"scope",
"!=",
"\"",
"\"",
"{",
"token",... | // DecorateRequest gets the correct access token and uses that to
// decorate the request | [
"DecorateRequest",
"gets",
"the",
"correct",
"access",
"token",
"and",
"uses",
"that",
"to",
"decorate",
"the",
"request"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/auth/access_token.go#L23-L36 |
144,214 | TheThingsNetwork/go-account-lib | auth/access_token.go | WithScope | func (a *accessToken) WithScope(scope string) Strategy {
return &accessToken{
accessToken: a.accessToken,
manager: a.manager,
scope: scope,
}
} | go | func (a *accessToken) WithScope(scope string) Strategy {
return &accessToken{
accessToken: a.accessToken,
manager: a.manager,
scope: scope,
}
} | [
"func",
"(",
"a",
"*",
"accessToken",
")",
"WithScope",
"(",
"scope",
"string",
")",
"Strategy",
"{",
"return",
"&",
"accessToken",
"{",
"accessToken",
":",
"a",
".",
"accessToken",
",",
"manager",
":",
"a",
".",
"manager",
",",
"scope",
":",
"scope",
... | // WithScope creates a new Strategy with | [
"WithScope",
"creates",
"a",
"new",
"Strategy",
"with"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/auth/access_token.go#L39-L45 |
144,215 | TheThingsNetwork/go-account-lib | auth/access_token.go | AccessToken | func AccessToken(s string) Strategy {
return &accessToken{
accessToken: s,
manager: tokens.HTTPManager("", s, tokens.NullStore),
}
} | go | func AccessToken(s string) Strategy {
return &accessToken{
accessToken: s,
manager: tokens.HTTPManager("", s, tokens.NullStore),
}
} | [
"func",
"AccessToken",
"(",
"s",
"string",
")",
"Strategy",
"{",
"return",
"&",
"accessToken",
"{",
"accessToken",
":",
"s",
",",
"manager",
":",
"tokens",
".",
"HTTPManager",
"(",
"\"",
"\"",
",",
"s",
",",
"tokens",
".",
"NullStore",
")",
",",
"}",
... | // AccessToken returns an authorization strategy that uses the specified
// access token to authorize | [
"AccessToken",
"returns",
"an",
"authorization",
"strategy",
"that",
"uses",
"the",
"specified",
"access",
"token",
"to",
"authorize"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/auth/access_token.go#L49-L54 |
144,216 | TheThingsNetwork/go-account-lib | auth/access_token.go | AccessTokenWithManager | func AccessTokenWithManager(s string, manager tokens.Manager) Strategy {
return &accessToken{
accessToken: s,
manager: manager,
}
} | go | func AccessTokenWithManager(s string, manager tokens.Manager) Strategy {
return &accessToken{
accessToken: s,
manager: manager,
}
} | [
"func",
"AccessTokenWithManager",
"(",
"s",
"string",
",",
"manager",
"tokens",
".",
"Manager",
")",
"Strategy",
"{",
"return",
"&",
"accessToken",
"{",
"accessToken",
":",
"s",
",",
"manager",
":",
"manager",
",",
"}",
"\n",
"}"
] | // AccessTokenWithManager returns an authorization strategy that uses the specified
// access token to authorize and that uses the specified manager to
// fetch new tokens if required. | [
"AccessTokenWithManager",
"returns",
"an",
"authorization",
"strategy",
"that",
"uses",
"the",
"specified",
"access",
"token",
"to",
"authorize",
"and",
"that",
"uses",
"the",
"specified",
"manager",
"to",
"fetch",
"new",
"tokens",
"if",
"required",
"."
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/auth/access_token.go#L59-L64 |
144,217 | TheThingsNetwork/go-account-lib | auth/basic_auth.go | BasicAuth | func BasicAuth(username, password string) Strategy {
return &basicAuth{
username: username,
password: password,
}
} | go | func BasicAuth(username, password string) Strategy {
return &basicAuth{
username: username,
password: password,
}
} | [
"func",
"BasicAuth",
"(",
"username",
",",
"password",
"string",
")",
"Strategy",
"{",
"return",
"&",
"basicAuth",
"{",
"username",
":",
"username",
",",
"password",
":",
"password",
",",
"}",
"\n",
"}"
] | // BasicAuth creates a authorization strategy that uses
// uses username and password in HTTP Basic Auth | [
"BasicAuth",
"creates",
"a",
"authorization",
"strategy",
"that",
"uses",
"uses",
"username",
"and",
"password",
"in",
"HTTP",
"Basic",
"Auth"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/auth/basic_auth.go#L25-L30 |
144,218 | TheThingsNetwork/go-account-lib | cache/memory_cache.go | Get | func (c *memoryCache) Get(key string) ([]byte, error) {
c.RLock()
defer c.RUnlock()
cached, ok := c.cache[key]
if ok {
return cached, nil
}
return nil, nil
} | go | func (c *memoryCache) Get(key string) ([]byte, error) {
c.RLock()
defer c.RUnlock()
cached, ok := c.cache[key]
if ok {
return cached, nil
}
return nil, nil
} | [
"func",
"(",
"c",
"*",
"memoryCache",
")",
"Get",
"(",
"key",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"c",
".",
"RLock",
"(",
")",
"\n",
"defer",
"c",
".",
"RUnlock",
"(",
")",
"\n\n",
"cached",
",",
"ok",
":=",
"c",
"."... | // Get gets the data from memory if it exists | [
"Get",
"gets",
"the",
"data",
"from",
"memory",
"if",
"it",
"exists"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/cache/memory_cache.go#L22-L32 |
144,219 | TheThingsNetwork/go-account-lib | cache/memory_cache.go | Set | func (c *memoryCache) Set(key string, data []byte) error {
c.Lock()
defer c.Unlock()
c.cache[key] = data
return nil
} | go | func (c *memoryCache) Set(key string, data []byte) error {
c.Lock()
defer c.Unlock()
c.cache[key] = data
return nil
} | [
"func",
"(",
"c",
"*",
"memoryCache",
")",
"Set",
"(",
"key",
"string",
",",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"c",
".",
"Lock",
"(",
")",
"\n",
"defer",
"c",
".",
"Unlock",
"(",
")",
"\n\n",
"c",
".",
"cache",
"[",
"key",
"]",
"="... | // Set saves the data to memory | [
"Set",
"saves",
"the",
"data",
"to",
"memory"
] | 3314753327942c0aed5a2a9233d4f001454c21a9 | https://github.com/TheThingsNetwork/go-account-lib/blob/3314753327942c0aed5a2a9233d4f001454c21a9/cache/memory_cache.go#L35-L41 |
144,220 | fvbommel/util | rope/rebalance.go | getFibCache | func getFibCache(N int64) []int64 {
fibLock.RLock()
defer fibLock.RUnlock()
if fibCache[len(fibCache)-1] < N {
// Calculate some more numbers
extendFibs(N)
}
return fibCache
} | go | func getFibCache(N int64) []int64 {
fibLock.RLock()
defer fibLock.RUnlock()
if fibCache[len(fibCache)-1] < N {
// Calculate some more numbers
extendFibs(N)
}
return fibCache
} | [
"func",
"getFibCache",
"(",
"N",
"int64",
")",
"[",
"]",
"int64",
"{",
"fibLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"fibLock",
".",
"RUnlock",
"(",
")",
"\n\n",
"if",
"fibCache",
"[",
"len",
"(",
"fibCache",
")",
"-",
"1",
"]",
"<",
"N",
"{"... | // getFibCache gets a reference to the current fibCache, extended to at least
// cover N. This reference is safe to use without locking since the only
// modification to fibCache is appending, which doesn't affect previous slices. | [
"getFibCache",
"gets",
"a",
"reference",
"to",
"the",
"current",
"fibCache",
"extended",
"to",
"at",
"least",
"cover",
"N",
".",
"This",
"reference",
"is",
"safe",
"to",
"use",
"without",
"locking",
"since",
"the",
"only",
"modification",
"to",
"fibCache",
"... | efcd4e0f97874370259c7d93e12aad57911dea81 | https://github.com/fvbommel/util/blob/efcd4e0f97874370259c7d93e12aad57911dea81/rope/rebalance.go#L52-L61 |
144,221 | fvbommel/util | rope/rebalance.go | Rebalance | func (r Rope) Rebalance() Rope {
if r.node == nil {
return r
}
rLen := r.Len()
fibs := getFibCache(rLen)
// The concatenation of non-empty nodes in the scratch array, in order of
// decreasing index, is equivalent to the concatenation of leaves walked
// so far.
type B struct {
n node
len int64
}
sc... | go | func (r Rope) Rebalance() Rope {
if r.node == nil {
return r
}
rLen := r.Len()
fibs := getFibCache(rLen)
// The concatenation of non-empty nodes in the scratch array, in order of
// decreasing index, is equivalent to the concatenation of leaves walked
// so far.
type B struct {
n node
len int64
}
sc... | [
"func",
"(",
"r",
"Rope",
")",
"Rebalance",
"(",
")",
"Rope",
"{",
"if",
"r",
".",
"node",
"==",
"nil",
"{",
"return",
"r",
"\n",
"}",
"\n\n",
"rLen",
":=",
"r",
".",
"Len",
"(",
")",
"\n",
"fibs",
":=",
"getFibCache",
"(",
"rLen",
")",
"\n\n",... | // Rebalance rebalances a rope. | [
"Rebalance",
"rebalances",
"a",
"rope",
"."
] | efcd4e0f97874370259c7d93e12aad57911dea81 | https://github.com/fvbommel/util/blob/efcd4e0f97874370259c7d93e12aad57911dea81/rope/rebalance.go#L100-L159 |
144,222 | fvbommel/util | rope/rope.go | New | func New(arg string) Rope {
if len(arg) == 0 {
return emptyRope
}
return Rope{
node: leaf(arg),
}
} | go | func New(arg string) Rope {
if len(arg) == 0 {
return emptyRope
}
return Rope{
node: leaf(arg),
}
} | [
"func",
"New",
"(",
"arg",
"string",
")",
"Rope",
"{",
"if",
"len",
"(",
"arg",
")",
"==",
"0",
"{",
"return",
"emptyRope",
"\n",
"}",
"\n",
"return",
"Rope",
"{",
"node",
":",
"leaf",
"(",
"arg",
")",
",",
"}",
"\n",
"}"
] | // New returns a Rope representing a given string. | [
"New",
"returns",
"a",
"Rope",
"representing",
"a",
"given",
"string",
"."
] | efcd4e0f97874370259c7d93e12aad57911dea81 | https://github.com/fvbommel/util/blob/efcd4e0f97874370259c7d93e12aad57911dea81/rope/rope.go#L27-L34 |
144,223 | fvbommel/util | rope/rope.go | String | func (r Rope) String() string {
if r.node == nil {
return ""
}
// In the trivial case, avoid allocation
if l, ok := r.node.(leaf); ok {
return string(l)
}
// The rope is not contiguous.
return string(r.Bytes())
} | go | func (r Rope) String() string {
if r.node == nil {
return ""
}
// In the trivial case, avoid allocation
if l, ok := r.node.(leaf); ok {
return string(l)
}
// The rope is not contiguous.
return string(r.Bytes())
} | [
"func",
"(",
"r",
"Rope",
")",
"String",
"(",
")",
"string",
"{",
"if",
"r",
".",
"node",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"// In the trivial case, avoid allocation",
"if",
"l",
",",
"ok",
":=",
"r",
".",
"node",
".",
"(",
"... | // String materializes the Rope as a string value. | [
"String",
"materializes",
"the",
"Rope",
"as",
"a",
"string",
"value",
"."
] | efcd4e0f97874370259c7d93e12aad57911dea81 | https://github.com/fvbommel/util/blob/efcd4e0f97874370259c7d93e12aad57911dea81/rope/rope.go#L37-L47 |
144,224 | fvbommel/util | rope/rope.go | GoString | func (r Rope) GoString() string {
// Perhaps technically more correct, but not nearly as useful:
// return fmt.Sprintf("rope.New(%q)", r.String())
// Instead, (mostly) pretend we're a regular string.
if MarkGoStringedRope {
return fmt.Sprintf("/*Rope*/ %#v", r.String())
}
return fmt.Sprintf("%#v", r.String())... | go | func (r Rope) GoString() string {
// Perhaps technically more correct, but not nearly as useful:
// return fmt.Sprintf("rope.New(%q)", r.String())
// Instead, (mostly) pretend we're a regular string.
if MarkGoStringedRope {
return fmt.Sprintf("/*Rope*/ %#v", r.String())
}
return fmt.Sprintf("%#v", r.String())... | [
"func",
"(",
"r",
"Rope",
")",
"GoString",
"(",
")",
"string",
"{",
"// Perhaps technically more correct, but not nearly as useful:",
"//\t return fmt.Sprintf(\"rope.New(%q)\", r.String())",
"// Instead, (mostly) pretend we're a regular string.",
"if",
"MarkGoStringedRope",
"{",
"ret... | // GoString materializes the Rope as a quoted string value. | [
"GoString",
"materializes",
"the",
"Rope",
"as",
"a",
"quoted",
"string",
"value",
"."
] | efcd4e0f97874370259c7d93e12aad57911dea81 | https://github.com/fvbommel/util/blob/efcd4e0f97874370259c7d93e12aad57911dea81/rope/rope.go#L50-L59 |
144,225 | fvbommel/util | rope/rope.go | WriteTo | func (r Rope) WriteTo(w io.Writer) (n int64, err error) {
if r.node == nil {
return 0, nil // Nothing to do
}
return r.node.WriteTo(w)
} | go | func (r Rope) WriteTo(w io.Writer) (n int64, err error) {
if r.node == nil {
return 0, nil // Nothing to do
}
return r.node.WriteTo(w)
} | [
"func",
"(",
"r",
"Rope",
")",
"WriteTo",
"(",
"w",
"io",
".",
"Writer",
")",
"(",
"n",
"int64",
",",
"err",
"error",
")",
"{",
"if",
"r",
".",
"node",
"==",
"nil",
"{",
"return",
"0",
",",
"nil",
"// Nothing to do",
"\n",
"}",
"\n",
"return",
... | // WriteTo writes the value of this Rope to the provided writer. | [
"WriteTo",
"writes",
"the",
"value",
"of",
"this",
"Rope",
"to",
"the",
"provided",
"writer",
"."
] | efcd4e0f97874370259c7d93e12aad57911dea81 | https://github.com/fvbommel/util/blob/efcd4e0f97874370259c7d93e12aad57911dea81/rope/rope.go#L73-L78 |
144,226 | fvbommel/util | rope/rope.go | Len | func (r Rope) Len() int64 {
if r.node == nil {
return 0
}
return r.node.length()
} | go | func (r Rope) Len() int64 {
if r.node == nil {
return 0
}
return r.node.length()
} | [
"func",
"(",
"r",
"Rope",
")",
"Len",
"(",
")",
"int64",
"{",
"if",
"r",
".",
"node",
"==",
"nil",
"{",
"return",
"0",
"\n",
"}",
"\n",
"return",
"r",
".",
"node",
".",
"length",
"(",
")",
"\n",
"}"
] | // Len returns the length of the string represented by the Rope. | [
"Len",
"returns",
"the",
"length",
"of",
"the",
"string",
"represented",
"by",
"the",
"Rope",
"."
] | efcd4e0f97874370259c7d93e12aad57911dea81 | https://github.com/fvbommel/util/blob/efcd4e0f97874370259c7d93e12aad57911dea81/rope/rope.go#L90-L95 |
144,227 | fvbommel/util | rope/rope.go | Append | func (r Rope) Append(rhs ...Rope) Rope {
// Handle nil-node receiver
for r.node == nil && len(rhs) > 0 {
r = rhs[0]
rhs = rhs[1:]
}
if len(rhs) == 0 {
return r
}
list := make([]node, 0, len(rhs))
for _, item := range rhs {
if item.node != nil && item.node != emptyNode {
list = append(list, item.node)... | go | func (r Rope) Append(rhs ...Rope) Rope {
// Handle nil-node receiver
for r.node == nil && len(rhs) > 0 {
r = rhs[0]
rhs = rhs[1:]
}
if len(rhs) == 0 {
return r
}
list := make([]node, 0, len(rhs))
for _, item := range rhs {
if item.node != nil && item.node != emptyNode {
list = append(list, item.node)... | [
"func",
"(",
"r",
"Rope",
")",
"Append",
"(",
"rhs",
"...",
"Rope",
")",
"Rope",
"{",
"// Handle nil-node receiver",
"for",
"r",
".",
"node",
"==",
"nil",
"&&",
"len",
"(",
"rhs",
")",
">",
"0",
"{",
"r",
"=",
"rhs",
"[",
"0",
"]",
"\n",
"rhs",
... | // Append returns the Rope representing the arguments appended to this rope. | [
"Append",
"returns",
"the",
"Rope",
"representing",
"the",
"arguments",
"appended",
"to",
"this",
"rope",
"."
] | efcd4e0f97874370259c7d93e12aad57911dea81 | https://github.com/fvbommel/util/blob/efcd4e0f97874370259c7d93e12aad57911dea81/rope/rope.go#L104-L122 |
144,228 | fvbommel/util | rope/rope.go | AppendString | func (r Rope) AppendString(rhs ...string) Rope {
leafs := make([]node, 0, len(rhs))
for _, str := range rhs {
if len(str) != 0 {
leafs = append(leafs, leaf(str))
}
}
return balanced(Rope{node: concMany(r.node, leafs...)})
} | go | func (r Rope) AppendString(rhs ...string) Rope {
leafs := make([]node, 0, len(rhs))
for _, str := range rhs {
if len(str) != 0 {
leafs = append(leafs, leaf(str))
}
}
return balanced(Rope{node: concMany(r.node, leafs...)})
} | [
"func",
"(",
"r",
"Rope",
")",
"AppendString",
"(",
"rhs",
"...",
"string",
")",
"Rope",
"{",
"leafs",
":=",
"make",
"(",
"[",
"]",
"node",
",",
"0",
",",
"len",
"(",
"rhs",
")",
")",
"\n",
"for",
"_",
",",
"str",
":=",
"range",
"rhs",
"{",
"... | // AppendString is like Append, but accepts strings. | [
"AppendString",
"is",
"like",
"Append",
"but",
"accepts",
"strings",
"."
] | efcd4e0f97874370259c7d93e12aad57911dea81 | https://github.com/fvbommel/util/blob/efcd4e0f97874370259c7d93e12aad57911dea81/rope/rope.go#L125-L133 |
144,229 | fvbommel/util | rope/rope.go | Repeat | func (r Rope) Repeat(count int64) Rope {
// Special cases:
switch count {
case 0:
return emptyRope
case 1:
return r
}
// General case:
orig := r
r = r.Repeat(count / 2)
r = r.Append(r)
if count%2 == 1 {
return r.Append(orig)
}
return balanced(r)
} | go | func (r Rope) Repeat(count int64) Rope {
// Special cases:
switch count {
case 0:
return emptyRope
case 1:
return r
}
// General case:
orig := r
r = r.Repeat(count / 2)
r = r.Append(r)
if count%2 == 1 {
return r.Append(orig)
}
return balanced(r)
} | [
"func",
"(",
"r",
"Rope",
")",
"Repeat",
"(",
"count",
"int64",
")",
"Rope",
"{",
"// Special cases:",
"switch",
"count",
"{",
"case",
"0",
":",
"return",
"emptyRope",
"\n",
"case",
"1",
":",
"return",
"r",
"\n",
"}",
"\n\n",
"// General case:",
"orig",
... | // Repeat returns the receiver, repeated a number of times. | [
"Repeat",
"returns",
"the",
"receiver",
"repeated",
"a",
"number",
"of",
"times",
"."
] | efcd4e0f97874370259c7d93e12aad57911dea81 | https://github.com/fvbommel/util/blob/efcd4e0f97874370259c7d93e12aad57911dea81/rope/rope.go#L136-L153 |
144,230 | fvbommel/util | regexp.go | removeDups | func removeDups(vs []string) []string {
insertPos := 1
for i := 1; i < len(vs); i++ {
if vs[i-1] != vs[i] {
vs[insertPos] = vs[i]
insertPos++
}
}
return vs[:insertPos]
} | go | func removeDups(vs []string) []string {
insertPos := 1
for i := 1; i < len(vs); i++ {
if vs[i-1] != vs[i] {
vs[insertPos] = vs[i]
insertPos++
}
}
return vs[:insertPos]
} | [
"func",
"removeDups",
"(",
"vs",
"[",
"]",
"string",
")",
"[",
"]",
"string",
"{",
"insertPos",
":=",
"1",
"\n",
"for",
"i",
":=",
"1",
";",
"i",
"<",
"len",
"(",
"vs",
")",
";",
"i",
"++",
"{",
"if",
"vs",
"[",
"i",
"-",
"1",
"]",
"!=",
... | // removeDups removes duplicate strings from vs and returns it.
// It assumes that vs has been sorted such that duplicates are next to each
// other. | [
"removeDups",
"removes",
"duplicate",
"strings",
"from",
"vs",
"and",
"returns",
"it",
".",
"It",
"assumes",
"that",
"vs",
"has",
"been",
"sorted",
"such",
"that",
"duplicates",
"are",
"next",
"to",
"each",
"other",
"."
] | efcd4e0f97874370259c7d93e12aad57911dea81 | https://github.com/fvbommel/util/blob/efcd4e0f97874370259c7d93e12aad57911dea81/regexp.go#L280-L289 |
144,231 | fvbommel/util | regexp.go | sharedPrefix | func sharedPrefix(ignore int, vs []string) (result string) {
//debugf("sharedPrefix(%d, %#q)", ignore, vs)
// defer func() {
//debugf("==> %#q", result)
// }()
switch len(vs) {
case 0:
return ""
case 1:
return vs[0]
}
for i := 0; i < len(vs[0])-ignore; i++ {
for n := 1; n < len(vs); n++ {
if i >= len(... | go | func sharedPrefix(ignore int, vs []string) (result string) {
//debugf("sharedPrefix(%d, %#q)", ignore, vs)
// defer func() {
//debugf("==> %#q", result)
// }()
switch len(vs) {
case 0:
return ""
case 1:
return vs[0]
}
for i := 0; i < len(vs[0])-ignore; i++ {
for n := 1; n < len(vs); n++ {
if i >= len(... | [
"func",
"sharedPrefix",
"(",
"ignore",
"int",
",",
"vs",
"[",
"]",
"string",
")",
"(",
"result",
"string",
")",
"{",
"//debugf(\"sharedPrefix(%d, %#q)\", ignore, vs)",
"// defer func() {",
"//debugf(\"==> %#q\", result)",
"// }()",
"switch",
"len",
"(",
"vs",
")",
"... | // sharedPrefix returns the longest prefix which all the parameters share but
// ignores a number of characters at the end of each string. | [
"sharedPrefix",
"returns",
"the",
"longest",
"prefix",
"which",
"all",
"the",
"parameters",
"share",
"but",
"ignores",
"a",
"number",
"of",
"characters",
"at",
"the",
"end",
"of",
"each",
"string",
"."
] | efcd4e0f97874370259c7d93e12aad57911dea81 | https://github.com/fvbommel/util/blob/efcd4e0f97874370259c7d93e12aad57911dea81/regexp.go#L462-L481 |
144,232 | fvbommel/util | regexp.go | sharedSuffix | func sharedSuffix(ignore int, vs []string) (result string) {
//debugf("sharedSuffix(%d, %#q)", ignore, vs)
// defer func() {
//debugf("==> %#q", result)
// }()
switch len(vs) {
case 0:
return ""
case 1:
return vs[0]
}
first := vs[0]
for i := 0; i < len(first)-ignore; i++ {
for n := 1; n < len(vs); n++ {... | go | func sharedSuffix(ignore int, vs []string) (result string) {
//debugf("sharedSuffix(%d, %#q)", ignore, vs)
// defer func() {
//debugf("==> %#q", result)
// }()
switch len(vs) {
case 0:
return ""
case 1:
return vs[0]
}
first := vs[0]
for i := 0; i < len(first)-ignore; i++ {
for n := 1; n < len(vs); n++ {... | [
"func",
"sharedSuffix",
"(",
"ignore",
"int",
",",
"vs",
"[",
"]",
"string",
")",
"(",
"result",
"string",
")",
"{",
"//debugf(\"sharedSuffix(%d, %#q)\", ignore, vs)",
"// defer func() {",
"//debugf(\"==> %#q\", result)",
"// }()",
"switch",
"len",
"(",
"vs",
")",
"... | // sharedSuffix returns the longest suffix which all the parameters share but
// ignores a number of characters at the start of each string. | [
"sharedSuffix",
"returns",
"the",
"longest",
"suffix",
"which",
"all",
"the",
"parameters",
"share",
"but",
"ignores",
"a",
"number",
"of",
"characters",
"at",
"the",
"start",
"of",
"each",
"string",
"."
] | efcd4e0f97874370259c7d93e12aad57911dea81 | https://github.com/fvbommel/util/blob/efcd4e0f97874370259c7d93e12aad57911dea81/regexp.go#L485-L509 |
144,233 | fvbommel/util | rope/reader.go | NewReader | func NewReader(rope Rope) *Reader {
// Put the leftmost path on the stack.
var reader Reader
if rope.node != nil {
reader.stack = make([]*concat, 0, rope.node.depth())
reader.pushSubtree(rope.node)
}
return &reader
} | go | func NewReader(rope Rope) *Reader {
// Put the leftmost path on the stack.
var reader Reader
if rope.node != nil {
reader.stack = make([]*concat, 0, rope.node.depth())
reader.pushSubtree(rope.node)
}
return &reader
} | [
"func",
"NewReader",
"(",
"rope",
"Rope",
")",
"*",
"Reader",
"{",
"// Put the leftmost path on the stack.",
"var",
"reader",
"Reader",
"\n",
"if",
"rope",
".",
"node",
"!=",
"nil",
"{",
"reader",
".",
"stack",
"=",
"make",
"(",
"[",
"]",
"*",
"concat",
... | // NewReader returns a Reader that reads from the specified Rope. | [
"NewReader",
"returns",
"a",
"Reader",
"that",
"reads",
"from",
"the",
"specified",
"Rope",
"."
] | efcd4e0f97874370259c7d93e12aad57911dea81 | https://github.com/fvbommel/util/blob/efcd4e0f97874370259c7d93e12aad57911dea81/rope/reader.go#L15-L23 |
144,234 | exponent-io/jsonpath | path.go | inferContext | func (p *JsonPath) inferContext() jsonContext {
if len(*p) == 0 {
return none
}
t := (*p)[len(*p)-1]
switch t.(type) {
case string:
return objKey
case int:
return arrValue
default:
panic(fmt.Sprintf("Invalid stack type %T", t))
}
} | go | func (p *JsonPath) inferContext() jsonContext {
if len(*p) == 0 {
return none
}
t := (*p)[len(*p)-1]
switch t.(type) {
case string:
return objKey
case int:
return arrValue
default:
panic(fmt.Sprintf("Invalid stack type %T", t))
}
} | [
"func",
"(",
"p",
"*",
"JsonPath",
")",
"inferContext",
"(",
")",
"jsonContext",
"{",
"if",
"len",
"(",
"*",
"p",
")",
"==",
"0",
"{",
"return",
"none",
"\n",
"}",
"\n",
"t",
":=",
"(",
"*",
"p",
")",
"[",
"len",
"(",
"*",
"p",
")",
"-",
"1... | // infer the context from the item at the top of the stack | [
"infer",
"the",
"context",
"from",
"the",
"item",
"at",
"the",
"top",
"of",
"the",
"stack"
] | d6023ce2651d8eafb5c75bb0c7167536102ec9f5 | https://github.com/exponent-io/jsonpath/blob/d6023ce2651d8eafb5c75bb0c7167536102ec9f5/path.go#L32-L45 |
144,235 | exponent-io/jsonpath | path.go | Equal | func (p *JsonPath) Equal(o JsonPath) bool {
if len(*p) != len(o) {
return false
}
for i, v := range *p {
if v != o[i] {
return false
}
}
return true
} | go | func (p *JsonPath) Equal(o JsonPath) bool {
if len(*p) != len(o) {
return false
}
for i, v := range *p {
if v != o[i] {
return false
}
}
return true
} | [
"func",
"(",
"p",
"*",
"JsonPath",
")",
"Equal",
"(",
"o",
"JsonPath",
")",
"bool",
"{",
"if",
"len",
"(",
"*",
"p",
")",
"!=",
"len",
"(",
"o",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"i",
",",
"v",
":=",
"range",
"*",
"p",
"{... | // Equal tests for equality between two JsonPath types. | [
"Equal",
"tests",
"for",
"equality",
"between",
"two",
"JsonPath",
"types",
"."
] | d6023ce2651d8eafb5c75bb0c7167536102ec9f5 | https://github.com/exponent-io/jsonpath/blob/d6023ce2651d8eafb5c75bb0c7167536102ec9f5/path.go#L48-L58 |
144,236 | exponent-io/jsonpath | pathaction.go | match | func (n *pathNode) match(path JsonPath) *pathNode {
var node *pathNode = n
for _, ps := range path {
found := false
for i, n := range node.childNodes {
if n.matchOn == ps {
node = &node.childNodes[i]
found = true
break
} else if _, ok := ps.(int); ok && n.matchOn == AnyIndex {
node = &node.c... | go | func (n *pathNode) match(path JsonPath) *pathNode {
var node *pathNode = n
for _, ps := range path {
found := false
for i, n := range node.childNodes {
if n.matchOn == ps {
node = &node.childNodes[i]
found = true
break
} else if _, ok := ps.(int); ok && n.matchOn == AnyIndex {
node = &node.c... | [
"func",
"(",
"n",
"*",
"pathNode",
")",
"match",
"(",
"path",
"JsonPath",
")",
"*",
"pathNode",
"{",
"var",
"node",
"*",
"pathNode",
"=",
"n",
"\n",
"for",
"_",
",",
"ps",
":=",
"range",
"path",
"{",
"found",
":=",
"false",
"\n",
"for",
"i",
",",... | // match climbs the trie to find a node that matches the given JSON path. | [
"match",
"climbs",
"the",
"trie",
"to",
"find",
"a",
"node",
"that",
"matches",
"the",
"given",
"JSON",
"path",
"."
] | d6023ce2651d8eafb5c75bb0c7167536102ec9f5 | https://github.com/exponent-io/jsonpath/blob/d6023ce2651d8eafb5c75bb0c7167536102ec9f5/pathaction.go#L11-L31 |
144,237 | exponent-io/jsonpath | pathaction.go | Add | func (je *PathActions) Add(action DecodeAction, path ...interface{}) {
var node *pathNode = &je.node
for _, ps := range path {
found := false
for i, n := range node.childNodes {
if n.matchOn == ps {
node = &node.childNodes[i]
found = true
break
}
}
if !found {
node.childNodes = append(no... | go | func (je *PathActions) Add(action DecodeAction, path ...interface{}) {
var node *pathNode = &je.node
for _, ps := range path {
found := false
for i, n := range node.childNodes {
if n.matchOn == ps {
node = &node.childNodes[i]
found = true
break
}
}
if !found {
node.childNodes = append(no... | [
"func",
"(",
"je",
"*",
"PathActions",
")",
"Add",
"(",
"action",
"DecodeAction",
",",
"path",
"...",
"interface",
"{",
"}",
")",
"{",
"var",
"node",
"*",
"pathNode",
"=",
"&",
"je",
".",
"node",
"\n",
"for",
"_",
",",
"ps",
":=",
"range",
"path",
... | // Add specifies an action to call on the Decoder when the specified path is encountered. | [
"Add",
"specifies",
"an",
"action",
"to",
"call",
"on",
"the",
"Decoder",
"when",
"the",
"specified",
"path",
"is",
"encountered",
"."
] | d6023ce2651d8eafb5c75bb0c7167536102ec9f5 | https://github.com/exponent-io/jsonpath/blob/d6023ce2651d8eafb5c75bb0c7167536102ec9f5/pathaction.go#L43-L61 |
144,238 | exponent-io/jsonpath | decoder.go | NewDecoder | func NewDecoder(r io.Reader) *Decoder {
return &Decoder{Decoder: *json.NewDecoder(r)}
} | go | func NewDecoder(r io.Reader) *Decoder {
return &Decoder{Decoder: *json.NewDecoder(r)}
} | [
"func",
"NewDecoder",
"(",
"r",
"io",
".",
"Reader",
")",
"*",
"Decoder",
"{",
"return",
"&",
"Decoder",
"{",
"Decoder",
":",
"*",
"json",
".",
"NewDecoder",
"(",
"r",
")",
"}",
"\n",
"}"
] | // NewDecoder creates a new instance of the extended JSON Decoder. | [
"NewDecoder",
"creates",
"a",
"new",
"instance",
"of",
"the",
"extended",
"JSON",
"Decoder",
"."
] | d6023ce2651d8eafb5c75bb0c7167536102ec9f5 | https://github.com/exponent-io/jsonpath/blob/d6023ce2651d8eafb5c75bb0c7167536102ec9f5/decoder.go#L20-L22 |
144,239 | cheekybits/is | decorate.go | callerinfo | func callerinfo() (string, int, bool) {
file := ""
line := 0
ok := false
for i := 0; ; i++ {
_, file, line, ok = runtime.Caller(i)
if !ok {
return "", 0, false
}
parts := strings.Split(file, "/")
dir := parts[len(parts)-2]
file = parts[len(parts)-1]
if dir != "is" || file == "is_test.go" {
bre... | go | func callerinfo() (string, int, bool) {
file := ""
line := 0
ok := false
for i := 0; ; i++ {
_, file, line, ok = runtime.Caller(i)
if !ok {
return "", 0, false
}
parts := strings.Split(file, "/")
dir := parts[len(parts)-2]
file = parts[len(parts)-1]
if dir != "is" || file == "is_test.go" {
bre... | [
"func",
"callerinfo",
"(",
")",
"(",
"string",
",",
"int",
",",
"bool",
")",
"{",
"file",
":=",
"\"",
"\"",
"\n",
"line",
":=",
"0",
"\n",
"ok",
":=",
"false",
"\n\n",
"for",
"i",
":=",
"0",
";",
";",
"i",
"++",
"{",
"_",
",",
"file",
",",
... | // callerinfo returns a string containing the file and line number of the test call
// that failed. | [
"callerinfo",
"returns",
"a",
"string",
"containing",
"the",
"file",
"and",
"line",
"number",
"of",
"the",
"test",
"call",
"that",
"failed",
"."
] | 68e9c0620927fb5427fda3708222d0edee89eae9 | https://github.com/cheekybits/is/blob/68e9c0620927fb5427fda3708222d0edee89eae9/decorate.go#L12-L32 |
144,240 | cheekybits/is | decorate.go | decorate | func decorate(s string) string {
file, line, ok := callerinfo() // decorate + log + public function.
if ok {
// Truncate file name at last file name separator.
if index := strings.LastIndex(file, "/"); index >= 0 {
file = file[index+1:]
} else if index = strings.LastIndex(file, "\\"); index >= 0 {
file = ... | go | func decorate(s string) string {
file, line, ok := callerinfo() // decorate + log + public function.
if ok {
// Truncate file name at last file name separator.
if index := strings.LastIndex(file, "/"); index >= 0 {
file = file[index+1:]
} else if index = strings.LastIndex(file, "\\"); index >= 0 {
file = ... | [
"func",
"decorate",
"(",
"s",
"string",
")",
"string",
"{",
"file",
",",
"line",
",",
"ok",
":=",
"callerinfo",
"(",
")",
"// decorate + log + public function.",
"\n",
"if",
"ok",
"{",
"// Truncate file name at last file name separator.",
"if",
"index",
":=",
"str... | // decorate prefixes the string with the file and line of the call site
// and inserts the final newline if needed and indentation tabs for formatting.
// this function was copied from the testing framework. | [
"decorate",
"prefixes",
"the",
"string",
"with",
"the",
"file",
"and",
"line",
"of",
"the",
"call",
"site",
"and",
"inserts",
"the",
"final",
"newline",
"if",
"needed",
"and",
"indentation",
"tabs",
"for",
"formatting",
".",
"this",
"function",
"was",
"copie... | 68e9c0620927fb5427fda3708222d0edee89eae9 | https://github.com/cheekybits/is/blob/68e9c0620927fb5427fda3708222d0edee89eae9/decorate.go#L37-L67 |
144,241 | cheekybits/is | is.go | OK | func (i *i) OK(o ...interface{}) {
for _, obj := range o {
if isNil(obj) {
i.Log("unexpected nil")
}
switch co := obj.(type) {
case func():
// shouldn't panic
var r interface{}
func() {
defer func() {
r = recover()
}()
co()
}()
if r != nil {
i.Logf("unexpected panic: %v... | go | func (i *i) OK(o ...interface{}) {
for _, obj := range o {
if isNil(obj) {
i.Log("unexpected nil")
}
switch co := obj.(type) {
case func():
// shouldn't panic
var r interface{}
func() {
defer func() {
r = recover()
}()
co()
}()
if r != nil {
i.Logf("unexpected panic: %v... | [
"func",
"(",
"i",
"*",
"i",
")",
"OK",
"(",
"o",
"...",
"interface",
"{",
"}",
")",
"{",
"for",
"_",
",",
"obj",
":=",
"range",
"o",
"{",
"if",
"isNil",
"(",
"obj",
")",
"{",
"i",
".",
"Log",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"swit... | // OK asserts that the specified objects are all OK. | [
"OK",
"asserts",
"that",
"the",
"specified",
"objects",
"are",
"all",
"OK",
"."
] | 68e9c0620927fb5427fda3708222d0edee89eae9 | https://github.com/cheekybits/is/blob/68e9c0620927fb5427fda3708222d0edee89eae9/is.go#L100-L146 |
144,242 | cheekybits/is | is.go | Equal | func (i *i) Equal(a, b interface{}) {
if !areEqual(a, b) {
i.Logf("%v != %v", a, b)
}
} | go | func (i *i) Equal(a, b interface{}) {
if !areEqual(a, b) {
i.Logf("%v != %v", a, b)
}
} | [
"func",
"(",
"i",
"*",
"i",
")",
"Equal",
"(",
"a",
",",
"b",
"interface",
"{",
"}",
")",
"{",
"if",
"!",
"areEqual",
"(",
"a",
",",
"b",
")",
"{",
"i",
".",
"Logf",
"(",
"\"",
"\"",
",",
"a",
",",
"b",
")",
"\n",
"}",
"\n",
"}"
] | // Equal asserts that the two values are
// considered equal. Non strict. | [
"Equal",
"asserts",
"that",
"the",
"two",
"values",
"are",
"considered",
"equal",
".",
"Non",
"strict",
"."
] | 68e9c0620927fb5427fda3708222d0edee89eae9 | https://github.com/cheekybits/is/blob/68e9c0620927fb5427fda3708222d0edee89eae9/is.go#L227-L231 |
144,243 | cheekybits/is | is.go | NotEqual | func (i *i) NotEqual(a, b interface{}) {
if areEqual(a, b) {
i.Logf("%v == %v", a, b)
}
} | go | func (i *i) NotEqual(a, b interface{}) {
if areEqual(a, b) {
i.Logf("%v == %v", a, b)
}
} | [
"func",
"(",
"i",
"*",
"i",
")",
"NotEqual",
"(",
"a",
",",
"b",
"interface",
"{",
"}",
")",
"{",
"if",
"areEqual",
"(",
"a",
",",
"b",
")",
"{",
"i",
".",
"Logf",
"(",
"\"",
"\"",
",",
"a",
",",
"b",
")",
"\n",
"}",
"\n",
"}"
] | // NotEqual asserts that the two values are not
// considered equal. Non strict. | [
"NotEqual",
"asserts",
"that",
"the",
"two",
"values",
"are",
"not",
"considered",
"equal",
".",
"Non",
"strict",
"."
] | 68e9c0620927fb5427fda3708222d0edee89eae9 | https://github.com/cheekybits/is/blob/68e9c0620927fb5427fda3708222d0edee89eae9/is.go#L235-L239 |
144,244 | cheekybits/is | is.go | Panic | func (i *i) Panic(fn func()) {
var r interface{}
func() {
defer func() {
r = recover()
}()
fn()
}()
if r == nil {
i.Log("expected panic")
}
} | go | func (i *i) Panic(fn func()) {
var r interface{}
func() {
defer func() {
r = recover()
}()
fn()
}()
if r == nil {
i.Log("expected panic")
}
} | [
"func",
"(",
"i",
"*",
"i",
")",
"Panic",
"(",
"fn",
"func",
"(",
")",
")",
"{",
"var",
"r",
"interface",
"{",
"}",
"\n",
"func",
"(",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"r",
"=",
"recover",
"(",
")",
"\n",
"}",
"(",
")",
"\n",
"fn... | // Panic asserts that the specified function
// panics. | [
"Panic",
"asserts",
"that",
"the",
"specified",
"function",
"panics",
"."
] | 68e9c0620927fb5427fda3708222d0edee89eae9 | https://github.com/cheekybits/is/blob/68e9c0620927fb5427fda3708222d0edee89eae9/is.go#L251-L262 |
144,245 | cheekybits/is | is.go | PanicWith | func (i *i) PanicWith(m string, fn func()) {
var r interface{}
func() {
defer func() {
r = recover()
}()
fn()
}()
if r != m {
i.Logf("expected panic: \"%s\"", m)
}
} | go | func (i *i) PanicWith(m string, fn func()) {
var r interface{}
func() {
defer func() {
r = recover()
}()
fn()
}()
if r != m {
i.Logf("expected panic: \"%s\"", m)
}
} | [
"func",
"(",
"i",
"*",
"i",
")",
"PanicWith",
"(",
"m",
"string",
",",
"fn",
"func",
"(",
")",
")",
"{",
"var",
"r",
"interface",
"{",
"}",
"\n",
"func",
"(",
")",
"{",
"defer",
"func",
"(",
")",
"{",
"r",
"=",
"recover",
"(",
")",
"\n",
"}... | // PanicWith asserts that the specified function
// panics with the specific message. | [
"PanicWith",
"asserts",
"that",
"the",
"specified",
"function",
"panics",
"with",
"the",
"specific",
"message",
"."
] | 68e9c0620927fb5427fda3708222d0edee89eae9 | https://github.com/cheekybits/is/blob/68e9c0620927fb5427fda3708222d0edee89eae9/is.go#L266-L277 |
144,246 | Songmu/retry | retry.go | Retry | func Retry(n uint, interval time.Duration, fn func() error) (err error) {
return WithContext(context.Background(), n, interval, fn)
} | go | func Retry(n uint, interval time.Duration, fn func() error) (err error) {
return WithContext(context.Background(), n, interval, fn)
} | [
"func",
"Retry",
"(",
"n",
"uint",
",",
"interval",
"time",
".",
"Duration",
",",
"fn",
"func",
"(",
")",
"error",
")",
"(",
"err",
"error",
")",
"{",
"return",
"WithContext",
"(",
"context",
".",
"Background",
"(",
")",
",",
"n",
",",
"interval",
... | // Retry calls the `fn` and if it returns the error, retry to call `fn` after `interval` duration.
// The `fn` is called up to `n` times. | [
"Retry",
"calls",
"the",
"fn",
"and",
"if",
"it",
"returns",
"the",
"error",
"retry",
"to",
"call",
"fn",
"after",
"interval",
"duration",
".",
"The",
"fn",
"is",
"called",
"up",
"to",
"n",
"times",
"."
] | 902aa877ec14b4d10b9db5c8caf81a111cf0680e | https://github.com/Songmu/retry/blob/902aa877ec14b4d10b9db5c8caf81a111cf0680e/retry.go#L10-L12 |
144,247 | Songmu/retry | retry.go | WithContext | func WithContext(ctx context.Context, n uint, interval time.Duration, fn func() error) (err error) {
for n > 0 {
n--
err = fn()
if err == nil || n <= 0 {
break
}
select {
case <-ctx.Done():
return ctx.Err()
case <-time.After(interval):
}
}
return
} | go | func WithContext(ctx context.Context, n uint, interval time.Duration, fn func() error) (err error) {
for n > 0 {
n--
err = fn()
if err == nil || n <= 0 {
break
}
select {
case <-ctx.Done():
return ctx.Err()
case <-time.After(interval):
}
}
return
} | [
"func",
"WithContext",
"(",
"ctx",
"context",
".",
"Context",
",",
"n",
"uint",
",",
"interval",
"time",
".",
"Duration",
",",
"fn",
"func",
"(",
")",
"error",
")",
"(",
"err",
"error",
")",
"{",
"for",
"n",
">",
"0",
"{",
"n",
"--",
"\n",
"err",... | // WithContext stops retrying when the context is done. | [
"WithContext",
"stops",
"retrying",
"when",
"the",
"context",
"is",
"done",
"."
] | 902aa877ec14b4d10b9db5c8caf81a111cf0680e | https://github.com/Songmu/retry/blob/902aa877ec14b4d10b9db5c8caf81a111cf0680e/retry.go#L15-L29 |
144,248 | jacobsa/crypto | siv/dbl.go | dbl | func dbl(b []byte) []byte {
if len(b) != aes.BlockSize {
panic("dbl requires a 16-byte buffer.")
}
shiftedOne := common.Msb(b) == 1
b = common.ShiftLeft(b)
if shiftedOne {
tmp := make([]byte, aes.BlockSize)
common.Xor(tmp, b, dblRb)
b = tmp
}
return b
} | go | func dbl(b []byte) []byte {
if len(b) != aes.BlockSize {
panic("dbl requires a 16-byte buffer.")
}
shiftedOne := common.Msb(b) == 1
b = common.ShiftLeft(b)
if shiftedOne {
tmp := make([]byte, aes.BlockSize)
common.Xor(tmp, b, dblRb)
b = tmp
}
return b
} | [
"func",
"dbl",
"(",
"b",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"b",
")",
"!=",
"aes",
".",
"BlockSize",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"shiftedOne",
":=",
"common",
".",
"Msb",
"(",
"b",
")",
... | // Given a 128-bit binary string, shift the string left by one bit and XOR the
// result with 0x00...87 if the bit shifted off was one. This is the dbl
// function of RFC 5297. | [
"Given",
"a",
"128",
"-",
"bit",
"binary",
"string",
"shift",
"the",
"string",
"left",
"by",
"one",
"bit",
"and",
"XOR",
"the",
"result",
"with",
"0x00",
"...",
"87",
"if",
"the",
"bit",
"shifted",
"off",
"was",
"one",
".",
"This",
"is",
"the",
"dbl"... | 9f44e2d11115452dad8f404f029574422855f46a | https://github.com/jacobsa/crypto/blob/9f44e2d11115452dad8f404f029574422855f46a/siv/dbl.go#L34-L48 |
144,249 | jacobsa/crypto | common/shiftleft.go | ShiftLeft | func ShiftLeft(b []byte) []byte {
l := len(b)
if l == 0 {
panic("shiftLeft requires a non-empty buffer.")
}
output := make([]byte, l)
overflow := byte(0)
for i := int(l - 1); i >= 0; i-- {
output[i] = b[i] << 1
output[i] |= overflow
overflow = (b[i] & 0x80) >> 7
}
return output
} | go | func ShiftLeft(b []byte) []byte {
l := len(b)
if l == 0 {
panic("shiftLeft requires a non-empty buffer.")
}
output := make([]byte, l)
overflow := byte(0)
for i := int(l - 1); i >= 0; i-- {
output[i] = b[i] << 1
output[i] |= overflow
overflow = (b[i] & 0x80) >> 7
}
return output
} | [
"func",
"ShiftLeft",
"(",
"b",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"l",
":=",
"len",
"(",
"b",
")",
"\n",
"if",
"l",
"==",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"output",
":=",
"make",
"(",
"[",
"]",
"byte",
... | // ShiftLeft shifts the binary string left by one bit, causing the
// most-signficant bit to disappear and a zero to be introduced at the right.
// This corresponds to the `x << 1` notation of RFC 4493. | [
"ShiftLeft",
"shifts",
"the",
"binary",
"string",
"left",
"by",
"one",
"bit",
"causing",
"the",
"most",
"-",
"signficant",
"bit",
"to",
"disappear",
"and",
"a",
"zero",
"to",
"be",
"introduced",
"at",
"the",
"right",
".",
"This",
"corresponds",
"to",
"the"... | 9f44e2d11115452dad8f404f029574422855f46a | https://github.com/jacobsa/crypto/blob/9f44e2d11115452dad8f404f029574422855f46a/common/shiftleft.go#L21-L37 |
144,250 | jacobsa/crypto | cmac/hash_32bit.go | xorBlock | func xorBlock(
dstPtr unsafe.Pointer,
aPtr unsafe.Pointer,
bPtr unsafe.Pointer) {
// Check assumptions. (These are compile-time constants, so this should
// compile out.)
const wordSize = unsafe.Sizeof(uintptr(0))
if blockSize != 4*wordSize {
log.Panicf("%d %d", blockSize, wordSize)
}
// Convert.
a := (*[4... | go | func xorBlock(
dstPtr unsafe.Pointer,
aPtr unsafe.Pointer,
bPtr unsafe.Pointer) {
// Check assumptions. (These are compile-time constants, so this should
// compile out.)
const wordSize = unsafe.Sizeof(uintptr(0))
if blockSize != 4*wordSize {
log.Panicf("%d %d", blockSize, wordSize)
}
// Convert.
a := (*[4... | [
"func",
"xorBlock",
"(",
"dstPtr",
"unsafe",
".",
"Pointer",
",",
"aPtr",
"unsafe",
".",
"Pointer",
",",
"bPtr",
"unsafe",
".",
"Pointer",
")",
"{",
"// Check assumptions. (These are compile-time constants, so this should",
"// compile out.)",
"const",
"wordSize",
"=",
... | // XOR the blockSize bytes starting at a and b, writing the result over dst. | [
"XOR",
"the",
"blockSize",
"bytes",
"starting",
"at",
"a",
"and",
"b",
"writing",
"the",
"result",
"over",
"dst",
"."
] | 9f44e2d11115452dad8f404f029574422855f46a | https://github.com/jacobsa/crypto/blob/9f44e2d11115452dad8f404f029574422855f46a/cmac/hash_32bit.go#L26-L47 |
144,251 | jacobsa/crypto | cmac/subkey.go | generateSubkeys | func generateSubkeys(ciph cipher.Block) (k1 []byte, k2 []byte) {
if ciph.BlockSize() != blockSize {
panic("generateSubkeys requires a cipher with a block size of 16 bytes.")
}
// Step 1
l := make([]byte, blockSize)
ciph.Encrypt(l, subkeyZero)
// Step 2: Derive the first subkey.
if common.Msb(l) == 0 {
// T... | go | func generateSubkeys(ciph cipher.Block) (k1 []byte, k2 []byte) {
if ciph.BlockSize() != blockSize {
panic("generateSubkeys requires a cipher with a block size of 16 bytes.")
}
// Step 1
l := make([]byte, blockSize)
ciph.Encrypt(l, subkeyZero)
// Step 2: Derive the first subkey.
if common.Msb(l) == 0 {
// T... | [
"func",
"generateSubkeys",
"(",
"ciph",
"cipher",
".",
"Block",
")",
"(",
"k1",
"[",
"]",
"byte",
",",
"k2",
"[",
"]",
"byte",
")",
"{",
"if",
"ciph",
".",
"BlockSize",
"(",
")",
"!=",
"blockSize",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
... | // Given the supplied cipher, whose block size must be 16 bytes, return two
// subkeys that can be used in MAC generation. See section 5.3 of NIST SP
// 800-38B. Note that the other NIST-approved block size of 8 bytes is not
// supported by this function. | [
"Given",
"the",
"supplied",
"cipher",
"whose",
"block",
"size",
"must",
"be",
"16",
"bytes",
"return",
"two",
"subkeys",
"that",
"can",
"be",
"used",
"in",
"MAC",
"generation",
".",
"See",
"section",
"5",
".",
"3",
"of",
"NIST",
"SP",
"800",
"-",
"38B"... | 9f44e2d11115452dad8f404f029574422855f46a | https://github.com/jacobsa/crypto/blob/9f44e2d11115452dad8f404f029574422855f46a/cmac/subkey.go#L37-L65 |
144,252 | jacobsa/crypto | common/pad_block.go | PadBlock | func PadBlock(block []byte) []byte {
blockLen := len(block)
if blockLen >= aes.BlockSize {
panic("PadBlock input must be less than 16 bytes.")
}
result := make([]byte, aes.BlockSize)
copy(result, block)
result[blockLen] = 0x80
return result
} | go | func PadBlock(block []byte) []byte {
blockLen := len(block)
if blockLen >= aes.BlockSize {
panic("PadBlock input must be less than 16 bytes.")
}
result := make([]byte, aes.BlockSize)
copy(result, block)
result[blockLen] = 0x80
return result
} | [
"func",
"PadBlock",
"(",
"block",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"blockLen",
":=",
"len",
"(",
"block",
")",
"\n",
"if",
"blockLen",
">=",
"aes",
".",
"BlockSize",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"result",
":... | // PadBlock pads a string of bytes less than 16 bytes long to a full block size
// by appending a one bit followed by zero bits. This is the padding function
// used in RFCs 4493 and 5297. | [
"PadBlock",
"pads",
"a",
"string",
"of",
"bytes",
"less",
"than",
"16",
"bytes",
"long",
"to",
"a",
"full",
"block",
"size",
"by",
"appending",
"a",
"one",
"bit",
"followed",
"by",
"zero",
"bits",
".",
"This",
"is",
"the",
"padding",
"function",
"used",
... | 9f44e2d11115452dad8f404f029574422855f46a | https://github.com/jacobsa/crypto/blob/9f44e2d11115452dad8f404f029574422855f46a/common/pad_block.go#L25-L36 |
144,253 | jacobsa/crypto | common/xor.go | Xor | func Xor(dst []byte, a []byte, b []byte) {
// TODO(jacobsa): Consider making this a helper function with known sizes
// where it is most hot, then even trying to inline it entirely.
if len(dst) != len(a) || len(a) != len(b) {
log.Panicf("Bad buffer lengths: %d, %d, %d", len(dst), len(a), len(b))
}
for i, _ := ... | go | func Xor(dst []byte, a []byte, b []byte) {
// TODO(jacobsa): Consider making this a helper function with known sizes
// where it is most hot, then even trying to inline it entirely.
if len(dst) != len(a) || len(a) != len(b) {
log.Panicf("Bad buffer lengths: %d, %d, %d", len(dst), len(a), len(b))
}
for i, _ := ... | [
"func",
"Xor",
"(",
"dst",
"[",
"]",
"byte",
",",
"a",
"[",
"]",
"byte",
",",
"b",
"[",
"]",
"byte",
")",
"{",
"// TODO(jacobsa): Consider making this a helper function with known sizes",
"// where it is most hot, then even trying to inline it entirely.",
"if",
"len",
"... | // Xor computes `a XOR b`, as defined by RFC 4493. dst, a, and b must all have
// the same length. | [
"Xor",
"computes",
"a",
"XOR",
"b",
"as",
"defined",
"by",
"RFC",
"4493",
".",
"dst",
"a",
"and",
"b",
"must",
"all",
"have",
"the",
"same",
"length",
"."
] | 9f44e2d11115452dad8f404f029574422855f46a | https://github.com/jacobsa/crypto/blob/9f44e2d11115452dad8f404f029574422855f46a/common/xor.go#L22-L33 |
144,254 | jacobsa/crypto | cmac/hash.go | New | func New(key []byte) (hash.Hash, error) {
switch len(key) {
case 16, 24, 32:
default:
return nil, fmt.Errorf("AES-CMAC requires a 16-, 24-, or 32-byte key.")
}
// Create a cipher.
ciph, err := aes.NewCipher(key)
if err != nil {
return nil, fmt.Errorf("aes.NewCipher: %v", err)
}
// Set up the hash object.... | go | func New(key []byte) (hash.Hash, error) {
switch len(key) {
case 16, 24, 32:
default:
return nil, fmt.Errorf("AES-CMAC requires a 16-, 24-, or 32-byte key.")
}
// Create a cipher.
ciph, err := aes.NewCipher(key)
if err != nil {
return nil, fmt.Errorf("aes.NewCipher: %v", err)
}
// Set up the hash object.... | [
"func",
"New",
"(",
"key",
"[",
"]",
"byte",
")",
"(",
"hash",
".",
"Hash",
",",
"error",
")",
"{",
"switch",
"len",
"(",
"key",
")",
"{",
"case",
"16",
",",
"24",
",",
"32",
":",
"default",
":",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(... | // New returns an AES-CMAC hash using the supplied key. The key must be 16, 24,
// or 32 bytes long. | [
"New",
"returns",
"an",
"AES",
"-",
"CMAC",
"hash",
"using",
"the",
"supplied",
"key",
".",
"The",
"key",
"must",
"be",
"16",
"24",
"or",
"32",
"bytes",
"long",
"."
] | 9f44e2d11115452dad8f404f029574422855f46a | https://github.com/jacobsa/crypto/blob/9f44e2d11115452dad8f404f029574422855f46a/cmac/hash.go#L151-L170 |
144,255 | jacobsa/crypto | siv/decrypt.go | Decrypt | func Decrypt(key, ciphertext []byte, associated [][]byte) ([]byte, error) {
keyLen := len(key)
associatedLen := len(associated)
// The first 16 bytes of the ciphertext are the SIV.
if len(ciphertext) < aes.BlockSize {
return nil, fmt.Errorf("Invalid ciphertext; length must be at least 16.")
}
v := ciphertext[... | go | func Decrypt(key, ciphertext []byte, associated [][]byte) ([]byte, error) {
keyLen := len(key)
associatedLen := len(associated)
// The first 16 bytes of the ciphertext are the SIV.
if len(ciphertext) < aes.BlockSize {
return nil, fmt.Errorf("Invalid ciphertext; length must be at least 16.")
}
v := ciphertext[... | [
"func",
"Decrypt",
"(",
"key",
",",
"ciphertext",
"[",
"]",
"byte",
",",
"associated",
"[",
"]",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"keyLen",
":=",
"len",
"(",
"key",
")",
"\n",
"associatedLen",
":=",
"len",
"("... | // Given ciphertext previously generated by Encrypt and the key and associated
// data that were used when generating the ciphertext, return the original
// plaintext given to Encrypt. If the input is well-formed but the key is
// incorrect, return an instance of WrongKeyError. | [
"Given",
"ciphertext",
"previously",
"generated",
"by",
"Encrypt",
"and",
"the",
"key",
"and",
"associated",
"data",
"that",
"were",
"used",
"when",
"generating",
"the",
"ciphertext",
"return",
"the",
"original",
"plaintext",
"given",
"to",
"Encrypt",
".",
"If",... | 9f44e2d11115452dad8f404f029574422855f46a | https://github.com/jacobsa/crypto/blob/9f44e2d11115452dad8f404f029574422855f46a/siv/decrypt.go#L41-L103 |
144,256 | nf/cr2 | reader.go | firstVal | func (d *decoder) firstVal(tag int) uint {
f := d.features[tag]
if len(f) == 0 {
return 0
}
return f[0]
} | go | func (d *decoder) firstVal(tag int) uint {
f := d.features[tag]
if len(f) == 0 {
return 0
}
return f[0]
} | [
"func",
"(",
"d",
"*",
"decoder",
")",
"firstVal",
"(",
"tag",
"int",
")",
"uint",
"{",
"f",
":=",
"d",
".",
"features",
"[",
"tag",
"]",
"\n",
"if",
"len",
"(",
"f",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n",
"return",
"f",
"[",
... | // firstVal returns the first uint of the features entry with the given tag,
// or 0 if the tag does not exist. | [
"firstVal",
"returns",
"the",
"first",
"uint",
"of",
"the",
"features",
"entry",
"with",
"the",
"given",
"tag",
"or",
"0",
"if",
"the",
"tag",
"does",
"not",
"exist",
"."
] | 4699471a17ed597dc2011a21e5b37335710afdea | https://github.com/nf/cr2/blob/4699471a17ed597dc2011a21e5b37335710afdea/reader.go#L65-L71 |
144,257 | nf/cr2 | reader.go | ifdUint | func (d *decoder) ifdUint(p []byte) (u []uint, err error) {
var raw []byte
datatype := d.byteOrder.Uint16(p[2:4])
count := d.byteOrder.Uint32(p[4:8])
if datalen := lengths[datatype] * count; datalen > 4 {
// The IFD contains a pointer to the real value.
raw = make([]byte, datalen)
_, err = d.r.ReadAt(raw, int... | go | func (d *decoder) ifdUint(p []byte) (u []uint, err error) {
var raw []byte
datatype := d.byteOrder.Uint16(p[2:4])
count := d.byteOrder.Uint32(p[4:8])
if datalen := lengths[datatype] * count; datalen > 4 {
// The IFD contains a pointer to the real value.
raw = make([]byte, datalen)
_, err = d.r.ReadAt(raw, int... | [
"func",
"(",
"d",
"*",
"decoder",
")",
"ifdUint",
"(",
"p",
"[",
"]",
"byte",
")",
"(",
"u",
"[",
"]",
"uint",
",",
"err",
"error",
")",
"{",
"var",
"raw",
"[",
"]",
"byte",
"\n",
"datatype",
":=",
"d",
".",
"byteOrder",
".",
"Uint16",
"(",
"... | // ifdUint decodes the IFD entry in p, which must be of the Byte, Short
// or Long type, and returns the decoded uint values. | [
"ifdUint",
"decodes",
"the",
"IFD",
"entry",
"in",
"p",
"which",
"must",
"be",
"of",
"the",
"Byte",
"Short",
"or",
"Long",
"type",
"and",
"returns",
"the",
"decoded",
"uint",
"values",
"."
] | 4699471a17ed597dc2011a21e5b37335710afdea | https://github.com/nf/cr2/blob/4699471a17ed597dc2011a21e5b37335710afdea/reader.go#L75-L108 |
144,258 | nf/cr2 | reader.go | parseIFD | func (d *decoder) parseIFD(p []byte) error {
tag := d.byteOrder.Uint16(p[0:2])
switch tag {
case tBitsPerSample,
tExtraSamples,
tPhotometricInterpretation,
tCompression,
tPredictor,
tStripOffsets,
tStripByteCounts,
tRowsPerStrip,
tTileWidth,
tTileLength,
tTileOffsets,
tTileByteCounts,
tImageL... | go | func (d *decoder) parseIFD(p []byte) error {
tag := d.byteOrder.Uint16(p[0:2])
switch tag {
case tBitsPerSample,
tExtraSamples,
tPhotometricInterpretation,
tCompression,
tPredictor,
tStripOffsets,
tStripByteCounts,
tRowsPerStrip,
tTileWidth,
tTileLength,
tTileOffsets,
tTileByteCounts,
tImageL... | [
"func",
"(",
"d",
"*",
"decoder",
")",
"parseIFD",
"(",
"p",
"[",
"]",
"byte",
")",
"error",
"{",
"tag",
":=",
"d",
".",
"byteOrder",
".",
"Uint16",
"(",
"p",
"[",
"0",
":",
"2",
"]",
")",
"\n",
"switch",
"tag",
"{",
"case",
"tBitsPerSample",
"... | // parseIFD decides whether the the IFD entry in p is "interesting" and
// stows away the data in the decoder. | [
"parseIFD",
"decides",
"whether",
"the",
"the",
"IFD",
"entry",
"in",
"p",
"is",
"interesting",
"and",
"stows",
"away",
"the",
"data",
"in",
"the",
"decoder",
"."
] | 4699471a17ed597dc2011a21e5b37335710afdea | https://github.com/nf/cr2/blob/4699471a17ed597dc2011a21e5b37335710afdea/reader.go#L112-L168 |
144,259 | nf/cr2 | reader.go | readBits | func (d *decoder) readBits(n uint) uint32 {
for d.nbits < n {
d.v <<= 8
d.v |= uint32(d.buf[d.off])
d.off++
d.nbits += 8
}
d.nbits -= n
rv := d.v >> d.nbits
d.v &^= rv << d.nbits
return rv
} | go | func (d *decoder) readBits(n uint) uint32 {
for d.nbits < n {
d.v <<= 8
d.v |= uint32(d.buf[d.off])
d.off++
d.nbits += 8
}
d.nbits -= n
rv := d.v >> d.nbits
d.v &^= rv << d.nbits
return rv
} | [
"func",
"(",
"d",
"*",
"decoder",
")",
"readBits",
"(",
"n",
"uint",
")",
"uint32",
"{",
"for",
"d",
".",
"nbits",
"<",
"n",
"{",
"d",
".",
"v",
"<<=",
"8",
"\n",
"d",
".",
"v",
"|=",
"uint32",
"(",
"d",
".",
"buf",
"[",
"d",
".",
"off",
... | // readBits reads n bits from the internal buffer starting at the current offset. | [
"readBits",
"reads",
"n",
"bits",
"from",
"the",
"internal",
"buffer",
"starting",
"at",
"the",
"current",
"offset",
"."
] | 4699471a17ed597dc2011a21e5b37335710afdea | https://github.com/nf/cr2/blob/4699471a17ed597dc2011a21e5b37335710afdea/reader.go#L171-L182 |
144,260 | nf/cr2 | reader.go | DecodeConfig | func DecodeConfig(r io.Reader) (image.Config, error) {
d, err := newDecoder(r)
if err != nil {
return image.Config{}, err
}
return d.config, nil
} | go | func DecodeConfig(r io.Reader) (image.Config, error) {
d, err := newDecoder(r)
if err != nil {
return image.Config{}, err
}
return d.config, nil
} | [
"func",
"DecodeConfig",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"image",
".",
"Config",
",",
"error",
")",
"{",
"d",
",",
"err",
":=",
"newDecoder",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"image",
".",
"Config",
"{",
"}",
... | // DecodeConfig returns the color model and dimensions of a TIFF image without
// decoding the entire image. | [
"DecodeConfig",
"returns",
"the",
"color",
"model",
"and",
"dimensions",
"of",
"a",
"TIFF",
"image",
"without",
"decoding",
"the",
"entire",
"image",
"."
] | 4699471a17ed597dc2011a21e5b37335710afdea | https://github.com/nf/cr2/blob/4699471a17ed597dc2011a21e5b37335710afdea/reader.go#L299-L305 |
144,261 | nf/cr2 | reader.go | NewReader | func NewReader(r io.Reader) (io.Reader, error) {
d, err := newDecoder(r)
if err != nil {
return nil, err
}
offset := int64(d.features[tStripOffsets][0])
n := int64(d.features[tStripByteCounts][0])
switch d.firstVal(tCompression) {
case cJPEG, cJPEGOld:
default:
return nil, UnsupportedError("compression")
}... | go | func NewReader(r io.Reader) (io.Reader, error) {
d, err := newDecoder(r)
if err != nil {
return nil, err
}
offset := int64(d.features[tStripOffsets][0])
n := int64(d.features[tStripByteCounts][0])
switch d.firstVal(tCompression) {
case cJPEG, cJPEGOld:
default:
return nil, UnsupportedError("compression")
}... | [
"func",
"NewReader",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"io",
".",
"Reader",
",",
"error",
")",
"{",
"d",
",",
"err",
":=",
"newDecoder",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
... | // NewReader returns an io.Reader to the JPEG thumbnail embedded in the CR2
// image in r. This allows access to the raw bytes of the JPEG thumbnail
// without the need to decompress it first. | [
"NewReader",
"returns",
"an",
"io",
".",
"Reader",
"to",
"the",
"JPEG",
"thumbnail",
"embedded",
"in",
"the",
"CR2",
"image",
"in",
"r",
".",
"This",
"allows",
"access",
"to",
"the",
"raw",
"bytes",
"of",
"the",
"JPEG",
"thumbnail",
"without",
"the",
"ne... | 4699471a17ed597dc2011a21e5b37335710afdea | https://github.com/nf/cr2/blob/4699471a17ed597dc2011a21e5b37335710afdea/reader.go#L310-L324 |
144,262 | nf/cr2 | reader.go | Decode | func Decode(r io.Reader) (image.Image, error) {
r, err := NewReader(r)
if err != nil {
return nil, err
}
return jpeg.Decode(r)
} | go | func Decode(r io.Reader) (image.Image, error) {
r, err := NewReader(r)
if err != nil {
return nil, err
}
return jpeg.Decode(r)
} | [
"func",
"Decode",
"(",
"r",
"io",
".",
"Reader",
")",
"(",
"image",
".",
"Image",
",",
"error",
")",
"{",
"r",
",",
"err",
":=",
"NewReader",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"r... | // Decode reads a CR2 image from r and returns the embedded JPEG thumbnail as
// an image.Image. | [
"Decode",
"reads",
"a",
"CR2",
"image",
"from",
"r",
"and",
"returns",
"the",
"embedded",
"JPEG",
"thumbnail",
"as",
"an",
"image",
".",
"Image",
"."
] | 4699471a17ed597dc2011a21e5b37335710afdea | https://github.com/nf/cr2/blob/4699471a17ed597dc2011a21e5b37335710afdea/reader.go#L328-L334 |
144,263 | nf/cr2 | buffer.go | fill | func (b *buffer) fill(end int) error {
m := len(b.buf)
if end > m {
if end > cap(b.buf) {
newcap := 1024
for newcap < end {
newcap *= 2
}
newbuf := make([]byte, end, newcap)
copy(newbuf, b.buf)
b.buf = newbuf
} else {
b.buf = b.buf[:end]
}
if n, err := io.ReadFull(b.r, b.buf[m:end]); ... | go | func (b *buffer) fill(end int) error {
m := len(b.buf)
if end > m {
if end > cap(b.buf) {
newcap := 1024
for newcap < end {
newcap *= 2
}
newbuf := make([]byte, end, newcap)
copy(newbuf, b.buf)
b.buf = newbuf
} else {
b.buf = b.buf[:end]
}
if n, err := io.ReadFull(b.r, b.buf[m:end]); ... | [
"func",
"(",
"b",
"*",
"buffer",
")",
"fill",
"(",
"end",
"int",
")",
"error",
"{",
"m",
":=",
"len",
"(",
"b",
".",
"buf",
")",
"\n",
"if",
"end",
">",
"m",
"{",
"if",
"end",
">",
"cap",
"(",
"b",
".",
"buf",
")",
"{",
"newcap",
":=",
"1... | // fill reads data from b.r until the buffer contains at least end bytes. | [
"fill",
"reads",
"data",
"from",
"b",
".",
"r",
"until",
"the",
"buffer",
"contains",
"at",
"least",
"end",
"bytes",
"."
] | 4699471a17ed597dc2011a21e5b37335710afdea | https://github.com/nf/cr2/blob/4699471a17ed597dc2011a21e5b37335710afdea/buffer.go#L16-L37 |
144,264 | nf/cr2 | buffer.go | Slice | func (b *buffer) Slice(off, n int) ([]byte, error) {
end := off + n
if err := b.fill(end); err != nil {
return nil, err
}
return b.buf[off:end], nil
} | go | func (b *buffer) Slice(off, n int) ([]byte, error) {
end := off + n
if err := b.fill(end); err != nil {
return nil, err
}
return b.buf[off:end], nil
} | [
"func",
"(",
"b",
"*",
"buffer",
")",
"Slice",
"(",
"off",
",",
"n",
"int",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"end",
":=",
"off",
"+",
"n",
"\n",
"if",
"err",
":=",
"b",
".",
"fill",
"(",
"end",
")",
";",
"err",
"!=",
"n... | // Slice returns a slice of the underlying buffer. The slice contains
// n bytes starting at offset off. | [
"Slice",
"returns",
"a",
"slice",
"of",
"the",
"underlying",
"buffer",
".",
"The",
"slice",
"contains",
"n",
"bytes",
"starting",
"at",
"offset",
"off",
"."
] | 4699471a17ed597dc2011a21e5b37335710afdea | https://github.com/nf/cr2/blob/4699471a17ed597dc2011a21e5b37335710afdea/buffer.go#L52-L58 |
144,265 | nf/cr2 | buffer.go | newReaderAt | func newReaderAt(r io.Reader) io.ReaderAt {
if ra, ok := r.(io.ReaderAt); ok {
return ra
}
return &buffer{
r: r,
buf: make([]byte, 0, 1024),
}
} | go | func newReaderAt(r io.Reader) io.ReaderAt {
if ra, ok := r.(io.ReaderAt); ok {
return ra
}
return &buffer{
r: r,
buf: make([]byte, 0, 1024),
}
} | [
"func",
"newReaderAt",
"(",
"r",
"io",
".",
"Reader",
")",
"io",
".",
"ReaderAt",
"{",
"if",
"ra",
",",
"ok",
":=",
"r",
".",
"(",
"io",
".",
"ReaderAt",
")",
";",
"ok",
"{",
"return",
"ra",
"\n",
"}",
"\n",
"return",
"&",
"buffer",
"{",
"r",
... | // newReaderAt converts an io.Reader into an io.ReaderAt. | [
"newReaderAt",
"converts",
"an",
"io",
".",
"Reader",
"into",
"an",
"io",
".",
"ReaderAt",
"."
] | 4699471a17ed597dc2011a21e5b37335710afdea | https://github.com/nf/cr2/blob/4699471a17ed597dc2011a21e5b37335710afdea/buffer.go#L61-L69 |
144,266 | carlosdp/twiliogo | ip_role.go | GetIPRole | func GetIPRole(client *TwilioIPMessagingClient, serviceSid, sid string) (*IPRole, error) {
var role *IPRole
res, err := client.get(url.Values{}, "/Services/"+serviceSid+"/Roles/"+sid+".json")
if err != nil {
return nil, err
}
role = new(IPRole)
err = json.Unmarshal(res, role)
return role, err
} | go | func GetIPRole(client *TwilioIPMessagingClient, serviceSid, sid string) (*IPRole, error) {
var role *IPRole
res, err := client.get(url.Values{}, "/Services/"+serviceSid+"/Roles/"+sid+".json")
if err != nil {
return nil, err
}
role = new(IPRole)
err = json.Unmarshal(res, role)
return role, err
} | [
"func",
"GetIPRole",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"serviceSid",
",",
"sid",
"string",
")",
"(",
"*",
"IPRole",
",",
"error",
")",
"{",
"var",
"role",
"*",
"IPRole",
"\n\n",
"res",
",",
"err",
":=",
"client",
".",
"get",
"(",
"url... | // GetIPRole returns information on the specified role. | [
"GetIPRole",
"returns",
"information",
"on",
"the",
"specified",
"role",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_role.go#L75-L88 |
144,267 | carlosdp/twiliogo | ip_role.go | DeleteIPRole | func DeleteIPRole(client *TwilioIPMessagingClient, serviceSid, sid string) error {
return client.delete("/Services/" + serviceSid + "/Roles/" + sid)
} | go | func DeleteIPRole(client *TwilioIPMessagingClient, serviceSid, sid string) error {
return client.delete("/Services/" + serviceSid + "/Roles/" + sid)
} | [
"func",
"DeleteIPRole",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"serviceSid",
",",
"sid",
"string",
")",
"error",
"{",
"return",
"client",
".",
"delete",
"(",
"\"",
"\"",
"+",
"serviceSid",
"+",
"\"",
"\"",
"+",
"sid",
")",
"\n",
"}"
] | // DeleteIPRole deletes the given IP Role. | [
"DeleteIPRole",
"deletes",
"the",
"given",
"IP",
"Role",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_role.go#L91-L93 |
144,268 | carlosdp/twiliogo | ip_role.go | UpdateIPRole | func UpdateIPRole(client *TwilioIPMessagingClient, serviceSid string, sid string, friendlyName string, kind string, permissions []string) (*IPRole, error) {
var role *IPRole
params := url.Values{}
params.Set("FriendlyName", friendlyName)
params.Set("Type", kind)
if permissions != nil {
for _, p := range permiss... | go | func UpdateIPRole(client *TwilioIPMessagingClient, serviceSid string, sid string, friendlyName string, kind string, permissions []string) (*IPRole, error) {
var role *IPRole
params := url.Values{}
params.Set("FriendlyName", friendlyName)
params.Set("Type", kind)
if permissions != nil {
for _, p := range permiss... | [
"func",
"UpdateIPRole",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"serviceSid",
"string",
",",
"sid",
"string",
",",
"friendlyName",
"string",
",",
"kind",
"string",
",",
"permissions",
"[",
"]",
"string",
")",
"(",
"*",
"IPRole",
",",
"error",
")"... | // UpdateIPRole updates an existing IP Messaging Role. | [
"UpdateIPRole",
"updates",
"an",
"existing",
"IP",
"Messaging",
"Role",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_role.go#L96-L118 |
144,269 | carlosdp/twiliogo | ip_role.go | ListIPRoles | func ListIPRoles(client *TwilioIPMessagingClient, serviceSid string) (*IPRoleList, error) {
var roleList *IPRoleList
body, err := client.get(nil, "/Services/"+serviceSid+"/Roles.json")
if err != nil {
return roleList, err
}
roleList = new(IPRoleList)
roleList.Client = client
err = json.Unmarshal(body, roleL... | go | func ListIPRoles(client *TwilioIPMessagingClient, serviceSid string) (*IPRoleList, error) {
var roleList *IPRoleList
body, err := client.get(nil, "/Services/"+serviceSid+"/Roles.json")
if err != nil {
return roleList, err
}
roleList = new(IPRoleList)
roleList.Client = client
err = json.Unmarshal(body, roleL... | [
"func",
"ListIPRoles",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"serviceSid",
"string",
")",
"(",
"*",
"IPRoleList",
",",
"error",
")",
"{",
"var",
"roleList",
"*",
"IPRoleList",
"\n\n",
"body",
",",
"err",
":=",
"client",
".",
"get",
"(",
"nil"... | // ListIPRoles returns the first page of roles. | [
"ListIPRoles",
"returns",
"the",
"first",
"page",
"of",
"roles",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_role.go#L121-L135 |
144,270 | carlosdp/twiliogo | ip_role.go | PreviousPage | func (s *IPRoleList) PreviousPage() (*IPRoleList, error) {
if !s.HasPreviousPage() {
return nil, Error{"No previous page"}
}
return s.getPage(s.Meta.NextPageUri)
} | go | func (s *IPRoleList) PreviousPage() (*IPRoleList, error) {
if !s.HasPreviousPage() {
return nil, Error{"No previous page"}
}
return s.getPage(s.Meta.NextPageUri)
} | [
"func",
"(",
"s",
"*",
"IPRoleList",
")",
"PreviousPage",
"(",
")",
"(",
"*",
"IPRoleList",
",",
"error",
")",
"{",
"if",
"!",
"s",
".",
"HasPreviousPage",
"(",
")",
"{",
"return",
"nil",
",",
"Error",
"{",
"\"",
"\"",
"}",
"\n",
"}",
"\n\n",
"re... | // PreviousPage returns the previous page of roles. | [
"PreviousPage",
"returns",
"the",
"previous",
"page",
"of",
"roles",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_role.go#L178-L184 |
144,271 | carlosdp/twiliogo | ip_role.go | FirstPage | func (s *IPRoleList) FirstPage() (*IPRoleList, error) {
return s.getPage(s.Meta.FirstPageUri)
} | go | func (s *IPRoleList) FirstPage() (*IPRoleList, error) {
return s.getPage(s.Meta.FirstPageUri)
} | [
"func",
"(",
"s",
"*",
"IPRoleList",
")",
"FirstPage",
"(",
")",
"(",
"*",
"IPRoleList",
",",
"error",
")",
"{",
"return",
"s",
".",
"getPage",
"(",
"s",
".",
"Meta",
".",
"FirstPageUri",
")",
"\n",
"}"
] | // FirstPage returns the first page of roles. | [
"FirstPage",
"returns",
"the",
"first",
"page",
"of",
"roles",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_role.go#L187-L189 |
144,272 | carlosdp/twiliogo | ip_role.go | LastPage | func (s *IPRoleList) LastPage() (*IPRoleList, error) {
return s.getPage(s.Meta.LastPageUri)
} | go | func (s *IPRoleList) LastPage() (*IPRoleList, error) {
return s.getPage(s.Meta.LastPageUri)
} | [
"func",
"(",
"s",
"*",
"IPRoleList",
")",
"LastPage",
"(",
")",
"(",
"*",
"IPRoleList",
",",
"error",
")",
"{",
"return",
"s",
".",
"getPage",
"(",
"s",
".",
"Meta",
".",
"LastPageUri",
")",
"\n",
"}"
] | // LastPage returns the last page of roles. | [
"LastPage",
"returns",
"the",
"last",
"page",
"of",
"roles",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_role.go#L192-L194 |
144,273 | carlosdp/twiliogo | ip_service.go | NewIPService | func NewIPService(client *TwilioIPMessagingClient, friendlyName string, defaultServiceRoleSid string, defaultChannelRoleSid string,
typingIndicatorTimeout time.Duration, webhooks Webhooks) (*IPService, error) {
timeout, err := durationToISO8601(typingIndicatorTimeout)
if err != nil {
return nil, err
}
var serv... | go | func NewIPService(client *TwilioIPMessagingClient, friendlyName string, defaultServiceRoleSid string, defaultChannelRoleSid string,
typingIndicatorTimeout time.Duration, webhooks Webhooks) (*IPService, error) {
timeout, err := durationToISO8601(typingIndicatorTimeout)
if err != nil {
return nil, err
}
var serv... | [
"func",
"NewIPService",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"friendlyName",
"string",
",",
"defaultServiceRoleSid",
"string",
",",
"defaultChannelRoleSid",
"string",
",",
"typingIndicatorTimeout",
"time",
".",
"Duration",
",",
"webhooks",
"Webhooks",
")"... | // NewIPService creates a new IP Messaging Service. | [
"NewIPService",
"creates",
"a",
"new",
"IP",
"Messaging",
"Service",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_service.go#L88-L119 |
144,274 | carlosdp/twiliogo | ip_service.go | GetIPService | func GetIPService(client *TwilioIPMessagingClient, sid string) (*IPService, error) {
var service *IPService
res, err := client.get(url.Values{}, "/Services/"+sid+".json")
if err != nil {
return nil, err
}
service = new(IPService)
err = json.Unmarshal(res, service)
return service, err
} | go | func GetIPService(client *TwilioIPMessagingClient, sid string) (*IPService, error) {
var service *IPService
res, err := client.get(url.Values{}, "/Services/"+sid+".json")
if err != nil {
return nil, err
}
service = new(IPService)
err = json.Unmarshal(res, service)
return service, err
} | [
"func",
"GetIPService",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"sid",
"string",
")",
"(",
"*",
"IPService",
",",
"error",
")",
"{",
"var",
"service",
"*",
"IPService",
"\n\n",
"res",
",",
"err",
":=",
"client",
".",
"get",
"(",
"url",
".",
... | // GetIPService returns information on the specified service. | [
"GetIPService",
"returns",
"information",
"on",
"the",
"specified",
"service",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_service.go#L122-L135 |
144,275 | carlosdp/twiliogo | ip_service.go | ListIPServices | func ListIPServices(client *TwilioIPMessagingClient) (*IPServiceList, error) {
var serviceList *IPServiceList
body, err := client.get(nil, "/Services.json")
if err != nil {
return serviceList, err
}
serviceList = new(IPServiceList)
serviceList.Client = client
err = json.Unmarshal(body, serviceList)
return... | go | func ListIPServices(client *TwilioIPMessagingClient) (*IPServiceList, error) {
var serviceList *IPServiceList
body, err := client.get(nil, "/Services.json")
if err != nil {
return serviceList, err
}
serviceList = new(IPServiceList)
serviceList.Client = client
err = json.Unmarshal(body, serviceList)
return... | [
"func",
"ListIPServices",
"(",
"client",
"*",
"TwilioIPMessagingClient",
")",
"(",
"*",
"IPServiceList",
",",
"error",
")",
"{",
"var",
"serviceList",
"*",
"IPServiceList",
"\n\n",
"body",
",",
"err",
":=",
"client",
".",
"get",
"(",
"nil",
",",
"\"",
"\""... | // ListIPServices returns the first page of services. | [
"ListIPServices",
"returns",
"the",
"first",
"page",
"of",
"services",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_service.go#L175-L189 |
144,276 | carlosdp/twiliogo | ip_service.go | NextPage | func (s *IPServiceList) NextPage() (*IPServiceList, error) {
if !s.HasNextPage() {
return nil, Error{"No next page"}
}
return s.getPage(s.Meta.NextPageUri)
} | go | func (s *IPServiceList) NextPage() (*IPServiceList, error) {
if !s.HasNextPage() {
return nil, Error{"No next page"}
}
return s.getPage(s.Meta.NextPageUri)
} | [
"func",
"(",
"s",
"*",
"IPServiceList",
")",
"NextPage",
"(",
")",
"(",
"*",
"IPServiceList",
",",
"error",
")",
"{",
"if",
"!",
"s",
".",
"HasNextPage",
"(",
")",
"{",
"return",
"nil",
",",
"Error",
"{",
"\"",
"\"",
"}",
"\n",
"}",
"\n\n",
"retu... | // NextPage returns the next page of services. | [
"NextPage",
"returns",
"the",
"next",
"page",
"of",
"services",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_service.go#L218-L224 |
144,277 | carlosdp/twiliogo | ip_service.go | FirstPage | func (s *IPServiceList) FirstPage() (*IPServiceList, error) {
return s.getPage(s.Meta.FirstPageUri)
} | go | func (s *IPServiceList) FirstPage() (*IPServiceList, error) {
return s.getPage(s.Meta.FirstPageUri)
} | [
"func",
"(",
"s",
"*",
"IPServiceList",
")",
"FirstPage",
"(",
")",
"(",
"*",
"IPServiceList",
",",
"error",
")",
"{",
"return",
"s",
".",
"getPage",
"(",
"s",
".",
"Meta",
".",
"FirstPageUri",
")",
"\n",
"}"
] | // FirstPage returns the first page of services. | [
"FirstPage",
"returns",
"the",
"first",
"page",
"of",
"services",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_service.go#L241-L243 |
144,278 | carlosdp/twiliogo | ip_service.go | LastPage | func (s *IPServiceList) LastPage() (*IPServiceList, error) {
return s.getPage(s.Meta.LastPageUri)
} | go | func (s *IPServiceList) LastPage() (*IPServiceList, error) {
return s.getPage(s.Meta.LastPageUri)
} | [
"func",
"(",
"s",
"*",
"IPServiceList",
")",
"LastPage",
"(",
")",
"(",
"*",
"IPServiceList",
",",
"error",
")",
"{",
"return",
"s",
".",
"getPage",
"(",
"s",
".",
"Meta",
".",
"LastPageUri",
")",
"\n",
"}"
] | // LastPage returns the last page of services. | [
"LastPage",
"returns",
"the",
"last",
"page",
"of",
"services",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_service.go#L246-L248 |
144,279 | carlosdp/twiliogo | ip_channel.go | NewIPChannel | func NewIPChannel(client *TwilioIPMessagingClient, serviceSid string, friendlyName string, uniqueName string, public bool, attributes string) (*IPChannel, error) {
var channel *IPChannel
params := url.Values{}
params.Set("FriendlyName", friendlyName)
params.Set("UniqueName", uniqueName)
kind := "private"
if publ... | go | func NewIPChannel(client *TwilioIPMessagingClient, serviceSid string, friendlyName string, uniqueName string, public bool, attributes string) (*IPChannel, error) {
var channel *IPChannel
params := url.Values{}
params.Set("FriendlyName", friendlyName)
params.Set("UniqueName", uniqueName)
kind := "private"
if publ... | [
"func",
"NewIPChannel",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"serviceSid",
"string",
",",
"friendlyName",
"string",
",",
"uniqueName",
"string",
",",
"public",
"bool",
",",
"attributes",
"string",
")",
"(",
"*",
"IPChannel",
",",
"error",
")",
"... | // NewIPChannel creates a new IP Messaging Channel. | [
"NewIPChannel",
"creates",
"a",
"new",
"IP",
"Messaging",
"Channel",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_channel.go#L33-L56 |
144,280 | carlosdp/twiliogo | ip_channel.go | GetIPChannel | func GetIPChannel(client *TwilioIPMessagingClient, serviceSid string, sid string) (*IPChannel, error) {
var channel *IPChannel
res, err := client.get(url.Values{}, "/Services/"+serviceSid+"/Channels/"+sid+".json")
if err != nil {
return nil, err
}
channel = new(IPChannel)
err = json.Unmarshal(res, channel)
... | go | func GetIPChannel(client *TwilioIPMessagingClient, serviceSid string, sid string) (*IPChannel, error) {
var channel *IPChannel
res, err := client.get(url.Values{}, "/Services/"+serviceSid+"/Channels/"+sid+".json")
if err != nil {
return nil, err
}
channel = new(IPChannel)
err = json.Unmarshal(res, channel)
... | [
"func",
"GetIPChannel",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"serviceSid",
"string",
",",
"sid",
"string",
")",
"(",
"*",
"IPChannel",
",",
"error",
")",
"{",
"var",
"channel",
"*",
"IPChannel",
"\n\n",
"res",
",",
"err",
":=",
"client",
"."... | // GetIPChannel returns the specified IP Channel. | [
"GetIPChannel",
"returns",
"the",
"specified",
"IP",
"Channel",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_channel.go#L85-L98 |
144,281 | carlosdp/twiliogo | ip_channel.go | DeleteIPChannel | func DeleteIPChannel(client *TwilioIPMessagingClient, serviceSid, sid string) error {
return client.delete("/Services/" + serviceSid + "/Channels/" + sid)
} | go | func DeleteIPChannel(client *TwilioIPMessagingClient, serviceSid, sid string) error {
return client.delete("/Services/" + serviceSid + "/Channels/" + sid)
} | [
"func",
"DeleteIPChannel",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"serviceSid",
",",
"sid",
"string",
")",
"error",
"{",
"return",
"client",
".",
"delete",
"(",
"\"",
"\"",
"+",
"serviceSid",
"+",
"\"",
"\"",
"+",
"sid",
")",
"\n",
"}"
] | // DeleteIPChannel deletes the given IP Channel. | [
"DeleteIPChannel",
"deletes",
"the",
"given",
"IP",
"Channel",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_channel.go#L101-L103 |
144,282 | carlosdp/twiliogo | ip_channel.go | ListIPChannels | func ListIPChannels(client *TwilioIPMessagingClient, serviceSid string) (*IPChannelList, error) {
var channelList *IPChannelList
body, err := client.get(nil, "/Services/"+serviceSid+"/Channels.json")
if err != nil {
return channelList, err
}
channelList = new(IPChannelList)
channelList.Client = client
err =... | go | func ListIPChannels(client *TwilioIPMessagingClient, serviceSid string) (*IPChannelList, error) {
var channelList *IPChannelList
body, err := client.get(nil, "/Services/"+serviceSid+"/Channels.json")
if err != nil {
return channelList, err
}
channelList = new(IPChannelList)
channelList.Client = client
err =... | [
"func",
"ListIPChannels",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"serviceSid",
"string",
")",
"(",
"*",
"IPChannelList",
",",
"error",
")",
"{",
"var",
"channelList",
"*",
"IPChannelList",
"\n\n",
"body",
",",
"err",
":=",
"client",
".",
"get",
... | // ListIPChannels returns the first page of channels. | [
"ListIPChannels",
"returns",
"the",
"first",
"page",
"of",
"channels",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_channel.go#L106-L120 |
144,283 | carlosdp/twiliogo | ip_channel.go | FirstPage | func (c *IPChannelList) FirstPage() (*IPChannelList, error) {
return c.getPage(c.Meta.FirstPageUri)
} | go | func (c *IPChannelList) FirstPage() (*IPChannelList, error) {
return c.getPage(c.Meta.FirstPageUri)
} | [
"func",
"(",
"c",
"*",
"IPChannelList",
")",
"FirstPage",
"(",
")",
"(",
"*",
"IPChannelList",
",",
"error",
")",
"{",
"return",
"c",
".",
"getPage",
"(",
"c",
".",
"Meta",
".",
"FirstPageUri",
")",
"\n",
"}"
] | // FirstPage returns the first page of channels. | [
"FirstPage",
"returns",
"the",
"first",
"page",
"of",
"channels",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_channel.go#L172-L174 |
144,284 | carlosdp/twiliogo | ip_channel.go | LastPage | func (c *IPChannelList) LastPage() (*IPChannelList, error) {
return c.getPage(c.Meta.LastPageUri)
} | go | func (c *IPChannelList) LastPage() (*IPChannelList, error) {
return c.getPage(c.Meta.LastPageUri)
} | [
"func",
"(",
"c",
"*",
"IPChannelList",
")",
"LastPage",
"(",
")",
"(",
"*",
"IPChannelList",
",",
"error",
")",
"{",
"return",
"c",
".",
"getPage",
"(",
"c",
".",
"Meta",
".",
"LastPageUri",
")",
"\n",
"}"
] | // LastPage returns the last page of channels. | [
"LastPage",
"returns",
"the",
"last",
"page",
"of",
"channels",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_channel.go#L177-L179 |
144,285 | carlosdp/twiliogo | ip_message.go | SendIPMessageToChannel | func SendIPMessageToChannel(client *TwilioIPMessagingClient, serviceSid string, channelSid string, from string, body string) (*IPMessage, error) {
var message *IPMessage
params := url.Values{}
params.Set("Body", body)
if from != "" {
params.Set("From", from)
}
res, err := client.post(params, "/Services/"+serv... | go | func SendIPMessageToChannel(client *TwilioIPMessagingClient, serviceSid string, channelSid string, from string, body string) (*IPMessage, error) {
var message *IPMessage
params := url.Values{}
params.Set("Body", body)
if from != "" {
params.Set("From", from)
}
res, err := client.post(params, "/Services/"+serv... | [
"func",
"SendIPMessageToChannel",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"serviceSid",
"string",
",",
"channelSid",
"string",
",",
"from",
"string",
",",
"body",
"string",
")",
"(",
"*",
"IPMessage",
",",
"error",
")",
"{",
"var",
"message",
"*",
... | // SendIPMessageToChannel sends a message to a channel. | [
"SendIPMessageToChannel",
"sends",
"a",
"message",
"to",
"a",
"channel",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_message.go#L31-L50 |
144,286 | carlosdp/twiliogo | ip_message.go | GetIPChannelMessage | func GetIPChannelMessage(client *TwilioIPMessagingClient, serviceSid, channelSid, sid string) (*IPMessage, error) {
var message *IPMessage
res, err := client.get(url.Values{}, "/Services/"+serviceSid+"/Channels/"+channelSid+"/Messages/"+sid+".json")
if err != nil {
return nil, err
}
message = new(IPMessage)
... | go | func GetIPChannelMessage(client *TwilioIPMessagingClient, serviceSid, channelSid, sid string) (*IPMessage, error) {
var message *IPMessage
res, err := client.get(url.Values{}, "/Services/"+serviceSid+"/Channels/"+channelSid+"/Messages/"+sid+".json")
if err != nil {
return nil, err
}
message = new(IPMessage)
... | [
"func",
"GetIPChannelMessage",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"serviceSid",
",",
"channelSid",
",",
"sid",
"string",
")",
"(",
"*",
"IPMessage",
",",
"error",
")",
"{",
"var",
"message",
"*",
"IPMessage",
"\n\n",
"res",
",",
"err",
":=",... | // GetIPChannelMessage returns the specified IP Message in the channel. | [
"GetIPChannelMessage",
"returns",
"the",
"specified",
"IP",
"Message",
"in",
"the",
"channel",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_message.go#L53-L66 |
144,287 | carlosdp/twiliogo | ip_message.go | ListIPMessages | func ListIPMessages(client *TwilioIPMessagingClient, serviceSid, channelSid string) (*IPMessageList, error) {
var messageList *IPMessageList
body, err := client.get(nil, "/Services/"+serviceSid+"/Channels/"+channelSid+"/Messages.json")
if err != nil {
return messageList, err
}
messageList = new(IPMessageList)... | go | func ListIPMessages(client *TwilioIPMessagingClient, serviceSid, channelSid string) (*IPMessageList, error) {
var messageList *IPMessageList
body, err := client.get(nil, "/Services/"+serviceSid+"/Channels/"+channelSid+"/Messages.json")
if err != nil {
return messageList, err
}
messageList = new(IPMessageList)... | [
"func",
"ListIPMessages",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"serviceSid",
",",
"channelSid",
"string",
")",
"(",
"*",
"IPMessageList",
",",
"error",
")",
"{",
"var",
"messageList",
"*",
"IPMessageList",
"\n\n",
"body",
",",
"err",
":=",
"clie... | // ListIPMessages returns the first page of messages for a channel. | [
"ListIPMessages",
"returns",
"the",
"first",
"page",
"of",
"messages",
"for",
"a",
"channel",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_message.go#L69-L83 |
144,288 | carlosdp/twiliogo | ip_message.go | FirstPage | func (c *IPMessageList) FirstPage() (*IPMessageList, error) {
return c.getPage(c.Meta.FirstPageUri)
} | go | func (c *IPMessageList) FirstPage() (*IPMessageList, error) {
return c.getPage(c.Meta.FirstPageUri)
} | [
"func",
"(",
"c",
"*",
"IPMessageList",
")",
"FirstPage",
"(",
")",
"(",
"*",
"IPMessageList",
",",
"error",
")",
"{",
"return",
"c",
".",
"getPage",
"(",
"c",
".",
"Meta",
".",
"FirstPageUri",
")",
"\n",
"}"
] | // FirstPage returns the first page of messages. | [
"FirstPage",
"returns",
"the",
"first",
"page",
"of",
"messages",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_message.go#L135-L137 |
144,289 | carlosdp/twiliogo | ip_message.go | LastPage | func (c *IPMessageList) LastPage() (*IPMessageList, error) {
return c.getPage(c.Meta.LastPageUri)
} | go | func (c *IPMessageList) LastPage() (*IPMessageList, error) {
return c.getPage(c.Meta.LastPageUri)
} | [
"func",
"(",
"c",
"*",
"IPMessageList",
")",
"LastPage",
"(",
")",
"(",
"*",
"IPMessageList",
",",
"error",
")",
"{",
"return",
"c",
".",
"getPage",
"(",
"c",
".",
"Meta",
".",
"LastPageUri",
")",
"\n",
"}"
] | // LastPage returns the last page of messages. | [
"LastPage",
"returns",
"the",
"last",
"page",
"of",
"messages",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_message.go#L140-L142 |
144,290 | carlosdp/twiliogo | ip_credential.go | NewIPCredential | func NewIPCredential(client *TwilioIPMessagingClient, friendlyName string, kind string, sandbox bool, apnsCert string, apnsPrivateKey string,
gcmApiKey string) (*IPCredential, error) {
var credential *IPCredential
params := url.Values{}
params.Set("FriendlyName", friendlyName)
params.Set("Type", kind)
if sandbox... | go | func NewIPCredential(client *TwilioIPMessagingClient, friendlyName string, kind string, sandbox bool, apnsCert string, apnsPrivateKey string,
gcmApiKey string) (*IPCredential, error) {
var credential *IPCredential
params := url.Values{}
params.Set("FriendlyName", friendlyName)
params.Set("Type", kind)
if sandbox... | [
"func",
"NewIPCredential",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"friendlyName",
"string",
",",
"kind",
"string",
",",
"sandbox",
"bool",
",",
"apnsCert",
"string",
",",
"apnsPrivateKey",
"string",
",",
"gcmApiKey",
"string",
")",
"(",
"*",
"IPCred... | // NewIPCredential creates a new IP Messaging Credential.
// Kind must be apns or gcm. | [
"NewIPCredential",
"creates",
"a",
"new",
"IP",
"Messaging",
"Credential",
".",
"Kind",
"must",
"be",
"apns",
"or",
"gcm",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_credential.go#L28-L60 |
144,291 | carlosdp/twiliogo | ip_credential.go | GetIPCredential | func GetIPCredential(client *TwilioIPMessagingClient, sid string) (*IPCredential, error) {
var credential *IPCredential
res, err := client.get(url.Values{}, "/Credentials/"+sid+".json")
if err != nil {
return nil, err
}
credential = new(IPCredential)
err = json.Unmarshal(res, credential)
return credential,... | go | func GetIPCredential(client *TwilioIPMessagingClient, sid string) (*IPCredential, error) {
var credential *IPCredential
res, err := client.get(url.Values{}, "/Credentials/"+sid+".json")
if err != nil {
return nil, err
}
credential = new(IPCredential)
err = json.Unmarshal(res, credential)
return credential,... | [
"func",
"GetIPCredential",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"sid",
"string",
")",
"(",
"*",
"IPCredential",
",",
"error",
")",
"{",
"var",
"credential",
"*",
"IPCredential",
"\n\n",
"res",
",",
"err",
":=",
"client",
".",
"get",
"(",
"ur... | // GetIPCredential returns information on the specified credential. | [
"GetIPCredential",
"returns",
"information",
"on",
"the",
"specified",
"credential",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_credential.go#L63-L76 |
144,292 | carlosdp/twiliogo | ip_credential.go | UpdateIPCredential | func UpdateIPCredential(client *TwilioIPMessagingClient, sid string, friendlyName string, kind string, sandbox bool) (*IPCredential, error) {
var credential *IPCredential
params := url.Values{}
params.Set("FriendlyName", friendlyName)
params.Set("Type", kind)
if sandbox {
params.Set("Sandbox", "true")
} else {... | go | func UpdateIPCredential(client *TwilioIPMessagingClient, sid string, friendlyName string, kind string, sandbox bool) (*IPCredential, error) {
var credential *IPCredential
params := url.Values{}
params.Set("FriendlyName", friendlyName)
params.Set("Type", kind)
if sandbox {
params.Set("Sandbox", "true")
} else {... | [
"func",
"UpdateIPCredential",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"sid",
"string",
",",
"friendlyName",
"string",
",",
"kind",
"string",
",",
"sandbox",
"bool",
")",
"(",
"*",
"IPCredential",
",",
"error",
")",
"{",
"var",
"credential",
"*",
... | // UpdateIPCredential updates an existing IP Messaging Credential. | [
"UpdateIPCredential",
"updates",
"an",
"existing",
"IP",
"Messaging",
"Credential",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_credential.go#L84-L106 |
144,293 | carlosdp/twiliogo | ip_credential.go | ListIPCredentials | func ListIPCredentials(client *TwilioIPMessagingClient) (*IPCredentialList, error) {
var credentialList *IPCredentialList
body, err := client.get(nil, "/Credentials.json")
if err != nil {
return credentialList, err
}
credentialList = new(IPCredentialList)
credentialList.Client = client
err = json.Unmarshal(... | go | func ListIPCredentials(client *TwilioIPMessagingClient) (*IPCredentialList, error) {
var credentialList *IPCredentialList
body, err := client.get(nil, "/Credentials.json")
if err != nil {
return credentialList, err
}
credentialList = new(IPCredentialList)
credentialList.Client = client
err = json.Unmarshal(... | [
"func",
"ListIPCredentials",
"(",
"client",
"*",
"TwilioIPMessagingClient",
")",
"(",
"*",
"IPCredentialList",
",",
"error",
")",
"{",
"var",
"credentialList",
"*",
"IPCredentialList",
"\n\n",
"body",
",",
"err",
":=",
"client",
".",
"get",
"(",
"nil",
",",
... | // ListIPCredentials returns the first page of credentials. | [
"ListIPCredentials",
"returns",
"the",
"first",
"page",
"of",
"credentials",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_credential.go#L109-L123 |
144,294 | carlosdp/twiliogo | ip_credential.go | FirstPage | func (s *IPCredentialList) FirstPage() (*IPCredentialList, error) {
return s.getPage(s.Meta.FirstPageUri)
} | go | func (s *IPCredentialList) FirstPage() (*IPCredentialList, error) {
return s.getPage(s.Meta.FirstPageUri)
} | [
"func",
"(",
"s",
"*",
"IPCredentialList",
")",
"FirstPage",
"(",
")",
"(",
"*",
"IPCredentialList",
",",
"error",
")",
"{",
"return",
"s",
".",
"getPage",
"(",
"s",
".",
"Meta",
".",
"FirstPageUri",
")",
"\n",
"}"
] | // FirstPage returns the first page of credentials. | [
"FirstPage",
"returns",
"the",
"first",
"page",
"of",
"credentials",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_credential.go#L175-L177 |
144,295 | carlosdp/twiliogo | ip_credential.go | LastPage | func (s *IPCredentialList) LastPage() (*IPCredentialList, error) {
return s.getPage(s.Meta.LastPageUri)
} | go | func (s *IPCredentialList) LastPage() (*IPCredentialList, error) {
return s.getPage(s.Meta.LastPageUri)
} | [
"func",
"(",
"s",
"*",
"IPCredentialList",
")",
"LastPage",
"(",
")",
"(",
"*",
"IPCredentialList",
",",
"error",
")",
"{",
"return",
"s",
".",
"getPage",
"(",
"s",
".",
"Meta",
".",
"LastPageUri",
")",
"\n",
"}"
] | // LastPage returns the last page of credentials. | [
"LastPage",
"returns",
"the",
"last",
"page",
"of",
"credentials",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_credential.go#L180-L182 |
144,296 | carlosdp/twiliogo | ip_user.go | GetIPUser | func GetIPUser(client *TwilioIPMessagingClient, serviceSid, sid string) (*IPUser, error) {
var user *IPUser
res, err := client.get(url.Values{}, "/Services/"+serviceSid+"/Users/"+sid+".json")
if err != nil {
return nil, err
}
user = new(IPUser)
err = json.Unmarshal(res, user)
return user, err
} | go | func GetIPUser(client *TwilioIPMessagingClient, serviceSid, sid string) (*IPUser, error) {
var user *IPUser
res, err := client.get(url.Values{}, "/Services/"+serviceSid+"/Users/"+sid+".json")
if err != nil {
return nil, err
}
user = new(IPUser)
err = json.Unmarshal(res, user)
return user, err
} | [
"func",
"GetIPUser",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"serviceSid",
",",
"sid",
"string",
")",
"(",
"*",
"IPUser",
",",
"error",
")",
"{",
"var",
"user",
"*",
"IPUser",
"\n\n",
"res",
",",
"err",
":=",
"client",
".",
"get",
"(",
"url... | // GetIPUser returns information on the specified user. | [
"GetIPUser",
"returns",
"information",
"on",
"the",
"specified",
"user",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_user.go#L49-L62 |
144,297 | carlosdp/twiliogo | ip_user.go | DeleteIPUser | func DeleteIPUser(client *TwilioIPMessagingClient, serviceSid, sid string) error {
return client.delete("/Services/" + serviceSid + "/Users/" + sid)
} | go | func DeleteIPUser(client *TwilioIPMessagingClient, serviceSid, sid string) error {
return client.delete("/Services/" + serviceSid + "/Users/" + sid)
} | [
"func",
"DeleteIPUser",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"serviceSid",
",",
"sid",
"string",
")",
"error",
"{",
"return",
"client",
".",
"delete",
"(",
"\"",
"\"",
"+",
"serviceSid",
"+",
"\"",
"\"",
"+",
"sid",
")",
"\n",
"}"
] | // DeleteIPUser deletes the given IP user. | [
"DeleteIPUser",
"deletes",
"the",
"given",
"IP",
"user",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_user.go#L65-L67 |
144,298 | carlosdp/twiliogo | ip_user.go | UpdateIPUser | func UpdateIPUser(client *TwilioIPMessagingClient, serviceSid string, sid string, identity string, roleSid string) (*IPUser, error) {
var user *IPUser
params := url.Values{}
params.Set("Identity", identity)
params.Set("RoleSid", roleSid)
res, err := client.post(params, "/Services/"+serviceSid+"/Users/"+sid+".jso... | go | func UpdateIPUser(client *TwilioIPMessagingClient, serviceSid string, sid string, identity string, roleSid string) (*IPUser, error) {
var user *IPUser
params := url.Values{}
params.Set("Identity", identity)
params.Set("RoleSid", roleSid)
res, err := client.post(params, "/Services/"+serviceSid+"/Users/"+sid+".jso... | [
"func",
"UpdateIPUser",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"serviceSid",
"string",
",",
"sid",
"string",
",",
"identity",
"string",
",",
"roleSid",
"string",
")",
"(",
"*",
"IPUser",
",",
"error",
")",
"{",
"var",
"user",
"*",
"IPUser",
"\... | // UpdateIPUser updates an existing IP Messaging user. | [
"UpdateIPUser",
"updates",
"an",
"existing",
"IP",
"Messaging",
"user",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_user.go#L70-L87 |
144,299 | carlosdp/twiliogo | ip_user.go | ListIPUsers | func ListIPUsers(client *TwilioIPMessagingClient, serviceSid string) (*IPUserList, error) {
var userList *IPUserList
body, err := client.get(nil, "/Services/"+serviceSid+"/Users.json")
if err != nil {
return userList, err
}
userList = new(IPUserList)
userList.Client = client
err = json.Unmarshal(body, userL... | go | func ListIPUsers(client *TwilioIPMessagingClient, serviceSid string) (*IPUserList, error) {
var userList *IPUserList
body, err := client.get(nil, "/Services/"+serviceSid+"/Users.json")
if err != nil {
return userList, err
}
userList = new(IPUserList)
userList.Client = client
err = json.Unmarshal(body, userL... | [
"func",
"ListIPUsers",
"(",
"client",
"*",
"TwilioIPMessagingClient",
",",
"serviceSid",
"string",
")",
"(",
"*",
"IPUserList",
",",
"error",
")",
"{",
"var",
"userList",
"*",
"IPUserList",
"\n\n",
"body",
",",
"err",
":=",
"client",
".",
"get",
"(",
"nil"... | // ListIPUsers returns the first page of users. | [
"ListIPUsers",
"returns",
"the",
"first",
"page",
"of",
"users",
"."
] | b26045ebb9d15c9296ba59d94687aaf7d2080905 | https://github.com/carlosdp/twiliogo/blob/b26045ebb9d15c9296ba59d94687aaf7d2080905/ip_user.go#L90-L104 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.