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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
154,200 | rdwilliamson/aws | glacier/multipart.go | ListMultipartParts | func (c *Connection) ListMultipartParts(vault, uploadId, marker string, limit int) (*MultipartParts, error) {
// Build request.
parameters := parameters{}
if limit > 0 {
// TODO validate limit
parameters.add("limit", strconv.Itoa(limit))
}
if marker != "" {
parameters.add("marker", marker)
}
request, err := http.NewRequest("GET", c.vault(vault)+"/multipart-uploads/"+uploadId+parameters.encode(), nil)
if err != nil {
return nil, err
}
request.Header.Add("x-amz-glacier-version", "2012-06-01")
c.Signature.Sign(request, nil)
// Perform request.
response, err := c.client().Do(request)
if err != nil {
return nil, err
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
return nil, aws.ParseError(response)
}
// Parse success response.
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return nil, err
}
var list struct {
ArchiveDescription string
CreationDate string
Marker *string
MultipartUploadId string
PartSizeInBytes int64
Parts []MultipartPart
VaultARN string
}
err = json.Unmarshal(body, &list)
if err != nil {
return nil, err
}
var result MultipartParts
result.ArchiveDescription = list.ArchiveDescription
result.CreationDate, err = time.Parse(time.RFC3339, list.CreationDate)
if err != nil {
return nil, err
}
if list.Marker != nil {
result.Marker = *list.Marker
}
result.MultipartUploadId = list.MultipartUploadId
result.PartSizeInBytes = list.PartSizeInBytes
result.Parts = list.Parts
result.VaultARN = list.VaultARN
return &result, nil
} | go | func (c *Connection) ListMultipartParts(vault, uploadId, marker string, limit int) (*MultipartParts, error) {
// Build request.
parameters := parameters{}
if limit > 0 {
// TODO validate limit
parameters.add("limit", strconv.Itoa(limit))
}
if marker != "" {
parameters.add("marker", marker)
}
request, err := http.NewRequest("GET", c.vault(vault)+"/multipart-uploads/"+uploadId+parameters.encode(), nil)
if err != nil {
return nil, err
}
request.Header.Add("x-amz-glacier-version", "2012-06-01")
c.Signature.Sign(request, nil)
// Perform request.
response, err := c.client().Do(request)
if err != nil {
return nil, err
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
return nil, aws.ParseError(response)
}
// Parse success response.
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return nil, err
}
var list struct {
ArchiveDescription string
CreationDate string
Marker *string
MultipartUploadId string
PartSizeInBytes int64
Parts []MultipartPart
VaultARN string
}
err = json.Unmarshal(body, &list)
if err != nil {
return nil, err
}
var result MultipartParts
result.ArchiveDescription = list.ArchiveDescription
result.CreationDate, err = time.Parse(time.RFC3339, list.CreationDate)
if err != nil {
return nil, err
}
if list.Marker != nil {
result.Marker = *list.Marker
}
result.MultipartUploadId = list.MultipartUploadId
result.PartSizeInBytes = list.PartSizeInBytes
result.Parts = list.Parts
result.VaultARN = list.VaultARN
return &result, nil
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"ListMultipartParts",
"(",
"vault",
",",
"uploadId",
",",
"marker",
"string",
",",
"limit",
"int",
")",
"(",
"*",
"MultipartParts",
",",
"error",
")",
"{",
"// Build request.",
"parameters",
":=",
"parameters",
"{",
... | // This multipart upload operation lists the parts of an archive that have been
// uploaded in a specific multipart upload identified by an upload ID.
//
// You can make this request at any time during an in-progress multipart upload
// before you complete the multipart upload. Amazon Glacier returns the part
// list sorted by range you specified in each part upload. If you send a List
// Parts request after completing the multipart upload, Amazon Glacier returns
// an error.
//
// The List Parts operation supports pagination. By default, this operation
// returns up to 1,000 uploaded parts in the response.You should always check
// the marker field in the response body for a marker at which to continue the
// list; if there are no more items the marker field is null. If the marker is
// not null, to fetch the next set of parts you sent another List Parts request
// with the marker request parameter set to the marker value Amazon Glacier
// returned in response to your previous List Parts request.
//
// You can also limit the number of parts returned in the response by specifying
// the limit parameter in the request. | [
"This",
"multipart",
"upload",
"operation",
"lists",
"the",
"parts",
"of",
"an",
"archive",
"that",
"have",
"been",
"uploaded",
"in",
"a",
"specific",
"multipart",
"upload",
"identified",
"by",
"an",
"upload",
"ID",
".",
"You",
"can",
"make",
"this",
"reques... | 54608bb65939fc94439865d46598a57f7f15fb0e | https://github.com/rdwilliamson/aws/blob/54608bb65939fc94439865d46598a57f7f15fb0e/glacier/multipart.go#L300-L365 |
154,201 | rdwilliamson/aws | glacier/multipart.go | ListMultipartUploads | func (c *Connection) ListMultipartUploads(vault, marker string, limit int) ([]Multipart, string, error) {
// Build request.
query := url.Values{}
if limit > 0 {
// TODO validate limit
query.Add("limit", fmt.Sprint(limit))
}
if marker != "" {
query.Add("marker", marker)
}
request, err := http.NewRequest("GET", c.vault(vault)+"/multipart-uploads"+query.Encode(), nil)
if err != nil {
return nil, "", err
}
request.Header.Add("x-amz-glacier-version", "2012-06-01")
c.Signature.Sign(request, nil)
// Perform request.
response, err := c.client().Do(request)
if err != nil {
return nil, "", err
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
return nil, "", aws.ParseError(response)
}
// Parse success response.
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return nil, "", err
}
var list struct {
Marker *string
UploadsList []struct {
ArchiveDescription *string
CreationDate string
MultipartUploadId string
PartSizeInBytes int64
VaultARN string
}
}
err = json.Unmarshal(body, &list)
if err != nil {
return nil, "", err
}
parts := make([]Multipart, len(list.UploadsList))
for i, v := range list.UploadsList {
if v.ArchiveDescription != nil {
parts[i].ArchiveDescription = *v.ArchiveDescription
}
parts[i].CreationDate, err = time.Parse(time.RFC3339, v.CreationDate)
if err != nil {
return nil, "", err
}
parts[i].MultipartUploadId = v.MultipartUploadId
parts[i].PartSizeInBytes = v.PartSizeInBytes
parts[i].VaultARN = v.VaultARN
}
var m string
if list.Marker != nil {
m = *list.Marker
}
return parts, m, nil
} | go | func (c *Connection) ListMultipartUploads(vault, marker string, limit int) ([]Multipart, string, error) {
// Build request.
query := url.Values{}
if limit > 0 {
// TODO validate limit
query.Add("limit", fmt.Sprint(limit))
}
if marker != "" {
query.Add("marker", marker)
}
request, err := http.NewRequest("GET", c.vault(vault)+"/multipart-uploads"+query.Encode(), nil)
if err != nil {
return nil, "", err
}
request.Header.Add("x-amz-glacier-version", "2012-06-01")
c.Signature.Sign(request, nil)
// Perform request.
response, err := c.client().Do(request)
if err != nil {
return nil, "", err
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
return nil, "", aws.ParseError(response)
}
// Parse success response.
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return nil, "", err
}
var list struct {
Marker *string
UploadsList []struct {
ArchiveDescription *string
CreationDate string
MultipartUploadId string
PartSizeInBytes int64
VaultARN string
}
}
err = json.Unmarshal(body, &list)
if err != nil {
return nil, "", err
}
parts := make([]Multipart, len(list.UploadsList))
for i, v := range list.UploadsList {
if v.ArchiveDescription != nil {
parts[i].ArchiveDescription = *v.ArchiveDescription
}
parts[i].CreationDate, err = time.Parse(time.RFC3339, v.CreationDate)
if err != nil {
return nil, "", err
}
parts[i].MultipartUploadId = v.MultipartUploadId
parts[i].PartSizeInBytes = v.PartSizeInBytes
parts[i].VaultARN = v.VaultARN
}
var m string
if list.Marker != nil {
m = *list.Marker
}
return parts, m, nil
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"ListMultipartUploads",
"(",
"vault",
",",
"marker",
"string",
",",
"limit",
"int",
")",
"(",
"[",
"]",
"Multipart",
",",
"string",
",",
"error",
")",
"{",
"// Build request.",
"query",
":=",
"url",
".",
"Values"... | // This multipart upload operation lists in-progress multipart uploads for the
// specified vault. An in-progress multipart upload is a multipart upload that
// has been initiated by an Initiate Multipart Upload request, but has not yet
// been completed or aborted. The list returned in the List Multipart Upload
// response has no guaranteed order.
//
// The List Multipart Uploads operation supports pagination. By default, this
// operation returns up to 1,000 multipart uploads in the response.You should
// always check the marker field in the response body for a marker at which to
// continue the list; if there are no more items the marker field is null.
//
// If the marker is not null, to fetch the next set of multipart uploads you
// sent another List Multipart Uploads request with the marker request parameter
// set to the marker value Amazon Glacier returned in response to your previous
// List Multipart Uploads request.
//
// Note the difference between this operation and the List Parts operation.The
// List Multipart Uploads operation lists all multipart uploads for a vault. The
// List Parts operation returns parts of a specific multipart upload identified
// by an Upload ID. | [
"This",
"multipart",
"upload",
"operation",
"lists",
"in",
"-",
"progress",
"multipart",
"uploads",
"for",
"the",
"specified",
"vault",
".",
"An",
"in",
"-",
"progress",
"multipart",
"upload",
"is",
"a",
"multipart",
"upload",
"that",
"has",
"been",
"initiated... | 54608bb65939fc94439865d46598a57f7f15fb0e | https://github.com/rdwilliamson/aws/blob/54608bb65939fc94439865d46598a57f7f15fb0e/glacier/multipart.go#L387-L458 |
154,202 | rdwilliamson/aws | glacier/multipart.go | TreeHashFromMultipartUpload | func (c *Connection) TreeHashFromMultipartUpload(vault, uploadID string) (string, error) {
marker := ""
m := MultiTreeHasher{}
for {
parts, err := c.ListMultipartParts(vault, uploadID, marker, 0)
if err != nil {
return "", err
}
for _, v := range parts.Parts {
m.Add(v.SHA256TreeHash)
}
if parts.Marker == "" {
break
}
marker = parts.Marker
}
return m.CreateHash(), nil
} | go | func (c *Connection) TreeHashFromMultipartUpload(vault, uploadID string) (string, error) {
marker := ""
m := MultiTreeHasher{}
for {
parts, err := c.ListMultipartParts(vault, uploadID, marker, 0)
if err != nil {
return "", err
}
for _, v := range parts.Parts {
m.Add(v.SHA256TreeHash)
}
if parts.Marker == "" {
break
}
marker = parts.Marker
}
return m.CreateHash(), nil
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"TreeHashFromMultipartUpload",
"(",
"vault",
",",
"uploadID",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"marker",
":=",
"\"",
"\"",
"\n",
"m",
":=",
"MultiTreeHasher",
"{",
"}",
"\n",
"for",
"{",
"p... | // TreeHashFromMultipartUpload lists the underlying parts
// and returns a hex-formatted treehash of the entire archive,
// for use in sending along with a CompleteMultipart request. | [
"TreeHashFromMultipartUpload",
"lists",
"the",
"underlying",
"parts",
"and",
"returns",
"a",
"hex",
"-",
"formatted",
"treehash",
"of",
"the",
"entire",
"archive",
"for",
"use",
"in",
"sending",
"along",
"with",
"a",
"CompleteMultipart",
"request",
"."
] | 54608bb65939fc94439865d46598a57f7f15fb0e | https://github.com/rdwilliamson/aws/blob/54608bb65939fc94439865d46598a57f7f15fb0e/glacier/multipart.go#L463-L480 |
154,203 | crackcomm/cloudflare | client.go | New | func New(opts *Options) *Client {
return &Client{
Zones: &Zones{Options: opts},
Records: &Records{Options: opts},
Firewalls: &Firewalls{Options: opts},
Options: opts,
}
} | go | func New(opts *Options) *Client {
return &Client{
Zones: &Zones{Options: opts},
Records: &Records{Options: opts},
Firewalls: &Firewalls{Options: opts},
Options: opts,
}
} | [
"func",
"New",
"(",
"opts",
"*",
"Options",
")",
"*",
"Client",
"{",
"return",
"&",
"Client",
"{",
"Zones",
":",
"&",
"Zones",
"{",
"Options",
":",
"opts",
"}",
",",
"Records",
":",
"&",
"Records",
"{",
"Options",
":",
"opts",
"}",
",",
"Firewalls"... | // New - Creates a new Cloudflare client. | [
"New",
"-",
"Creates",
"a",
"new",
"Cloudflare",
"client",
"."
] | dc358193164414054010e3fafdb6cc8def4eb864 | https://github.com/crackcomm/cloudflare/blob/dc358193164414054010e3fafdb6cc8def4eb864/client.go#L21-L28 |
154,204 | jacobsa/daemonize | daemonize.go | startProcess | func startProcess(
path string,
args []string,
env []string,
pipeW *os.File) (err error) {
cmd := exec.Command(path)
cmd.Args = append(cmd.Args, args...)
cmd.Env = append(cmd.Env, env...)
cmd.ExtraFiles = []*os.File{pipeW}
// Change working directories so that we don't prevent unmounting of the
// volume of our current working directory.
cmd.Dir = "/"
// Call setsid after forking in order to avoid being killed when the user
// logs out.
cmd.SysProcAttr = &syscall.SysProcAttr{
Setsid: true,
}
// Send along the write end of the pipe.
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=3", envVar))
// Start. Clean up in the background, ignoring errors.
err = cmd.Start()
go cmd.Wait()
return
} | go | func startProcess(
path string,
args []string,
env []string,
pipeW *os.File) (err error) {
cmd := exec.Command(path)
cmd.Args = append(cmd.Args, args...)
cmd.Env = append(cmd.Env, env...)
cmd.ExtraFiles = []*os.File{pipeW}
// Change working directories so that we don't prevent unmounting of the
// volume of our current working directory.
cmd.Dir = "/"
// Call setsid after forking in order to avoid being killed when the user
// logs out.
cmd.SysProcAttr = &syscall.SysProcAttr{
Setsid: true,
}
// Send along the write end of the pipe.
cmd.Env = append(cmd.Env, fmt.Sprintf("%s=3", envVar))
// Start. Clean up in the background, ignoring errors.
err = cmd.Start()
go cmd.Wait()
return
} | [
"func",
"startProcess",
"(",
"path",
"string",
",",
"args",
"[",
"]",
"string",
",",
"env",
"[",
"]",
"string",
",",
"pipeW",
"*",
"os",
".",
"File",
")",
"(",
"err",
"error",
")",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"path",
")",
"\n",... | // Start the daemon process, handing it the supplied pipe for communication. Do
// not wait for it to return. | [
"Start",
"the",
"daemon",
"process",
"handing",
"it",
"the",
"supplied",
"pipe",
"for",
"communication",
".",
"Do",
"not",
"wait",
"for",
"it",
"to",
"return",
"."
] | e460293e890f254bdec4234e574fa31ac7927c2c | https://github.com/jacobsa/daemonize/blob/e460293e890f254bdec4234e574fa31ac7927c2c/daemonize.go#L205-L233 |
154,205 | apid/apidApigeeSync | data.go | initDB | func (dbMan *dbManager) initDB() error {
db, err := dataService.DB()
if err != nil {
return err
}
tx, err := db.Begin()
if err != nil {
log.Errorf("initDB(): Unable to get DB tx err: {%v}", err)
return err
}
defer tx.Rollback()
_, err = tx.Exec(`
CREATE TABLE IF NOT EXISTS APID (
instance_id text,
apid_cluster_id text,
last_snapshot_info text,
PRIMARY KEY (instance_id)
);
`)
if err != nil {
log.Errorf("initDB(): Unable to tx exec err: {%v}", err)
return err
}
if err = tx.Commit(); err != nil {
log.Errorf("Error when initDb: %v", err)
return err
}
log.Debug("Database tables created.")
return nil
} | go | func (dbMan *dbManager) initDB() error {
db, err := dataService.DB()
if err != nil {
return err
}
tx, err := db.Begin()
if err != nil {
log.Errorf("initDB(): Unable to get DB tx err: {%v}", err)
return err
}
defer tx.Rollback()
_, err = tx.Exec(`
CREATE TABLE IF NOT EXISTS APID (
instance_id text,
apid_cluster_id text,
last_snapshot_info text,
PRIMARY KEY (instance_id)
);
`)
if err != nil {
log.Errorf("initDB(): Unable to tx exec err: {%v}", err)
return err
}
if err = tx.Commit(); err != nil {
log.Errorf("Error when initDb: %v", err)
return err
}
log.Debug("Database tables created.")
return nil
} | [
"func",
"(",
"dbMan",
"*",
"dbManager",
")",
"initDB",
"(",
")",
"error",
"{",
"db",
",",
"err",
":=",
"dataService",
".",
"DB",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"tx",
",",
"err",
":=",
"db",
".",... | // idempotent call to initialize default DB | [
"idempotent",
"call",
"to",
"initialize",
"default",
"DB"
] | 655b66d3ded76155c155649c401cc9ac0fbf3969 | https://github.com/apid/apidApigeeSync/blob/655b66d3ded76155c155649c401cc9ac0fbf3969/data.go#L56-L85 |
154,206 | matrix-org/dugong | fshook.go | NewFSHook | func NewFSHook(path string, formatter log.Formatter, rotSched RotationScheduler) log.Hook {
if formatter == nil {
formatter = &log.JSONFormatter{}
}
hook := &fsHook{
entries: make(chan log.Entry, 1024),
path: path,
formatter: formatter,
scheduler: rotSched,
}
go func() {
for entry := range hook.entries {
if err := hook.writeEntry(&entry); err != nil {
fmt.Fprintf(os.Stderr, "Error writing to logfile: %v\n", err)
}
atomic.AddInt32(&hook.queueSize, -1)
}
}()
return hook
} | go | func NewFSHook(path string, formatter log.Formatter, rotSched RotationScheduler) log.Hook {
if formatter == nil {
formatter = &log.JSONFormatter{}
}
hook := &fsHook{
entries: make(chan log.Entry, 1024),
path: path,
formatter: formatter,
scheduler: rotSched,
}
go func() {
for entry := range hook.entries {
if err := hook.writeEntry(&entry); err != nil {
fmt.Fprintf(os.Stderr, "Error writing to logfile: %v\n", err)
}
atomic.AddInt32(&hook.queueSize, -1)
}
}()
return hook
} | [
"func",
"NewFSHook",
"(",
"path",
"string",
",",
"formatter",
"log",
".",
"Formatter",
",",
"rotSched",
"RotationScheduler",
")",
"log",
".",
"Hook",
"{",
"if",
"formatter",
"==",
"nil",
"{",
"formatter",
"=",
"&",
"log",
".",
"JSONFormatter",
"{",
"}",
... | // NewFSHook makes a logging hook that writes formatted
// log entries to info, warn and error log files. Each log file
// contains the messages with that severity or higher. If a formatter is
// not specified, they will be logged using a JSON formatter. If a
// RotationScheduler is set, the files will be cycled according to its rules. | [
"NewFSHook",
"makes",
"a",
"logging",
"hook",
"that",
"writes",
"formatted",
"log",
"entries",
"to",
"info",
"warn",
"and",
"error",
"log",
"files",
".",
"Each",
"log",
"file",
"contains",
"the",
"messages",
"with",
"that",
"severity",
"or",
"higher",
".",
... | 51a565b5666b107eca8a1b48d5a751dd2491b02b | https://github.com/matrix-org/dugong/blob/51a565b5666b107eca8a1b48d5a751dd2491b02b/fshook.go#L75-L96 |
154,207 | matrix-org/dugong | fshook.go | rotate | func (hook *fsHook) rotate(suffix string, gzip bool) error {
logFilePath := hook.path + suffix
if err := os.Rename(hook.path, logFilePath); err != nil {
// e.g. because there were no errors in error.log for this day
fmt.Fprintf(os.Stderr, "Error rotating file %s: %v\n", hook.path, err)
} else if gzip {
// Don't try to gzip if we failed to rotate
if err := gzipFile(logFilePath); err != nil {
fmt.Fprintf(os.Stderr, "Failed to gzip file %s: %v\n", logFilePath, err)
}
}
return nil
} | go | func (hook *fsHook) rotate(suffix string, gzip bool) error {
logFilePath := hook.path + suffix
if err := os.Rename(hook.path, logFilePath); err != nil {
// e.g. because there were no errors in error.log for this day
fmt.Fprintf(os.Stderr, "Error rotating file %s: %v\n", hook.path, err)
} else if gzip {
// Don't try to gzip if we failed to rotate
if err := gzipFile(logFilePath); err != nil {
fmt.Fprintf(os.Stderr, "Failed to gzip file %s: %v\n", logFilePath, err)
}
}
return nil
} | [
"func",
"(",
"hook",
"*",
"fsHook",
")",
"rotate",
"(",
"suffix",
"string",
",",
"gzip",
"bool",
")",
"error",
"{",
"logFilePath",
":=",
"hook",
".",
"path",
"+",
"suffix",
"\n",
"if",
"err",
":=",
"os",
".",
"Rename",
"(",
"hook",
".",
"path",
","... | // rotate all the log files to the given suffix.
// If error path is "err.log" and suffix is "1" then move
// the contents to "err.log1".
// This requires no locking as the goroutine calling this is the same
// one which does the logging. Since we don't hold open a handle to the
// file when writing, a simple Rename is all that is required. | [
"rotate",
"all",
"the",
"log",
"files",
"to",
"the",
"given",
"suffix",
".",
"If",
"error",
"path",
"is",
"err",
".",
"log",
"and",
"suffix",
"is",
"1",
"then",
"move",
"the",
"contents",
"to",
"err",
".",
"log1",
".",
"This",
"requires",
"no",
"lock... | 51a565b5666b107eca8a1b48d5a751dd2491b02b | https://github.com/matrix-org/dugong/blob/51a565b5666b107eca8a1b48d5a751dd2491b02b/fshook.go#L150-L162 |
154,208 | rdwilliamson/aws | glacier/vault.go | GetVaultNotifications | func (c *Connection) GetVaultNotifications(name string) (*Notifications, error) {
// Build request.
var results Notifications
request, err := http.NewRequest("GET", c.vault(name)+"/notification-configuration", nil)
if err != nil {
return nil, err
}
request.Header.Add("x-amz-glacier-version", "2012-06-01")
c.Signature.Sign(request, nil)
// Perform request.
response, err := c.client().Do(request)
if err != nil {
return nil, err
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
return nil, aws.ParseError(response)
}
// Parse success response.
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return nil, err
}
err = json.Unmarshal(body, &results)
if err != nil {
return nil, err
}
return &results, nil
} | go | func (c *Connection) GetVaultNotifications(name string) (*Notifications, error) {
// Build request.
var results Notifications
request, err := http.NewRequest("GET", c.vault(name)+"/notification-configuration", nil)
if err != nil {
return nil, err
}
request.Header.Add("x-amz-glacier-version", "2012-06-01")
c.Signature.Sign(request, nil)
// Perform request.
response, err := c.client().Do(request)
if err != nil {
return nil, err
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
return nil, aws.ParseError(response)
}
// Parse success response.
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return nil, err
}
err = json.Unmarshal(body, &results)
if err != nil {
return nil, err
}
return &results, nil
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"GetVaultNotifications",
"(",
"name",
"string",
")",
"(",
"*",
"Notifications",
",",
"error",
")",
"{",
"// Build request.",
"var",
"results",
"Notifications",
"\n\n",
"request",
",",
"err",
":=",
"http",
".",
"NewRe... | // This operation retrieves the notification-configuration subresource set on
// the vault. If notification configuration for a vault is not set, the
// operation returns a 404 Not Found error. | [
"This",
"operation",
"retrieves",
"the",
"notification",
"-",
"configuration",
"subresource",
"set",
"on",
"the",
"vault",
".",
"If",
"notification",
"configuration",
"for",
"a",
"vault",
"is",
"not",
"set",
"the",
"operation",
"returns",
"a",
"404",
"Not",
"F... | 54608bb65939fc94439865d46598a57f7f15fb0e | https://github.com/rdwilliamson/aws/blob/54608bb65939fc94439865d46598a57f7f15fb0e/glacier/vault.go#L318-L353 |
154,209 | rdwilliamson/aws | glacier/policy.go | ToDataRetrievalPolicy | func ToDataRetrievalPolicy(strategy string) DataRetrievalPolicy {
if result, ok := toDataRetrievalPolicy[strategy]; ok {
return result
}
return toDataRetrievalPolicy[strings.ToLower(strings.Join(strings.Fields(strategy), ""))]
} | go | func ToDataRetrievalPolicy(strategy string) DataRetrievalPolicy {
if result, ok := toDataRetrievalPolicy[strategy]; ok {
return result
}
return toDataRetrievalPolicy[strings.ToLower(strings.Join(strings.Fields(strategy), ""))]
} | [
"func",
"ToDataRetrievalPolicy",
"(",
"strategy",
"string",
")",
"DataRetrievalPolicy",
"{",
"if",
"result",
",",
"ok",
":=",
"toDataRetrievalPolicy",
"[",
"strategy",
"]",
";",
"ok",
"{",
"return",
"result",
"\n",
"}",
"\n",
"return",
"toDataRetrievalPolicy",
"... | // ToDataRetrievalPolicy tries to converts a string to a DataRetrievalPolicy. | [
"ToDataRetrievalPolicy",
"tries",
"to",
"converts",
"a",
"string",
"to",
"a",
"DataRetrievalPolicy",
"."
] | 54608bb65939fc94439865d46598a57f7f15fb0e | https://github.com/rdwilliamson/aws/blob/54608bb65939fc94439865d46598a57f7f15fb0e/glacier/policy.go#L120-L125 |
154,210 | rdwilliamson/aws | glacier/policy.go | SetRetrievalPolicy | func (c *Connection) SetRetrievalPolicy(drp DataRetrievalPolicy, bytesPerHour int) error {
// Build request.
var rules dataRetrievalPolicy
rules.Policy.Rules[0].Strategy = drp.String()
if bytesPerHour != 0 {
rules.Policy.Rules[0].BytesPerHour = &bytesPerHour
}
data, err := json.Marshal(rules)
if err != nil {
return err
}
reader := bytes.NewReader(data)
request, err := http.NewRequest("PUT", c.policy("data-retrieval"), reader)
if err != nil {
return err
}
request.Header.Add("x-amz-glacier-version", "2012-06-01")
c.Signature.Sign(request, aws.ReadSeekerPayload(reader))
// Perform request.
response, err := c.client().Do(request)
if err != nil {
return err
}
defer response.Body.Close()
if response.StatusCode != http.StatusNoContent {
return aws.ParseError(response)
}
io.Copy(ioutil.Discard, response.Body)
// Parse success response.
return nil
} | go | func (c *Connection) SetRetrievalPolicy(drp DataRetrievalPolicy, bytesPerHour int) error {
// Build request.
var rules dataRetrievalPolicy
rules.Policy.Rules[0].Strategy = drp.String()
if bytesPerHour != 0 {
rules.Policy.Rules[0].BytesPerHour = &bytesPerHour
}
data, err := json.Marshal(rules)
if err != nil {
return err
}
reader := bytes.NewReader(data)
request, err := http.NewRequest("PUT", c.policy("data-retrieval"), reader)
if err != nil {
return err
}
request.Header.Add("x-amz-glacier-version", "2012-06-01")
c.Signature.Sign(request, aws.ReadSeekerPayload(reader))
// Perform request.
response, err := c.client().Do(request)
if err != nil {
return err
}
defer response.Body.Close()
if response.StatusCode != http.StatusNoContent {
return aws.ParseError(response)
}
io.Copy(ioutil.Discard, response.Body)
// Parse success response.
return nil
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"SetRetrievalPolicy",
"(",
"drp",
"DataRetrievalPolicy",
",",
"bytesPerHour",
"int",
")",
"error",
"{",
"// Build request.",
"var",
"rules",
"dataRetrievalPolicy",
"\n",
"rules",
".",
"Policy",
".",
"Rules",
"[",
"0",
... | // This operation sets and then enacts a data retrieval policy.
//
// You can set one policy per region for an AWS account. The policy is enacted
// within a few minutes of a successful call.
//
// The set policy operation does not affect retrieval jobs that were in progress
// before the policy was enacted. For more information about data retrieval
// policies, see DataRetrievalPolicy. | [
"This",
"operation",
"sets",
"and",
"then",
"enacts",
"a",
"data",
"retrieval",
"policy",
".",
"You",
"can",
"set",
"one",
"policy",
"per",
"region",
"for",
"an",
"AWS",
"account",
".",
"The",
"policy",
"is",
"enacted",
"within",
"a",
"few",
"minutes",
"... | 54608bb65939fc94439865d46598a57f7f15fb0e | https://github.com/rdwilliamson/aws/blob/54608bb65939fc94439865d46598a57f7f15fb0e/glacier/policy.go#L188-L224 |
154,211 | matiaskorhonen/ftp2s3 | s3driver/s3driver.go | Authenticate | func (d *S3Driver) Authenticate(username string, password string) bool {
return username == d.Username && password == d.Password
} | go | func (d *S3Driver) Authenticate(username string, password string) bool {
return username == d.Username && password == d.Password
} | [
"func",
"(",
"d",
"*",
"S3Driver",
")",
"Authenticate",
"(",
"username",
"string",
",",
"password",
"string",
")",
"bool",
"{",
"return",
"username",
"==",
"d",
".",
"Username",
"&&",
"password",
"==",
"d",
".",
"Password",
"\n",
"}"
] | // Authenticate checks that the FTP username and password match | [
"Authenticate",
"checks",
"that",
"the",
"FTP",
"username",
"and",
"password",
"match"
] | 0d4cdc42ba21902bba76f7fed9f596e203532bc7 | https://github.com/matiaskorhonen/ftp2s3/blob/0d4cdc42ba21902bba76f7fed9f596e203532bc7/s3driver/s3driver.go#L80-L82 |
154,212 | matiaskorhonen/ftp2s3 | s3driver/s3driver.go | Bytes | func (d *S3Driver) Bytes(path string) int64 {
svc := d.s3service()
path = strings.TrimPrefix(path, "/")
params := &s3.HeadObjectInput{
Bucket: aws.String(d.AWSBucketName), // Required
Key: aws.String(path), // Required
}
resp, err := svc.HeadObject(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
return -1
} else if err != nil {
// A non-service error occurred.
panic(err)
return -1
}
return *resp.ContentLength
} | go | func (d *S3Driver) Bytes(path string) int64 {
svc := d.s3service()
path = strings.TrimPrefix(path, "/")
params := &s3.HeadObjectInput{
Bucket: aws.String(d.AWSBucketName), // Required
Key: aws.String(path), // Required
}
resp, err := svc.HeadObject(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
return -1
} else if err != nil {
// A non-service error occurred.
panic(err)
return -1
}
return *resp.ContentLength
} | [
"func",
"(",
"d",
"*",
"S3Driver",
")",
"Bytes",
"(",
"path",
"string",
")",
"int64",
"{",
"svc",
":=",
"d",
".",
"s3service",
"(",
")",
"\n\n",
"path",
"=",
"strings",
".",
"TrimPrefix",
"(",
"path",
",",
"\"",
"\"",
")",
"\n\n",
"params",
":=",
... | // Bytes returns the ContentLength for the path if the key exists | [
"Bytes",
"returns",
"the",
"ContentLength",
"for",
"the",
"path",
"if",
"the",
"key",
"exists"
] | 0d4cdc42ba21902bba76f7fed9f596e203532bc7 | https://github.com/matiaskorhonen/ftp2s3/blob/0d4cdc42ba21902bba76f7fed9f596e203532bc7/s3driver/s3driver.go#L85-L107 |
154,213 | matiaskorhonen/ftp2s3 | s3driver/s3driver.go | ModifiedTime | func (d *S3Driver) ModifiedTime(path string) (time.Time, bool) {
svc := d.s3service()
path = strings.TrimPrefix(path, "/")
params := &s3.HeadObjectInput{
Bucket: aws.String(d.AWSBucketName), // Required
Key: aws.String(path), // Required
}
resp, err := svc.HeadObject(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
return time.Now(), false
} else if err != nil {
// A non-service error occurred.
panic(err)
return time.Now(), false
}
return *resp.LastModified, true
} | go | func (d *S3Driver) ModifiedTime(path string) (time.Time, bool) {
svc := d.s3service()
path = strings.TrimPrefix(path, "/")
params := &s3.HeadObjectInput{
Bucket: aws.String(d.AWSBucketName), // Required
Key: aws.String(path), // Required
}
resp, err := svc.HeadObject(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
return time.Now(), false
} else if err != nil {
// A non-service error occurred.
panic(err)
return time.Now(), false
}
return *resp.LastModified, true
} | [
"func",
"(",
"d",
"*",
"S3Driver",
")",
"ModifiedTime",
"(",
"path",
"string",
")",
"(",
"time",
".",
"Time",
",",
"bool",
")",
"{",
"svc",
":=",
"d",
".",
"s3service",
"(",
")",
"\n\n",
"path",
"=",
"strings",
".",
"TrimPrefix",
"(",
"path",
",",
... | // ModifiedTime returns the LastModifiedTime for the path if the key exists | [
"ModifiedTime",
"returns",
"the",
"LastModifiedTime",
"for",
"the",
"path",
"if",
"the",
"key",
"exists"
] | 0d4cdc42ba21902bba76f7fed9f596e203532bc7 | https://github.com/matiaskorhonen/ftp2s3/blob/0d4cdc42ba21902bba76f7fed9f596e203532bc7/s3driver/s3driver.go#L110-L132 |
154,214 | matiaskorhonen/ftp2s3 | s3driver/s3driver.go | DeleteFile | func (d *S3Driver) DeleteFile(path string) bool {
svc := d.s3service()
path = strings.TrimPrefix(path, "/")
params := &s3.DeleteObjectInput{
Bucket: aws.String(d.AWSBucketName), // Required
Key: aws.String(path), // Required
}
_, err := svc.DeleteObject(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
return false
} else if err != nil {
// A non-service error occurred.
panic(err)
return false
}
return true
} | go | func (d *S3Driver) DeleteFile(path string) bool {
svc := d.s3service()
path = strings.TrimPrefix(path, "/")
params := &s3.DeleteObjectInput{
Bucket: aws.String(d.AWSBucketName), // Required
Key: aws.String(path), // Required
}
_, err := svc.DeleteObject(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
return false
} else if err != nil {
// A non-service error occurred.
panic(err)
return false
}
return true
} | [
"func",
"(",
"d",
"*",
"S3Driver",
")",
"DeleteFile",
"(",
"path",
"string",
")",
"bool",
"{",
"svc",
":=",
"d",
".",
"s3service",
"(",
")",
"\n",
"path",
"=",
"strings",
".",
"TrimPrefix",
"(",
"path",
",",
"\"",
"\"",
")",
"\n\n",
"params",
":=",... | // DeleteFile deletes the files from the given path | [
"DeleteFile",
"deletes",
"the",
"files",
"from",
"the",
"given",
"path"
] | 0d4cdc42ba21902bba76f7fed9f596e203532bc7 | https://github.com/matiaskorhonen/ftp2s3/blob/0d4cdc42ba21902bba76f7fed9f596e203532bc7/s3driver/s3driver.go#L222-L243 |
154,215 | matiaskorhonen/ftp2s3 | s3driver/s3driver.go | GetFile | func (d *S3Driver) GetFile(path string, position int64) (io.ReadCloser, bool) {
svc := d.s3service()
path = strings.TrimPrefix(path, "/")
params := &s3.GetObjectInput{
Bucket: aws.String(d.AWSBucketName), // Required
Key: aws.String(path), // Required
}
resp, err := svc.GetObject(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
return nil, false
} else if err != nil {
// A non-service error occurred.
panic(err)
return nil, false
}
return resp.Body, true
} | go | func (d *S3Driver) GetFile(path string, position int64) (io.ReadCloser, bool) {
svc := d.s3service()
path = strings.TrimPrefix(path, "/")
params := &s3.GetObjectInput{
Bucket: aws.String(d.AWSBucketName), // Required
Key: aws.String(path), // Required
}
resp, err := svc.GetObject(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
return nil, false
} else if err != nil {
// A non-service error occurred.
panic(err)
return nil, false
}
return resp.Body, true
} | [
"func",
"(",
"d",
"*",
"S3Driver",
")",
"GetFile",
"(",
"path",
"string",
",",
"position",
"int64",
")",
"(",
"io",
".",
"ReadCloser",
",",
"bool",
")",
"{",
"svc",
":=",
"d",
".",
"s3service",
"(",
")",
"\n\n",
"path",
"=",
"strings",
".",
"TrimPr... | // GetFile returns a reader for the given path on S3 | [
"GetFile",
"returns",
"a",
"reader",
"for",
"the",
"given",
"path",
"on",
"S3"
] | 0d4cdc42ba21902bba76f7fed9f596e203532bc7 | https://github.com/matiaskorhonen/ftp2s3/blob/0d4cdc42ba21902bba76f7fed9f596e203532bc7/s3driver/s3driver.go#L256-L278 |
154,216 | matiaskorhonen/ftp2s3 | s3driver/s3driver.go | PutFile | func (d *S3Driver) PutFile(path string, reader io.Reader) bool {
svc := d.s3service()
fmt.Println("put path: ", path)
fmt.Println("wd: ", d.WorkingDirectory)
if strings.HasPrefix(path, "/") {
path = strings.TrimPrefix(path, "/")
} else {
path = d.WorkingDirectory + path
}
fileExt := filepath.Ext(path)
contentType := mime.TypeByExtension(fileExt)
if contentType == "" {
contentType = "application/octet-stream"
}
buf := new(bytes.Buffer)
buf.ReadFrom(reader)
params := &s3.PutObjectInput{
Bucket: aws.String(d.AWSBucketName), // Required
Key: aws.String(path), // Required
Body: bytes.NewReader(buf.Bytes()),
ContentType: aws.String(contentType),
}
resp, err := svc.PutObject(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
return false
} else if err != nil {
// A non-service error occurred.
panic(err)
return false
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
return true
} | go | func (d *S3Driver) PutFile(path string, reader io.Reader) bool {
svc := d.s3service()
fmt.Println("put path: ", path)
fmt.Println("wd: ", d.WorkingDirectory)
if strings.HasPrefix(path, "/") {
path = strings.TrimPrefix(path, "/")
} else {
path = d.WorkingDirectory + path
}
fileExt := filepath.Ext(path)
contentType := mime.TypeByExtension(fileExt)
if contentType == "" {
contentType = "application/octet-stream"
}
buf := new(bytes.Buffer)
buf.ReadFrom(reader)
params := &s3.PutObjectInput{
Bucket: aws.String(d.AWSBucketName), // Required
Key: aws.String(path), // Required
Body: bytes.NewReader(buf.Bytes()),
ContentType: aws.String(contentType),
}
resp, err := svc.PutObject(params)
if awserr := aws.Error(err); awserr != nil {
// A service error occurred.
fmt.Println("Error:", awserr.Code, awserr.Message)
return false
} else if err != nil {
// A non-service error occurred.
panic(err)
return false
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
return true
} | [
"func",
"(",
"d",
"*",
"S3Driver",
")",
"PutFile",
"(",
"path",
"string",
",",
"reader",
"io",
".",
"Reader",
")",
"bool",
"{",
"svc",
":=",
"d",
".",
"s3service",
"(",
")",
"\n\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"path",
")",
"\n",
... | // PutFile uploads a file to S3 | [
"PutFile",
"uploads",
"a",
"file",
"to",
"S3"
] | 0d4cdc42ba21902bba76f7fed9f596e203532bc7 | https://github.com/matiaskorhonen/ftp2s3/blob/0d4cdc42ba21902bba76f7fed9f596e203532bc7/s3driver/s3driver.go#L281-L325 |
154,217 | keybase/go-triplesec | triplesec.go | NewCipher | func NewCipher(passphrase []byte, salt []byte, version Version) (*Cipher, error) {
return NewCipherWithRng(passphrase, salt, version, NewCryptoRandGenerator())
} | go | func NewCipher(passphrase []byte, salt []byte, version Version) (*Cipher, error) {
return NewCipherWithRng(passphrase, salt, version, NewCryptoRandGenerator())
} | [
"func",
"NewCipher",
"(",
"passphrase",
"[",
"]",
"byte",
",",
"salt",
"[",
"]",
"byte",
",",
"version",
"Version",
")",
"(",
"*",
"Cipher",
",",
"error",
")",
"{",
"return",
"NewCipherWithRng",
"(",
"passphrase",
",",
"salt",
",",
"version",
",",
"New... | // NewCipher makes an instance of TripleSec using a particular key and
// a particular salt | [
"NewCipher",
"makes",
"an",
"instance",
"of",
"TripleSec",
"using",
"a",
"particular",
"key",
"and",
"a",
"particular",
"salt"
] | bbc0310f629a582cf83c31389b4109e8e2b4c6c9 | https://github.com/keybase/go-triplesec/blob/bbc0310f629a582cf83c31389b4109e8e2b4c6c9/triplesec.go#L123-L125 |
154,218 | keybase/go-triplesec | triplesec.go | NewCipherWithRng | func NewCipherWithRng(passphrase []byte, salt []byte, version Version, rng RandomnessGenerator) (*Cipher, error) {
if salt != nil && len(salt) != SaltLen {
return nil, fmt.Errorf("Need a salt of size %d", SaltLen)
}
var versionParams VersionParams
var ok bool
if versionParams, ok = versionParamsLookup[version]; !ok {
return nil, fmt.Errorf("Not a valid version")
}
return &Cipher{passphrase, salt, nil, versionParams, rng}, nil
} | go | func NewCipherWithRng(passphrase []byte, salt []byte, version Version, rng RandomnessGenerator) (*Cipher, error) {
if salt != nil && len(salt) != SaltLen {
return nil, fmt.Errorf("Need a salt of size %d", SaltLen)
}
var versionParams VersionParams
var ok bool
if versionParams, ok = versionParamsLookup[version]; !ok {
return nil, fmt.Errorf("Not a valid version")
}
return &Cipher{passphrase, salt, nil, versionParams, rng}, nil
} | [
"func",
"NewCipherWithRng",
"(",
"passphrase",
"[",
"]",
"byte",
",",
"salt",
"[",
"]",
"byte",
",",
"version",
"Version",
",",
"rng",
"RandomnessGenerator",
")",
"(",
"*",
"Cipher",
",",
"error",
")",
"{",
"if",
"salt",
"!=",
"nil",
"&&",
"len",
"(",
... | // NewCipherWithRng makes an instance of TripleSec using a particular key and
// a particular salt and uses a given randomness stream | [
"NewCipherWithRng",
"makes",
"an",
"instance",
"of",
"TripleSec",
"using",
"a",
"particular",
"key",
"and",
"a",
"particular",
"salt",
"and",
"uses",
"a",
"given",
"randomness",
"stream"
] | bbc0310f629a582cf83c31389b4109e8e2b4c6c9 | https://github.com/keybase/go-triplesec/blob/bbc0310f629a582cf83c31389b4109e8e2b4c6c9/triplesec.go#L129-L139 |
154,219 | jsccast/tinygraph | steps.go | launch | func (g *Graph) launch(c *Chan, at Triple, ss []*Stepper) {
g.step(c, Path{at}, ss)
select {
case <-c.done:
default:
(*c).c <- nil
}
} | go | func (g *Graph) launch(c *Chan, at Triple, ss []*Stepper) {
g.step(c, Path{at}, ss)
select {
case <-c.done:
default:
(*c).c <- nil
}
} | [
"func",
"(",
"g",
"*",
"Graph",
")",
"launch",
"(",
"c",
"*",
"Chan",
",",
"at",
"Triple",
",",
"ss",
"[",
"]",
"*",
"Stepper",
")",
"{",
"g",
".",
"step",
"(",
"c",
",",
"Path",
"{",
"at",
"}",
",",
"ss",
")",
"\n",
"select",
"{",
"case",
... | // Start walking. | [
"Start",
"walking",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L73-L80 |
154,220 | jsccast/tinygraph | steps.go | Out | func Out(p []byte) *Stepper {
return &Stepper{OPS, SPO, SPO, Triple{nil, p, nil, nil}, nil, make([]func(Path), 0, 0), nil}
} | go | func Out(p []byte) *Stepper {
return &Stepper{OPS, SPO, SPO, Triple{nil, p, nil, nil}, nil, make([]func(Path), 0, 0), nil}
} | [
"func",
"Out",
"(",
"p",
"[",
"]",
"byte",
")",
"*",
"Stepper",
"{",
"return",
"&",
"Stepper",
"{",
"OPS",
",",
"SPO",
",",
"SPO",
",",
"Triple",
"{",
"nil",
",",
"p",
",",
"nil",
",",
"nil",
"}",
",",
"nil",
",",
"make",
"(",
"[",
"]",
"fu... | // Out returns a Stepper that traverses all edges out of the Stepper's input verticies. | [
"Out",
"returns",
"a",
"Stepper",
"that",
"traverses",
"all",
"edges",
"out",
"of",
"the",
"Stepper",
"s",
"input",
"verticies",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L138-L140 |
154,221 | jsccast/tinygraph | steps.go | Out | func (s *Stepper) Out(p []byte) *Stepper {
next := Out(p)
next.previous = s
return next
} | go | func (s *Stepper) Out(p []byte) *Stepper {
next := Out(p)
next.previous = s
return next
} | [
"func",
"(",
"s",
"*",
"Stepper",
")",
"Out",
"(",
"p",
"[",
"]",
"byte",
")",
"*",
"Stepper",
"{",
"next",
":=",
"Out",
"(",
"p",
")",
"\n",
"next",
".",
"previous",
"=",
"s",
"\n",
"return",
"next",
"\n",
"}"
] | // Out extends the stepper to follow out-bound edges with the given property. | [
"Out",
"extends",
"the",
"stepper",
"to",
"follow",
"out",
"-",
"bound",
"edges",
"with",
"the",
"given",
"property",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L143-L147 |
154,222 | jsccast/tinygraph | steps.go | AllOut | func AllOut() *Stepper {
return &Stepper{OPS, SPO, SPO, Triple{nil, nil, nil, nil}, nil, make([]func(Path), 0, 0), nil}
} | go | func AllOut() *Stepper {
return &Stepper{OPS, SPO, SPO, Triple{nil, nil, nil, nil}, nil, make([]func(Path), 0, 0), nil}
} | [
"func",
"AllOut",
"(",
")",
"*",
"Stepper",
"{",
"return",
"&",
"Stepper",
"{",
"OPS",
",",
"SPO",
",",
"SPO",
",",
"Triple",
"{",
"nil",
",",
"nil",
",",
"nil",
",",
"nil",
"}",
",",
"nil",
",",
"make",
"(",
"[",
"]",
"func",
"(",
"Path",
")... | // AllOut returns a Stepper that traverses all out-bound edges. | [
"AllOut",
"returns",
"a",
"Stepper",
"that",
"traverses",
"all",
"out",
"-",
"bound",
"edges",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L150-L152 |
154,223 | jsccast/tinygraph | steps.go | AllOut | func (s *Stepper) AllOut() *Stepper {
next := AllOut()
next.previous = s
return next
} | go | func (s *Stepper) AllOut() *Stepper {
next := AllOut()
next.previous = s
return next
} | [
"func",
"(",
"s",
"*",
"Stepper",
")",
"AllOut",
"(",
")",
"*",
"Stepper",
"{",
"next",
":=",
"AllOut",
"(",
")",
"\n",
"next",
".",
"previous",
"=",
"s",
"\n",
"return",
"next",
"\n",
"}"
] | // AllOut extends the stepper to follow all edges. | [
"AllOut",
"extends",
"the",
"stepper",
"to",
"follow",
"all",
"edges",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L155-L159 |
154,224 | jsccast/tinygraph | steps.go | In | func In(p []byte) *Stepper {
return &Stepper{OPS, OPS, OPS, Triple{nil, p, nil, nil}, nil, make([]func(Path), 0, 0), nil}
} | go | func In(p []byte) *Stepper {
return &Stepper{OPS, OPS, OPS, Triple{nil, p, nil, nil}, nil, make([]func(Path), 0, 0), nil}
} | [
"func",
"In",
"(",
"p",
"[",
"]",
"byte",
")",
"*",
"Stepper",
"{",
"return",
"&",
"Stepper",
"{",
"OPS",
",",
"OPS",
",",
"OPS",
",",
"Triple",
"{",
"nil",
",",
"p",
",",
"nil",
",",
"nil",
"}",
",",
"nil",
",",
"make",
"(",
"[",
"]",
"fun... | // In returns a Stepper that traverses all edges into of the Stepper's input verticies. | [
"In",
"returns",
"a",
"Stepper",
"that",
"traverses",
"all",
"edges",
"into",
"of",
"the",
"Stepper",
"s",
"input",
"verticies",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L162-L164 |
154,225 | jsccast/tinygraph | steps.go | In | func (s *Stepper) In(p []byte) *Stepper {
next := In(p)
next.previous = s
return next
} | go | func (s *Stepper) In(p []byte) *Stepper {
next := In(p)
next.previous = s
return next
} | [
"func",
"(",
"s",
"*",
"Stepper",
")",
"In",
"(",
"p",
"[",
"]",
"byte",
")",
"*",
"Stepper",
"{",
"next",
":=",
"In",
"(",
"p",
")",
"\n",
"next",
".",
"previous",
"=",
"s",
"\n",
"return",
"next",
"\n",
"}"
] | // In extends the stepper to follow all in-bound edges with the given property. | [
"In",
"extends",
"the",
"stepper",
"to",
"follow",
"all",
"in",
"-",
"bound",
"edges",
"with",
"the",
"given",
"property",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L167-L171 |
154,226 | jsccast/tinygraph | steps.go | AllIn | func AllIn() *Stepper {
return &Stepper{OPS, OPS, OPS, Triple{nil, nil, nil, nil}, nil, make([]func(Path), 0, 0), nil}
} | go | func AllIn() *Stepper {
return &Stepper{OPS, OPS, OPS, Triple{nil, nil, nil, nil}, nil, make([]func(Path), 0, 0), nil}
} | [
"func",
"AllIn",
"(",
")",
"*",
"Stepper",
"{",
"return",
"&",
"Stepper",
"{",
"OPS",
",",
"OPS",
",",
"OPS",
",",
"Triple",
"{",
"nil",
",",
"nil",
",",
"nil",
",",
"nil",
"}",
",",
"nil",
",",
"make",
"(",
"[",
"]",
"func",
"(",
"Path",
")"... | // AllIn returns a Stepper that traverses all in-bound edges. | [
"AllIn",
"returns",
"a",
"Stepper",
"that",
"traverses",
"all",
"in",
"-",
"bound",
"edges",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L174-L176 |
154,227 | jsccast/tinygraph | steps.go | AllIn | func (s *Stepper) AllIn() *Stepper {
next := AllIn()
next.previous = s
return next
} | go | func (s *Stepper) AllIn() *Stepper {
next := AllIn()
next.previous = s
return next
} | [
"func",
"(",
"s",
"*",
"Stepper",
")",
"AllIn",
"(",
")",
"*",
"Stepper",
"{",
"next",
":=",
"AllIn",
"(",
")",
"\n",
"next",
".",
"previous",
"=",
"s",
"\n",
"return",
"next",
"\n",
"}"
] | // AllIn extends the stepper to follow all in-bound edges. | [
"AllIn",
"extends",
"the",
"stepper",
"to",
"follow",
"all",
"in",
"-",
"bound",
"edges",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L179-L183 |
154,228 | jsccast/tinygraph | steps.go | Has | func Has(pred func(Triple) bool) *Stepper {
return &Stepper{SPO, SPO, SPO, Triple{}, pred, make([]func(Path), 0, 0), nil}
} | go | func Has(pred func(Triple) bool) *Stepper {
return &Stepper{SPO, SPO, SPO, Triple{}, pred, make([]func(Path), 0, 0), nil}
} | [
"func",
"Has",
"(",
"pred",
"func",
"(",
"Triple",
")",
"bool",
")",
"*",
"Stepper",
"{",
"return",
"&",
"Stepper",
"{",
"SPO",
",",
"SPO",
",",
"SPO",
",",
"Triple",
"{",
"}",
",",
"pred",
",",
"make",
"(",
"[",
"]",
"func",
"(",
"Path",
")",
... | // Has returns a stepper that will follow edges for which pred returns true. | [
"Has",
"returns",
"a",
"stepper",
"that",
"will",
"follow",
"edges",
"for",
"which",
"pred",
"returns",
"true",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L186-L188 |
154,229 | jsccast/tinygraph | steps.go | Has | func (s *Stepper) Has(pred func(Triple) bool) *Stepper {
next := Has(pred)
next.previous = s
return next
} | go | func (s *Stepper) Has(pred func(Triple) bool) *Stepper {
next := Has(pred)
next.previous = s
return next
} | [
"func",
"(",
"s",
"*",
"Stepper",
")",
"Has",
"(",
"pred",
"func",
"(",
"Triple",
")",
"bool",
")",
"*",
"Stepper",
"{",
"next",
":=",
"Has",
"(",
"pred",
")",
"\n",
"next",
".",
"previous",
"=",
"s",
"\n",
"return",
"next",
"\n",
"}"
] | // Has extends a stepper to will follow edges for which pred returns true. | [
"Has",
"extends",
"a",
"stepper",
"to",
"will",
"follow",
"edges",
"for",
"which",
"pred",
"returns",
"true",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L191-L195 |
154,230 | jsccast/tinygraph | steps.go | Do | func (s *Stepper) Do(f func(Path)) *Stepper {
s.fs = append(s.fs, f)
return s
} | go | func (s *Stepper) Do(f func(Path)) *Stepper {
s.fs = append(s.fs, f)
return s
} | [
"func",
"(",
"s",
"*",
"Stepper",
")",
"Do",
"(",
"f",
"func",
"(",
"Path",
")",
")",
"*",
"Stepper",
"{",
"s",
".",
"fs",
"=",
"append",
"(",
"s",
".",
"fs",
",",
"f",
")",
"\n",
"return",
"s",
"\n",
"}"
] | // Do extends a stepper to execute a the given function for the current path. | [
"Do",
"extends",
"a",
"stepper",
"to",
"execute",
"a",
"the",
"given",
"function",
"for",
"the",
"current",
"path",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L198-L201 |
154,231 | jsccast/tinygraph | steps.go | Walk | func (s *Stepper) Walk(g *Graph, from Vertex) *Chan {
at := s
ss := make([]*Stepper, 0, 1)
ss = append(ss, at)
for at.previous != nil {
ss = append([]*Stepper{at.previous}, ss...)
at = at.previous
}
return g.Walk(from, ss)
} | go | func (s *Stepper) Walk(g *Graph, from Vertex) *Chan {
at := s
ss := make([]*Stepper, 0, 1)
ss = append(ss, at)
for at.previous != nil {
ss = append([]*Stepper{at.previous}, ss...)
at = at.previous
}
return g.Walk(from, ss)
} | [
"func",
"(",
"s",
"*",
"Stepper",
")",
"Walk",
"(",
"g",
"*",
"Graph",
",",
"from",
"Vertex",
")",
"*",
"Chan",
"{",
"at",
":=",
"s",
"\n",
"ss",
":=",
"make",
"(",
"[",
"]",
"*",
"Stepper",
",",
"0",
",",
"1",
")",
"\n",
"ss",
"=",
"append... | // Walk starts the stepper at the given vertex. Returns a channel of paths. | [
"Walk",
"starts",
"the",
"stepper",
"at",
"the",
"given",
"vertex",
".",
"Returns",
"a",
"channel",
"of",
"paths",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L213-L222 |
154,232 | jsccast/tinygraph | steps.go | Do | func (c *Chan) Do(f func(Path)) {
defer c.Close()
for {
x := <-(*c).c
if x == nil {
break
}
f(x)
}
} | go | func (c *Chan) Do(f func(Path)) {
defer c.Close()
for {
x := <-(*c).c
if x == nil {
break
}
f(x)
}
} | [
"func",
"(",
"c",
"*",
"Chan",
")",
"Do",
"(",
"f",
"func",
"(",
"Path",
")",
")",
"{",
"defer",
"c",
".",
"Close",
"(",
")",
"\n",
"for",
"{",
"x",
":=",
"<-",
"(",
"*",
"c",
")",
".",
"c",
"\n",
"if",
"x",
"==",
"nil",
"{",
"break",
"... | // Do is a utility function to call the given function on every path from the channel. | [
"Do",
"is",
"a",
"utility",
"function",
"to",
"call",
"the",
"given",
"function",
"on",
"every",
"path",
"from",
"the",
"channel",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L225-L234 |
154,233 | jsccast/tinygraph | steps.go | DoSome | func (c *Chan) DoSome(f func(Path), limit int64) {
defer c.Close()
n := int64(0)
for {
x := <-(*c).c
if x == nil || n == limit {
break
}
f(x)
n++
}
} | go | func (c *Chan) DoSome(f func(Path), limit int64) {
defer c.Close()
n := int64(0)
for {
x := <-(*c).c
if x == nil || n == limit {
break
}
f(x)
n++
}
} | [
"func",
"(",
"c",
"*",
"Chan",
")",
"DoSome",
"(",
"f",
"func",
"(",
"Path",
")",
",",
"limit",
"int64",
")",
"{",
"defer",
"c",
".",
"Close",
"(",
")",
"\n",
"n",
":=",
"int64",
"(",
"0",
")",
"\n",
"for",
"{",
"x",
":=",
"<-",
"(",
"*",
... | // DoSome is a utility function to call the given function on paths
// from the channel at most 'limit' times. | [
"DoSome",
"is",
"a",
"utility",
"function",
"to",
"call",
"the",
"given",
"function",
"on",
"paths",
"from",
"the",
"channel",
"at",
"most",
"limit",
"times",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L238-L249 |
154,234 | jsccast/tinygraph | steps.go | Print | func (c *Chan) Print() {
c.Do(func(path Path) { fmt.Printf("path %s\n", path.String()) })
} | go | func (c *Chan) Print() {
c.Do(func(path Path) { fmt.Printf("path %s\n", path.String()) })
} | [
"func",
"(",
"c",
"*",
"Chan",
")",
"Print",
"(",
")",
"{",
"c",
".",
"Do",
"(",
"func",
"(",
"path",
"Path",
")",
"{",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"path",
".",
"String",
"(",
")",
")",
"}",
")",
"\n",
"}"
] | // Print is a utility function that prints every path from the channel. | [
"Print",
"is",
"a",
"utility",
"function",
"that",
"prints",
"every",
"path",
"from",
"the",
"channel",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L252-L254 |
154,235 | jsccast/tinygraph | steps.go | CollectSome | func (c *Chan) CollectSome(limit int64) []Path {
acc := make([]Path, 0, 0)
c.DoSome(func(ts Path) {
acc = append(acc, ts)
}, limit)
return acc
} | go | func (c *Chan) CollectSome(limit int64) []Path {
acc := make([]Path, 0, 0)
c.DoSome(func(ts Path) {
acc = append(acc, ts)
}, limit)
return acc
} | [
"func",
"(",
"c",
"*",
"Chan",
")",
"CollectSome",
"(",
"limit",
"int64",
")",
"[",
"]",
"Path",
"{",
"acc",
":=",
"make",
"(",
"[",
"]",
"Path",
",",
"0",
",",
"0",
")",
"\n",
"c",
".",
"DoSome",
"(",
"func",
"(",
"ts",
"Path",
")",
"{",
"... | // CollectSome is a utility function that gathers up at most 'limit'
// paths into an array. | [
"CollectSome",
"is",
"a",
"utility",
"function",
"that",
"gathers",
"up",
"at",
"most",
"limit",
"paths",
"into",
"an",
"array",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/steps.go#L268-L274 |
154,236 | jsccast/tinygraph | graph.go | NextVertex | func (i *VertexIterator) NextVertex() string {
bs, ok := i.Next()
if !ok {
return ""
}
return string(bs)
} | go | func (i *VertexIterator) NextVertex() string {
bs, ok := i.Next()
if !ok {
return ""
}
return string(bs)
} | [
"func",
"(",
"i",
"*",
"VertexIterator",
")",
"NextVertex",
"(",
")",
"string",
"{",
"bs",
",",
"ok",
":=",
"i",
".",
"Next",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"string",
"(",
"bs",
")",
"\n",... | // Really for Javscript. | [
"Really",
"for",
"Javscript",
"."
] | 72b309a39878d5618ba15fa102a6b5e906ddb43e | https://github.com/jsccast/tinygraph/blob/72b309a39878d5618ba15fa102a6b5e906ddb43e/graph.go#L378-L384 |
154,237 | lestrrat-go/ngram | index.go | IterateSimilar | func (i *Index) IterateSimilar(input string, min float64, limit int) <-chan MatchResult {
c := make(chan MatchResult)
go i.iterateSimilar(c, input, min, limit)
return c
} | go | func (i *Index) IterateSimilar(input string, min float64, limit int) <-chan MatchResult {
c := make(chan MatchResult)
go i.iterateSimilar(c, input, min, limit)
return c
} | [
"func",
"(",
"i",
"*",
"Index",
")",
"IterateSimilar",
"(",
"input",
"string",
",",
"min",
"float64",
",",
"limit",
"int",
")",
"<-",
"chan",
"MatchResult",
"{",
"c",
":=",
"make",
"(",
"chan",
"MatchResult",
")",
"\n",
"go",
"i",
".",
"iterateSimilar"... | // search for similar strings in index, sending the search results
// to the returned channel.
// you can specify the minimum score and the maximum items to be fetched | [
"search",
"for",
"similar",
"strings",
"in",
"index",
"sending",
"the",
"search",
"results",
"to",
"the",
"returned",
"channel",
".",
"you",
"can",
"specify",
"the",
"minimum",
"score",
"and",
"the",
"maximum",
"items",
"to",
"be",
"fetched"
] | adb5d38f67ccf4259f5ea3e29f286bbc1b1b7a8a | https://github.com/lestrrat-go/ngram/blob/adb5d38f67ccf4259f5ea3e29f286bbc1b1b7a8a/index.go#L144-L148 |
154,238 | cjgdev/goryman | client.go | Connect | func (c *GorymanClient) Connect() error {
udp, err := net.DialTimeout("udp", c.addr, time.Second*5)
if err != nil {
return err
}
tcp, err := net.DialTimeout("tcp", c.addr, time.Second*5)
if err != nil {
return err
}
c.udp = NewUdpTransport(udp)
c.tcp = NewTcpTransport(tcp)
return nil
} | go | func (c *GorymanClient) Connect() error {
udp, err := net.DialTimeout("udp", c.addr, time.Second*5)
if err != nil {
return err
}
tcp, err := net.DialTimeout("tcp", c.addr, time.Second*5)
if err != nil {
return err
}
c.udp = NewUdpTransport(udp)
c.tcp = NewTcpTransport(tcp)
return nil
} | [
"func",
"(",
"c",
"*",
"GorymanClient",
")",
"Connect",
"(",
")",
"error",
"{",
"udp",
",",
"err",
":=",
"net",
".",
"DialTimeout",
"(",
"\"",
"\"",
",",
"c",
".",
"addr",
",",
"time",
".",
"Second",
"*",
"5",
")",
"\n",
"if",
"err",
"!=",
"nil... | // Connect creates a UDP and TCP connection to a Riemann server | [
"Connect",
"creates",
"a",
"UDP",
"and",
"TCP",
"connection",
"to",
"a",
"Riemann",
"server"
] | 55c3cbc3df542201b3c140e72a758d0adae4bc05 | https://github.com/cjgdev/goryman/blob/55c3cbc3df542201b3c140e72a758d0adae4bc05/client.go#L30-L42 |
154,239 | cjgdev/goryman | client.go | Close | func (c *GorymanClient) Close() error {
if nil == c.udp && nil == c.tcp {
return nil
}
err := c.udp.Close()
if err != nil {
return err
}
return c.tcp.Close()
} | go | func (c *GorymanClient) Close() error {
if nil == c.udp && nil == c.tcp {
return nil
}
err := c.udp.Close()
if err != nil {
return err
}
return c.tcp.Close()
} | [
"func",
"(",
"c",
"*",
"GorymanClient",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"nil",
"==",
"c",
".",
"udp",
"&&",
"nil",
"==",
"c",
".",
"tcp",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"err",
":=",
"c",
".",
"udp",
".",
"Close",
"(",
")",... | // Close the connection to Riemann | [
"Close",
"the",
"connection",
"to",
"Riemann"
] | 55c3cbc3df542201b3c140e72a758d0adae4bc05 | https://github.com/cjgdev/goryman/blob/55c3cbc3df542201b3c140e72a758d0adae4bc05/client.go#L45-L54 |
154,240 | cjgdev/goryman | client.go | SendEvent | func (c *GorymanClient) SendEvent(e *Event) error {
epb, err := EventToProtocolBuffer(e)
if err != nil {
return err
}
message := &proto.Msg{}
message.Events = append(message.Events, epb)
_, err = c.sendMaybeRecv(message)
return err
} | go | func (c *GorymanClient) SendEvent(e *Event) error {
epb, err := EventToProtocolBuffer(e)
if err != nil {
return err
}
message := &proto.Msg{}
message.Events = append(message.Events, epb)
_, err = c.sendMaybeRecv(message)
return err
} | [
"func",
"(",
"c",
"*",
"GorymanClient",
")",
"SendEvent",
"(",
"e",
"*",
"Event",
")",
"error",
"{",
"epb",
",",
"err",
":=",
"EventToProtocolBuffer",
"(",
"e",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"message",
... | // Send an event | [
"Send",
"an",
"event"
] | 55c3cbc3df542201b3c140e72a758d0adae4bc05 | https://github.com/cjgdev/goryman/blob/55c3cbc3df542201b3c140e72a758d0adae4bc05/client.go#L57-L68 |
154,241 | cjgdev/goryman | client.go | SendState | func (c *GorymanClient) SendState(s *State) error {
spb, err := StateToProtocolBuffer(s)
if err != nil {
return err
}
message := &proto.Msg{}
message.States = append(message.States, spb)
_, err = c.sendMaybeRecv(message)
return err
} | go | func (c *GorymanClient) SendState(s *State) error {
spb, err := StateToProtocolBuffer(s)
if err != nil {
return err
}
message := &proto.Msg{}
message.States = append(message.States, spb)
_, err = c.sendMaybeRecv(message)
return err
} | [
"func",
"(",
"c",
"*",
"GorymanClient",
")",
"SendState",
"(",
"s",
"*",
"State",
")",
"error",
"{",
"spb",
",",
"err",
":=",
"StateToProtocolBuffer",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"message",
... | // Send a state update | [
"Send",
"a",
"state",
"update"
] | 55c3cbc3df542201b3c140e72a758d0adae4bc05 | https://github.com/cjgdev/goryman/blob/55c3cbc3df542201b3c140e72a758d0adae4bc05/client.go#L71-L82 |
154,242 | cjgdev/goryman | client.go | QueryEvents | func (c *GorymanClient) QueryEvents(q string) ([]Event, error) {
query := &proto.Query{}
query.String_ = pb.String(q)
message := &proto.Msg{}
message.Query = query
response, err := c.sendRecv(message)
if err != nil {
return nil, err
}
return ProtocolBuffersToEvents(response.GetEvents()), nil
} | go | func (c *GorymanClient) QueryEvents(q string) ([]Event, error) {
query := &proto.Query{}
query.String_ = pb.String(q)
message := &proto.Msg{}
message.Query = query
response, err := c.sendRecv(message)
if err != nil {
return nil, err
}
return ProtocolBuffersToEvents(response.GetEvents()), nil
} | [
"func",
"(",
"c",
"*",
"GorymanClient",
")",
"QueryEvents",
"(",
"q",
"string",
")",
"(",
"[",
"]",
"Event",
",",
"error",
")",
"{",
"query",
":=",
"&",
"proto",
".",
"Query",
"{",
"}",
"\n",
"query",
".",
"String_",
"=",
"pb",
".",
"String",
"("... | // Query the server for events | [
"Query",
"the",
"server",
"for",
"events"
] | 55c3cbc3df542201b3c140e72a758d0adae4bc05 | https://github.com/cjgdev/goryman/blob/55c3cbc3df542201b3c140e72a758d0adae4bc05/client.go#L85-L98 |
154,243 | cjgdev/goryman | client.go | sendRecv | func (c *GorymanClient) sendRecv(m *proto.Msg) (*proto.Msg, error) {
return c.tcp.SendRecv(m)
} | go | func (c *GorymanClient) sendRecv(m *proto.Msg) (*proto.Msg, error) {
return c.tcp.SendRecv(m)
} | [
"func",
"(",
"c",
"*",
"GorymanClient",
")",
"sendRecv",
"(",
"m",
"*",
"proto",
".",
"Msg",
")",
"(",
"*",
"proto",
".",
"Msg",
",",
"error",
")",
"{",
"return",
"c",
".",
"tcp",
".",
"SendRecv",
"(",
"m",
")",
"\n",
"}"
] | // Send and receive data from Riemann | [
"Send",
"and",
"receive",
"data",
"from",
"Riemann"
] | 55c3cbc3df542201b3c140e72a758d0adae4bc05 | https://github.com/cjgdev/goryman/blob/55c3cbc3df542201b3c140e72a758d0adae4bc05/client.go#L101-L103 |
154,244 | cjgdev/goryman | client.go | sendMaybeRecv | func (c *GorymanClient) sendMaybeRecv(m *proto.Msg) (*proto.Msg, error) {
_, err := c.udp.SendMaybeRecv(m)
if err != nil {
return c.tcp.SendMaybeRecv(m)
}
return nil, nil
} | go | func (c *GorymanClient) sendMaybeRecv(m *proto.Msg) (*proto.Msg, error) {
_, err := c.udp.SendMaybeRecv(m)
if err != nil {
return c.tcp.SendMaybeRecv(m)
}
return nil, nil
} | [
"func",
"(",
"c",
"*",
"GorymanClient",
")",
"sendMaybeRecv",
"(",
"m",
"*",
"proto",
".",
"Msg",
")",
"(",
"*",
"proto",
".",
"Msg",
",",
"error",
")",
"{",
"_",
",",
"err",
":=",
"c",
".",
"udp",
".",
"SendMaybeRecv",
"(",
"m",
")",
"\n",
"if... | // Send and maybe receive data from Riemann | [
"Send",
"and",
"maybe",
"receive",
"data",
"from",
"Riemann"
] | 55c3cbc3df542201b3c140e72a758d0adae4bc05 | https://github.com/cjgdev/goryman/blob/55c3cbc3df542201b3c140e72a758d0adae4bc05/client.go#L106-L112 |
154,245 | rdwilliamson/aws | glacier/glacier.go | vault | func (c *Connection) vault(vault string) string {
return "https://" + c.Signature.Region.Glacier + "/-/vaults/" + vault
} | go | func (c *Connection) vault(vault string) string {
return "https://" + c.Signature.Region.Glacier + "/-/vaults/" + vault
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"vault",
"(",
"vault",
"string",
")",
"string",
"{",
"return",
"\"",
"\"",
"+",
"c",
".",
"Signature",
".",
"Region",
".",
"Glacier",
"+",
"\"",
"\"",
"+",
"vault",
"\n",
"}"
] | // vault returns the URL prefix of the named vault, without a trailing slash. | [
"vault",
"returns",
"the",
"URL",
"prefix",
"of",
"the",
"named",
"vault",
"without",
"a",
"trailing",
"slash",
"."
] | 54608bb65939fc94439865d46598a57f7f15fb0e | https://github.com/rdwilliamson/aws/blob/54608bb65939fc94439865d46598a57f7f15fb0e/glacier/glacier.go#L29-L31 |
154,246 | rdwilliamson/aws | glacier/glacier.go | policy | func (c *Connection) policy(policy string) string {
return "https://" + c.Signature.Region.Glacier + "/-/policies/" + policy
} | go | func (c *Connection) policy(policy string) string {
return "https://" + c.Signature.Region.Glacier + "/-/policies/" + policy
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"policy",
"(",
"policy",
"string",
")",
"string",
"{",
"return",
"\"",
"\"",
"+",
"c",
".",
"Signature",
".",
"Region",
".",
"Glacier",
"+",
"\"",
"\"",
"+",
"policy",
"\n",
"}"
] | // policy returns the URL prefix of the named policy, without a trailing slash. | [
"policy",
"returns",
"the",
"URL",
"prefix",
"of",
"the",
"named",
"policy",
"without",
"a",
"trailing",
"slash",
"."
] | 54608bb65939fc94439865d46598a57f7f15fb0e | https://github.com/rdwilliamson/aws/blob/54608bb65939fc94439865d46598a57f7f15fb0e/glacier/glacier.go#L34-L36 |
154,247 | rdwilliamson/aws | glacier/glacier.go | NewConnection | func NewConnection(secret, access string, r *aws.Region) *Connection {
return &Connection{
Signature: aws.NewSignature(secret, access, r, "glacier"),
}
} | go | func NewConnection(secret, access string, r *aws.Region) *Connection {
return &Connection{
Signature: aws.NewSignature(secret, access, r, "glacier"),
}
} | [
"func",
"NewConnection",
"(",
"secret",
",",
"access",
"string",
",",
"r",
"*",
"aws",
".",
"Region",
")",
"*",
"Connection",
"{",
"return",
"&",
"Connection",
"{",
"Signature",
":",
"aws",
".",
"NewSignature",
"(",
"secret",
",",
"access",
",",
"r",
"... | // NewConnection returns a Connection with an initialized signature
// based on the provided access credentials and region. | [
"NewConnection",
"returns",
"a",
"Connection",
"with",
"an",
"initialized",
"signature",
"based",
"on",
"the",
"provided",
"access",
"credentials",
"and",
"region",
"."
] | 54608bb65939fc94439865d46598a57f7f15fb0e | https://github.com/rdwilliamson/aws/blob/54608bb65939fc94439865d46598a57f7f15fb0e/glacier/glacier.go#L40-L44 |
154,248 | rdwilliamson/aws | glacier/glacier.go | add | func (p parameters) add(key, value string) {
url.Values(p).Add(key, value)
} | go | func (p parameters) add(key, value string) {
url.Values(p).Add(key, value)
} | [
"func",
"(",
"p",
"parameters",
")",
"add",
"(",
"key",
",",
"value",
"string",
")",
"{",
"url",
".",
"Values",
"(",
"p",
")",
".",
"Add",
"(",
"key",
",",
"value",
")",
"\n",
"}"
] | // add adds the key value pair. It appends to any existing values associated
// with key. | [
"add",
"adds",
"the",
"key",
"value",
"pair",
".",
"It",
"appends",
"to",
"any",
"existing",
"values",
"associated",
"with",
"key",
"."
] | 54608bb65939fc94439865d46598a57f7f15fb0e | https://github.com/rdwilliamson/aws/blob/54608bb65939fc94439865d46598a57f7f15fb0e/glacier/glacier.go#L59-L61 |
154,249 | arduino/go-timeutils | time.go | TimezoneOffsetNoDST | func TimezoneOffsetNoDST(t time.Time) int {
_, winterOffset := time.Date(t.Year(), 1, 1, 0, 0, 0, 0, t.Location()).Zone()
_, summerOffset := time.Date(t.Year(), 7, 1, 0, 0, 0, 0, t.Location()).Zone()
if winterOffset > summerOffset {
winterOffset, summerOffset = summerOffset, winterOffset
}
return winterOffset
} | go | func TimezoneOffsetNoDST(t time.Time) int {
_, winterOffset := time.Date(t.Year(), 1, 1, 0, 0, 0, 0, t.Location()).Zone()
_, summerOffset := time.Date(t.Year(), 7, 1, 0, 0, 0, 0, t.Location()).Zone()
if winterOffset > summerOffset {
winterOffset, summerOffset = summerOffset, winterOffset
}
return winterOffset
} | [
"func",
"TimezoneOffsetNoDST",
"(",
"t",
"time",
".",
"Time",
")",
"int",
"{",
"_",
",",
"winterOffset",
":=",
"time",
".",
"Date",
"(",
"t",
".",
"Year",
"(",
")",
",",
"1",
",",
"1",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"t",
".",
... | // TimezoneOffsetNoDST returns the timezone offset without the DST component | [
"TimezoneOffsetNoDST",
"returns",
"the",
"timezone",
"offset",
"without",
"the",
"DST",
"component"
] | d1dd9e313b1bfede35fe0bbf46d612e16a50e04e | https://github.com/arduino/go-timeutils/blob/d1dd9e313b1bfede35fe0bbf46d612e16a50e04e/time.go#L35-L42 |
154,250 | arduino/go-timeutils | time.go | DaylightSavingsOffset | func DaylightSavingsOffset(t time.Time) int {
_, offset := t.Zone()
return offset - TimezoneOffsetNoDST(t)
} | go | func DaylightSavingsOffset(t time.Time) int {
_, offset := t.Zone()
return offset - TimezoneOffsetNoDST(t)
} | [
"func",
"DaylightSavingsOffset",
"(",
"t",
"time",
".",
"Time",
")",
"int",
"{",
"_",
",",
"offset",
":=",
"t",
".",
"Zone",
"(",
")",
"\n",
"return",
"offset",
"-",
"TimezoneOffsetNoDST",
"(",
"t",
")",
"\n",
"}"
] | // DaylightSavingsOffset returns the DST offset of the specified time | [
"DaylightSavingsOffset",
"returns",
"the",
"DST",
"offset",
"of",
"the",
"specified",
"time"
] | d1dd9e313b1bfede35fe0bbf46d612e16a50e04e | https://github.com/arduino/go-timeutils/blob/d1dd9e313b1bfede35fe0bbf46d612e16a50e04e/time.go#L45-L48 |
154,251 | arduino/go-timeutils | time.go | LocalUnix | func LocalUnix(t time.Time) int64 {
_, offset := t.Zone()
return t.Unix() + int64(offset)
} | go | func LocalUnix(t time.Time) int64 {
_, offset := t.Zone()
return t.Unix() + int64(offset)
} | [
"func",
"LocalUnix",
"(",
"t",
"time",
".",
"Time",
")",
"int64",
"{",
"_",
",",
"offset",
":=",
"t",
".",
"Zone",
"(",
")",
"\n",
"return",
"t",
".",
"Unix",
"(",
")",
"+",
"int64",
"(",
"offset",
")",
"\n",
"}"
] | // LocalUnix returns the unix timestamp of the specified time with the
// local timezone offset and DST added | [
"LocalUnix",
"returns",
"the",
"unix",
"timestamp",
"of",
"the",
"specified",
"time",
"with",
"the",
"local",
"timezone",
"offset",
"and",
"DST",
"added"
] | d1dd9e313b1bfede35fe0bbf46d612e16a50e04e | https://github.com/arduino/go-timeutils/blob/d1dd9e313b1bfede35fe0bbf46d612e16a50e04e/time.go#L52-L55 |
154,252 | rdwilliamson/aws | glacier/jobs.go | InitiateRetrievalJob | func (c *Connection) InitiateRetrievalJob(vault, archive, topic, description string) (string, error) {
// Build request.
j := jobRequest{Type: "archive-retrieval", ArchiveId: archive, Description: description, SNSTopic: topic}
body, _ := json.Marshal(j)
request, err := http.NewRequest("POST", c.vault(vault)+"/jobs", nil)
if err != nil {
return "", err
}
request.Header.Add("x-amz-glacier-version", "2012-06-01")
c.Signature.Sign(request, aws.MemoryPayload(body))
// Perform request.
response, err := c.client().Do(request)
if err != nil {
return "", err
}
defer response.Body.Close()
if response.StatusCode != http.StatusAccepted {
return "", aws.ParseError(response)
}
io.Copy(ioutil.Discard, response.Body)
// Parse success response.
return response.Header.Get("x-amz-job-id"), nil
} | go | func (c *Connection) InitiateRetrievalJob(vault, archive, topic, description string) (string, error) {
// Build request.
j := jobRequest{Type: "archive-retrieval", ArchiveId: archive, Description: description, SNSTopic: topic}
body, _ := json.Marshal(j)
request, err := http.NewRequest("POST", c.vault(vault)+"/jobs", nil)
if err != nil {
return "", err
}
request.Header.Add("x-amz-glacier-version", "2012-06-01")
c.Signature.Sign(request, aws.MemoryPayload(body))
// Perform request.
response, err := c.client().Do(request)
if err != nil {
return "", err
}
defer response.Body.Close()
if response.StatusCode != http.StatusAccepted {
return "", aws.ParseError(response)
}
io.Copy(ioutil.Discard, response.Body)
// Parse success response.
return response.Header.Get("x-amz-job-id"), nil
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"InitiateRetrievalJob",
"(",
"vault",
",",
"archive",
",",
"topic",
",",
"description",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"// Build request.",
"j",
":=",
"jobRequest",
"{",
"Type",
":",
"\"",
... | // Initiate an archive retrieval job with both the vault name where the
// archive resides and the archive ID you wish to download. You can also
// provide an optional job description when you initiate these jobs. If you
// specify a topic, Amazon Glacier sends notifications to both the supplied
// topic and the vault's ArchiveRetrievalCompleted notification topic.
//
// Returns the job ID or the first error encountered. | [
"Initiate",
"an",
"archive",
"retrieval",
"job",
"with",
"both",
"the",
"vault",
"name",
"where",
"the",
"archive",
"resides",
"and",
"the",
"archive",
"ID",
"you",
"wish",
"to",
"download",
".",
"You",
"can",
"also",
"provide",
"an",
"optional",
"job",
"d... | 54608bb65939fc94439865d46598a57f7f15fb0e | https://github.com/rdwilliamson/aws/blob/54608bb65939fc94439865d46598a57f7f15fb0e/glacier/jobs.go#L121-L149 |
154,253 | rdwilliamson/aws | glacier/jobs.go | DescribeJob | func (c *Connection) DescribeJob(vault, jobId string) (*Job, error) {
// Build request.
request, err := http.NewRequest("GET", c.vault(vault)+"/jobs/"+jobId, nil)
if err != nil {
return nil, err
}
request.Header.Add("x-amz-glacier-version", "2012-06-01")
c.Signature.Sign(request, nil)
// Perform request.
response, err := c.client().Do(request)
if err != nil {
return nil, err
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
return nil, aws.ParseError(response)
}
// Parse success response.
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return nil, err
}
var j job
err = json.Unmarshal(body, &j)
if err != nil {
return nil, err
}
var result Job
if j.ArchiveId != nil {
result.ArchiveId = *j.ArchiveId
}
if j.ArchiveSizeInBytes != nil {
result.ArchiveSizeInBytes = *j.ArchiveSizeInBytes
}
result.Completed = j.Completed
if j.CompletionDate != nil {
result.CompletionDate, err = time.Parse(time.RFC3339, *j.CompletionDate)
if err != nil {
return nil, err
}
}
result.CreationDate, err = time.Parse(time.RFC3339, j.CreationDate)
if err != nil {
return nil, err
}
if j.InventorySizeInBytes != nil {
result.InventorySizeInBytes = *j.InventorySizeInBytes
}
if j.JobDescription != nil {
result.JobDescription = *j.JobDescription
}
result.JobId = j.JobId
if j.SHA256TreeHash != nil {
result.SHA256TreeHash = *j.SHA256TreeHash
}
if j.SNSTopic != nil {
result.SNSTopic = *j.SNSTopic
}
result.StatusCode = j.StatusCode
if j.StatusMessage != nil {
result.StatusMessage = *j.StatusMessage
}
result.VaultARN = j.VaultARN
return &result, nil
} | go | func (c *Connection) DescribeJob(vault, jobId string) (*Job, error) {
// Build request.
request, err := http.NewRequest("GET", c.vault(vault)+"/jobs/"+jobId, nil)
if err != nil {
return nil, err
}
request.Header.Add("x-amz-glacier-version", "2012-06-01")
c.Signature.Sign(request, nil)
// Perform request.
response, err := c.client().Do(request)
if err != nil {
return nil, err
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
return nil, aws.ParseError(response)
}
// Parse success response.
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return nil, err
}
var j job
err = json.Unmarshal(body, &j)
if err != nil {
return nil, err
}
var result Job
if j.ArchiveId != nil {
result.ArchiveId = *j.ArchiveId
}
if j.ArchiveSizeInBytes != nil {
result.ArchiveSizeInBytes = *j.ArchiveSizeInBytes
}
result.Completed = j.Completed
if j.CompletionDate != nil {
result.CompletionDate, err = time.Parse(time.RFC3339, *j.CompletionDate)
if err != nil {
return nil, err
}
}
result.CreationDate, err = time.Parse(time.RFC3339, j.CreationDate)
if err != nil {
return nil, err
}
if j.InventorySizeInBytes != nil {
result.InventorySizeInBytes = *j.InventorySizeInBytes
}
if j.JobDescription != nil {
result.JobDescription = *j.JobDescription
}
result.JobId = j.JobId
if j.SHA256TreeHash != nil {
result.SHA256TreeHash = *j.SHA256TreeHash
}
if j.SNSTopic != nil {
result.SNSTopic = *j.SNSTopic
}
result.StatusCode = j.StatusCode
if j.StatusMessage != nil {
result.StatusMessage = *j.StatusMessage
}
result.VaultARN = j.VaultARN
return &result, nil
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"DescribeJob",
"(",
"vault",
",",
"jobId",
"string",
")",
"(",
"*",
"Job",
",",
"error",
")",
"{",
"// Build request.",
"request",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"c",
".",
... | // This operation returns information about a job you previously initiated,
// see Job type.
//
// Returns the job and the first error, if any, encountered. | [
"This",
"operation",
"returns",
"information",
"about",
"a",
"job",
"you",
"previously",
"initiated",
"see",
"Job",
"type",
".",
"Returns",
"the",
"job",
"and",
"the",
"first",
"error",
"if",
"any",
"encountered",
"."
] | 54608bb65939fc94439865d46598a57f7f15fb0e | https://github.com/rdwilliamson/aws/blob/54608bb65939fc94439865d46598a57f7f15fb0e/glacier/jobs.go#L191-L262 |
154,254 | rdwilliamson/aws | glacier/jobs.go | GetInventoryJob | func (c *Connection) GetInventoryJob(vault, job string) (*Inventory, error) {
// Build request.
request, err := http.NewRequest("GET", c.vault(vault)+"/jobs/"+job+"/output", nil)
if err != nil {
return nil, err
}
request.Header.Add("x-amz-glacier-version", "2012-06-01")
c.Signature.Sign(request, nil)
// Perform request.
response, err := c.client().Do(request)
if err != nil {
return nil, err
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
return nil, aws.ParseError(response)
}
// Parse success response.
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return nil, err
}
var i struct {
VaultARN string
InventoryDate string
ArchiveList []struct {
ArchiveId string
ArchiveDescription string
CreationDate string
Size int64
SHA256TreeHash string
}
}
err = json.Unmarshal(body, &i)
if err != nil {
return nil, err
}
var result Inventory
result.VaultARN = i.VaultARN
result.InventoryDate, err = time.Parse(time.RFC3339, i.InventoryDate)
if err != nil {
return nil, err
}
result.ArchiveList = make([]Archive, len(i.ArchiveList))
for j, v := range i.ArchiveList {
result.ArchiveList[j].ArchiveId = v.ArchiveId
result.ArchiveList[j].ArchiveDescription = v.ArchiveDescription
result.ArchiveList[j].CreationDate, err = time.Parse(time.RFC3339, v.CreationDate)
if err != nil {
return nil, err
}
result.ArchiveList[j].Size = v.Size
result.ArchiveList[j].SHA256TreeHash = v.SHA256TreeHash
}
return &result, nil
} | go | func (c *Connection) GetInventoryJob(vault, job string) (*Inventory, error) {
// Build request.
request, err := http.NewRequest("GET", c.vault(vault)+"/jobs/"+job+"/output", nil)
if err != nil {
return nil, err
}
request.Header.Add("x-amz-glacier-version", "2012-06-01")
c.Signature.Sign(request, nil)
// Perform request.
response, err := c.client().Do(request)
if err != nil {
return nil, err
}
defer response.Body.Close()
if response.StatusCode != http.StatusOK {
return nil, aws.ParseError(response)
}
// Parse success response.
body, err := ioutil.ReadAll(response.Body)
if err != nil {
return nil, err
}
var i struct {
VaultARN string
InventoryDate string
ArchiveList []struct {
ArchiveId string
ArchiveDescription string
CreationDate string
Size int64
SHA256TreeHash string
}
}
err = json.Unmarshal(body, &i)
if err != nil {
return nil, err
}
var result Inventory
result.VaultARN = i.VaultARN
result.InventoryDate, err = time.Parse(time.RFC3339, i.InventoryDate)
if err != nil {
return nil, err
}
result.ArchiveList = make([]Archive, len(i.ArchiveList))
for j, v := range i.ArchiveList {
result.ArchiveList[j].ArchiveId = v.ArchiveId
result.ArchiveList[j].ArchiveDescription = v.ArchiveDescription
result.ArchiveList[j].CreationDate, err = time.Parse(time.RFC3339, v.CreationDate)
if err != nil {
return nil, err
}
result.ArchiveList[j].Size = v.Size
result.ArchiveList[j].SHA256TreeHash = v.SHA256TreeHash
}
return &result, nil
} | [
"func",
"(",
"c",
"*",
"Connection",
")",
"GetInventoryJob",
"(",
"vault",
",",
"job",
"string",
")",
"(",
"*",
"Inventory",
",",
"error",
")",
"{",
"// Build request.",
"request",
",",
"err",
":=",
"http",
".",
"NewRequest",
"(",
"\"",
"\"",
",",
"c",... | // Amazon Glacier updates a vault inventory approximately once a day, starting
// on the day you first upload an archive to the vault. When you initiate a job
// for a vault inventory, Amazon Glacier returns the last inventory it
// generated, which is a point-in-time snapshot and not realtime data. Note that
// after Amazon Glacier creates the first inventory for the vault, it typically
// takes half a day and up to a day before that inventory is available for
// retrieval.You might not find it useful to retrieve a vault inventory for each
// archive upload. However, suppose you maintain a database on the client-side
// associating metadata about the archives you upload to Amazon Glacier. Then,
// you might find the vault inventory useful to reconcile information, as
// needed, in your database with the actual vault inventory. | [
"Amazon",
"Glacier",
"updates",
"a",
"vault",
"inventory",
"approximately",
"once",
"a",
"day",
"starting",
"on",
"the",
"day",
"you",
"first",
"upload",
"an",
"archive",
"to",
"the",
"vault",
".",
"When",
"you",
"initiate",
"a",
"job",
"for",
"a",
"vault"... | 54608bb65939fc94439865d46598a57f7f15fb0e | https://github.com/rdwilliamson/aws/blob/54608bb65939fc94439865d46598a57f7f15fb0e/glacier/jobs.go#L329-L391 |
154,255 | captncraig/easyauth | auth.go | Wrapper | func (m *authManager) Wrapper(required Role) func(http.Handler) http.Handler {
return func(h http.Handler) http.Handler {
return m.Wrap(h, required)
}
} | go | func (m *authManager) Wrapper(required Role) func(http.Handler) http.Handler {
return func(h http.Handler) http.Handler {
return m.Wrap(h, required)
}
} | [
"func",
"(",
"m",
"*",
"authManager",
")",
"Wrapper",
"(",
"required",
"Role",
")",
"func",
"(",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"func",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",... | //Wrapper returns a middleware constructor for the given auth level. This function can be used with middleware chains
//or by itself to create new handlers in the future | [
"Wrapper",
"returns",
"a",
"middleware",
"constructor",
"for",
"the",
"given",
"auth",
"level",
".",
"This",
"function",
"can",
"be",
"used",
"with",
"middleware",
"chains",
"or",
"by",
"itself",
"to",
"create",
"new",
"handlers",
"in",
"the",
"future"
] | c6de284138cfb3c428a4870ceec7391fddcec2ef | https://github.com/captncraig/easyauth/blob/c6de284138cfb3c428a4870ceec7391fddcec2ef/auth.go#L152-L156 |
154,256 | captncraig/easyauth | auth.go | RandomString | func RandomString(length int) string {
var dat = make([]byte, length)
rand.Read(dat)
return base64.StdEncoding.EncodeToString(dat)
} | go | func RandomString(length int) string {
var dat = make([]byte, length)
rand.Read(dat)
return base64.StdEncoding.EncodeToString(dat)
} | [
"func",
"RandomString",
"(",
"length",
"int",
")",
"string",
"{",
"var",
"dat",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"length",
")",
"\n",
"rand",
".",
"Read",
"(",
"dat",
")",
"\n",
"return",
"base64",
".",
"StdEncoding",
".",
"EncodeToString",
"... | //RandomString returns a random string of bytes length long, base64 encoded. | [
"RandomString",
"returns",
"a",
"random",
"string",
"of",
"bytes",
"length",
"long",
"base64",
"encoded",
"."
] | c6de284138cfb3c428a4870ceec7391fddcec2ef | https://github.com/captncraig/easyauth/blob/c6de284138cfb3c428a4870ceec7391fddcec2ef/auth.go#L286-L290 |
154,257 | crackcomm/cloudflare | client_firewalls.go | Create | func (firewalls *Firewalls) Create(ctx context.Context, id string, firewall *Firewall) (fw *Firewall, err error) {
buffer := new(bytes.Buffer)
err = json.NewEncoder(buffer).Encode(firewall)
if err != nil {
return
}
response, err := httpDo(ctx, firewalls.Options, "POST", apiURL("/zones/%s/firewall/access_rules/rules", id), buffer)
if err != nil {
return
}
defer response.Body.Close()
result, err := readResponse(response.Body)
if err != nil {
return
}
fw = new(Firewall)
err = json.Unmarshal(result.Result, &fw)
return
} | go | func (firewalls *Firewalls) Create(ctx context.Context, id string, firewall *Firewall) (fw *Firewall, err error) {
buffer := new(bytes.Buffer)
err = json.NewEncoder(buffer).Encode(firewall)
if err != nil {
return
}
response, err := httpDo(ctx, firewalls.Options, "POST", apiURL("/zones/%s/firewall/access_rules/rules", id), buffer)
if err != nil {
return
}
defer response.Body.Close()
result, err := readResponse(response.Body)
if err != nil {
return
}
fw = new(Firewall)
err = json.Unmarshal(result.Result, &fw)
return
} | [
"func",
"(",
"firewalls",
"*",
"Firewalls",
")",
"Create",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
",",
"firewall",
"*",
"Firewall",
")",
"(",
"fw",
"*",
"Firewall",
",",
"err",
"error",
")",
"{",
"buffer",
":=",
"new",
"(",
"byte... | // Create - Creates a firewall rule for zone. | [
"Create",
"-",
"Creates",
"a",
"firewall",
"rule",
"for",
"zone",
"."
] | dc358193164414054010e3fafdb6cc8def4eb864 | https://github.com/crackcomm/cloudflare/blob/dc358193164414054010e3fafdb6cc8def4eb864/client_firewalls.go#L17-L35 |
154,258 | crackcomm/cloudflare | client_firewalls.go | List | func (firewalls *Firewalls) List(ctx context.Context, zone string) ([]*Firewall, error) {
return firewalls.listPages(ctx, zone, 1)
} | go | func (firewalls *Firewalls) List(ctx context.Context, zone string) ([]*Firewall, error) {
return firewalls.listPages(ctx, zone, 1)
} | [
"func",
"(",
"firewalls",
"*",
"Firewalls",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"zone",
"string",
")",
"(",
"[",
"]",
"*",
"Firewall",
",",
"error",
")",
"{",
"return",
"firewalls",
".",
"listPages",
"(",
"ctx",
",",
"zone",
",",... | // List - Lists all firewall rules for zone. | [
"List",
"-",
"Lists",
"all",
"firewall",
"rules",
"for",
"zone",
"."
] | dc358193164414054010e3fafdb6cc8def4eb864 | https://github.com/crackcomm/cloudflare/blob/dc358193164414054010e3fafdb6cc8def4eb864/client_firewalls.go#L38-L40 |
154,259 | crackcomm/cloudflare | client_firewalls.go | Delete | func (firewalls *Firewalls) Delete(ctx context.Context, zone, id string) (err error) {
response, err := httpDo(ctx, firewalls.Options, "DELETE", apiURL("/zones/%s/firewall/access_rules/rules/%s", zone, id), nil)
if err != nil {
return
}
defer response.Body.Close()
_, err = readResponse(response.Body)
return
} | go | func (firewalls *Firewalls) Delete(ctx context.Context, zone, id string) (err error) {
response, err := httpDo(ctx, firewalls.Options, "DELETE", apiURL("/zones/%s/firewall/access_rules/rules/%s", zone, id), nil)
if err != nil {
return
}
defer response.Body.Close()
_, err = readResponse(response.Body)
return
} | [
"func",
"(",
"firewalls",
"*",
"Firewalls",
")",
"Delete",
"(",
"ctx",
"context",
".",
"Context",
",",
"zone",
",",
"id",
"string",
")",
"(",
"err",
"error",
")",
"{",
"response",
",",
"err",
":=",
"httpDo",
"(",
"ctx",
",",
"firewalls",
".",
"Option... | // Delete - Deletes firewall by id. | [
"Delete",
"-",
"Deletes",
"firewall",
"by",
"id",
"."
] | dc358193164414054010e3fafdb6cc8def4eb864 | https://github.com/crackcomm/cloudflare/blob/dc358193164414054010e3fafdb6cc8def4eb864/client_firewalls.go#L43-L51 |
154,260 | seven5/seven5 | raw.go | NewRestNode | func NewRestNode() *RestNode {
return &RestNode{
Res: make(map[string]*restObj),
ResUdid: make(map[string]*restObjUdid),
Children: make(map[string]*RestNode),
ChildrenUdid: make(map[string]*RestNode),
}
} | go | func NewRestNode() *RestNode {
return &RestNode{
Res: make(map[string]*restObj),
ResUdid: make(map[string]*restObjUdid),
Children: make(map[string]*RestNode),
ChildrenUdid: make(map[string]*RestNode),
}
} | [
"func",
"NewRestNode",
"(",
")",
"*",
"RestNode",
"{",
"return",
"&",
"RestNode",
"{",
"Res",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"restObj",
")",
",",
"ResUdid",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"restObjUdid",
")",
",... | //NewRestNode creates a new, empty rest node. | [
"NewRestNode",
"creates",
"a",
"new",
"empty",
"rest",
"node",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L43-L50 |
154,261 | seven5/seven5 | raw.go | AddResourceSeparate | func (self *RawDispatcher) AddResourceSeparate(node *RestNode, name string, wireExample interface{}, index RestIndex,
find RestFind, post RestPost, put RestPut, del RestDelete) {
t := self.validateType(wireExample)
obj := &restObj{
restShared: restShared{
typ: t,
name: name,
index: index,
post: post,
},
find: find,
del: del,
put: put,
}
node.Res[strings.ToLower(name)] = obj
} | go | func (self *RawDispatcher) AddResourceSeparate(node *RestNode, name string, wireExample interface{}, index RestIndex,
find RestFind, post RestPost, put RestPut, del RestDelete) {
t := self.validateType(wireExample)
obj := &restObj{
restShared: restShared{
typ: t,
name: name,
index: index,
post: post,
},
find: find,
del: del,
put: put,
}
node.Res[strings.ToLower(name)] = obj
} | [
"func",
"(",
"self",
"*",
"RawDispatcher",
")",
"AddResourceSeparate",
"(",
"node",
"*",
"RestNode",
",",
"name",
"string",
",",
"wireExample",
"interface",
"{",
"}",
",",
"index",
"RestIndex",
",",
"find",
"RestFind",
",",
"post",
"RestPost",
",",
"put",
... | //AddResourceSeparate adds a resource to a given rest node, in a way parallel
//to ResourceSeparate. | [
"AddResourceSeparate",
"adds",
"a",
"resource",
"to",
"a",
"given",
"rest",
"node",
"in",
"a",
"way",
"parallel",
"to",
"ResourceSeparate",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L77-L93 |
154,262 | seven5/seven5 | raw.go | ResourceSeparateUdid | func (self *RawDispatcher) ResourceSeparateUdid(name string, wireExample interface{}, index RestIndex,
find RestFindUdid, post RestPost, put RestPutUdid, del RestDeleteUdid) {
self.AddResourceSeparateUdid(self.Root, name, wireExample, index, find, post, put, del)
} | go | func (self *RawDispatcher) ResourceSeparateUdid(name string, wireExample interface{}, index RestIndex,
find RestFindUdid, post RestPost, put RestPutUdid, del RestDeleteUdid) {
self.AddResourceSeparateUdid(self.Root, name, wireExample, index, find, post, put, del)
} | [
"func",
"(",
"self",
"*",
"RawDispatcher",
")",
"ResourceSeparateUdid",
"(",
"name",
"string",
",",
"wireExample",
"interface",
"{",
"}",
",",
"index",
"RestIndex",
",",
"find",
"RestFindUdid",
",",
"post",
"RestPost",
",",
"put",
"RestPutUdid",
",",
"del",
... | //ResourceSeparateUdid adds a resource type to this dispatcher with each of the RestUdid methods
//individually specified. The name should be singular and camel case. The example should an example
//of the wire type to be marshalled, unmarshalled. The wire type can have an Id in addition
//to a Udid field. | [
"ResourceSeparateUdid",
"adds",
"a",
"resource",
"type",
"to",
"this",
"dispatcher",
"with",
"each",
"of",
"the",
"RestUdid",
"methods",
"individually",
"specified",
".",
"The",
"name",
"should",
"be",
"singular",
"and",
"camel",
"case",
".",
"The",
"example",
... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L108-L112 |
154,263 | seven5/seven5 | raw.go | AddResourceSeparateUdid | func (self *RawDispatcher) AddResourceSeparateUdid(node *RestNode, name string, wireExample interface{}, index RestIndex,
find RestFindUdid, post RestPost, put RestPutUdid, del RestDeleteUdid) {
t := self.validateType(wireExample)
obj := &restObjUdid{
restShared: restShared{
typ: t,
name: name,
index: index,
post: post,
},
find: find,
del: del,
put: put,
}
node.ResUdid[strings.ToLower(name)] = obj
} | go | func (self *RawDispatcher) AddResourceSeparateUdid(node *RestNode, name string, wireExample interface{}, index RestIndex,
find RestFindUdid, post RestPost, put RestPutUdid, del RestDeleteUdid) {
t := self.validateType(wireExample)
obj := &restObjUdid{
restShared: restShared{
typ: t,
name: name,
index: index,
post: post,
},
find: find,
del: del,
put: put,
}
node.ResUdid[strings.ToLower(name)] = obj
} | [
"func",
"(",
"self",
"*",
"RawDispatcher",
")",
"AddResourceSeparateUdid",
"(",
"node",
"*",
"RestNode",
",",
"name",
"string",
",",
"wireExample",
"interface",
"{",
"}",
",",
"index",
"RestIndex",
",",
"find",
"RestFindUdid",
",",
"post",
"RestPost",
",",
"... | //AddResourceSeparateUdid adds a resource to a given rest node, in a way parallel
//to ResourceSeparateUdid. | [
"AddResourceSeparateUdid",
"adds",
"a",
"resource",
"to",
"a",
"given",
"rest",
"node",
"in",
"a",
"way",
"parallel",
"to",
"ResourceSeparateUdid",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L116-L131 |
154,264 | seven5/seven5 | raw.go | Resource | func (self *RawDispatcher) Resource(name string, wireExample interface{}, r RestAll) {
self.ResourceSeparate(name, wireExample, r, r, r, r, r)
} | go | func (self *RawDispatcher) Resource(name string, wireExample interface{}, r RestAll) {
self.ResourceSeparate(name, wireExample, r, r, r, r, r)
} | [
"func",
"(",
"self",
"*",
"RawDispatcher",
")",
"Resource",
"(",
"name",
"string",
",",
"wireExample",
"interface",
"{",
"}",
",",
"r",
"RestAll",
")",
"{",
"self",
".",
"ResourceSeparate",
"(",
"name",
",",
"wireExample",
",",
"r",
",",
"r",
",",
"r",... | //Resource is the shorter form of ResourceSeparate that allows you to pass a single resource
//in so long as it meets the interface RestAll. Resource name must be singular and camel case and will be
//converted to all lowercase for use as a url. The example wire type's fields must be public. | [
"Resource",
"is",
"the",
"shorter",
"form",
"of",
"ResourceSeparate",
"that",
"allows",
"you",
"to",
"pass",
"a",
"single",
"resource",
"in",
"so",
"long",
"as",
"it",
"meets",
"the",
"interface",
"RestAll",
".",
"Resource",
"name",
"must",
"be",
"singular",... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L136-L138 |
154,265 | seven5/seven5 | raw.go | ResourceUdid | func (self *RawDispatcher) ResourceUdid(name string, wireExample interface{}, r RestAllUdid) {
self.ResourceSeparateUdid(name, wireExample, r, r, r, r, r)
} | go | func (self *RawDispatcher) ResourceUdid(name string, wireExample interface{}, r RestAllUdid) {
self.ResourceSeparateUdid(name, wireExample, r, r, r, r, r)
} | [
"func",
"(",
"self",
"*",
"RawDispatcher",
")",
"ResourceUdid",
"(",
"name",
"string",
",",
"wireExample",
"interface",
"{",
"}",
",",
"r",
"RestAllUdid",
")",
"{",
"self",
".",
"ResourceSeparateUdid",
"(",
"name",
",",
"wireExample",
",",
"r",
",",
"r",
... | //ResourceUdid is the shorter form of ResourceSeparateUdid that allows you to pass a single resource
//in so long as it meets the interface RestAllUdid. Resource name must be singular and camel case and will be
//converted to all lowercase for use as a url. The example wire type's fields must be public. | [
"ResourceUdid",
"is",
"the",
"shorter",
"form",
"of",
"ResourceSeparateUdid",
"that",
"allows",
"you",
"to",
"pass",
"a",
"single",
"resource",
"in",
"so",
"long",
"as",
"it",
"meets",
"the",
"interface",
"RestAllUdid",
".",
"Resource",
"name",
"must",
"be",
... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L143-L145 |
154,266 | seven5/seven5 | raw.go | Rez | func (self *RawDispatcher) Rez(wireExample interface{}, r RestAll) {
self.Resource(exampleTypeToName(wireExample), wireExample, r)
} | go | func (self *RawDispatcher) Rez(wireExample interface{}, r RestAll) {
self.Resource(exampleTypeToName(wireExample), wireExample, r)
} | [
"func",
"(",
"self",
"*",
"RawDispatcher",
")",
"Rez",
"(",
"wireExample",
"interface",
"{",
"}",
",",
"r",
"RestAll",
")",
"{",
"self",
".",
"Resource",
"(",
"exampleTypeToName",
"(",
"wireExample",
")",
",",
"wireExample",
",",
"r",
")",
"\n",
"}"
] | //Rez is the really short form for adding a resource. It assumes that the name is
//the same as the wire type and that the resource supports RestAll. | [
"Rez",
"is",
"the",
"really",
"short",
"form",
"for",
"adding",
"a",
"resource",
".",
"It",
"assumes",
"that",
"the",
"name",
"is",
"the",
"same",
"as",
"the",
"wire",
"type",
"and",
"that",
"the",
"resource",
"supports",
"RestAll",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L149-L151 |
154,267 | seven5/seven5 | raw.go | RezUdid | func (self *RawDispatcher) RezUdid(wireExample interface{}, r RestAllUdid) {
self.ResourceUdid(exampleTypeToName(wireExample), wireExample, r)
} | go | func (self *RawDispatcher) RezUdid(wireExample interface{}, r RestAllUdid) {
self.ResourceUdid(exampleTypeToName(wireExample), wireExample, r)
} | [
"func",
"(",
"self",
"*",
"RawDispatcher",
")",
"RezUdid",
"(",
"wireExample",
"interface",
"{",
"}",
",",
"r",
"RestAllUdid",
")",
"{",
"self",
".",
"ResourceUdid",
"(",
"exampleTypeToName",
"(",
"wireExample",
")",
",",
"wireExample",
",",
"r",
")",
"\n"... | //RezUdid is the really short form for adding a resource based on Udid. It
//assumes that the name is the same as the wire type and that the resource
//supports RestAllUdid. | [
"RezUdid",
"is",
"the",
"really",
"short",
"form",
"for",
"adding",
"a",
"resource",
"based",
"on",
"Udid",
".",
"It",
"assumes",
"that",
"the",
"name",
"is",
"the",
"same",
"as",
"the",
"wire",
"type",
"and",
"that",
"the",
"resource",
"supports",
"Rest... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L156-L158 |
154,268 | seven5/seven5 | raw.go | SubResource | func (self *RawDispatcher) SubResource(parentWire interface{},
subresourcename string, wireExample interface{}, index RestIndex, find RestFind, post RestPost, put RestPut, del RestDelete) {
parent := self.FindWireType(sanityCheckParentWireExample(parentWire), self.Root)
if parent == nil {
panic(fmt.Sprintf("unable to find wire type (parent) %T", parentWire))
}
child := NewRestNode()
parent.Children[subresourcename] = child
self.AddResourceSeparate(child, subresourcename, wireExample,
index, find, post, put, del)
} | go | func (self *RawDispatcher) SubResource(parentWire interface{},
subresourcename string, wireExample interface{}, index RestIndex, find RestFind, post RestPost, put RestPut, del RestDelete) {
parent := self.FindWireType(sanityCheckParentWireExample(parentWire), self.Root)
if parent == nil {
panic(fmt.Sprintf("unable to find wire type (parent) %T", parentWire))
}
child := NewRestNode()
parent.Children[subresourcename] = child
self.AddResourceSeparate(child, subresourcename, wireExample,
index, find, post, put, del)
} | [
"func",
"(",
"self",
"*",
"RawDispatcher",
")",
"SubResource",
"(",
"parentWire",
"interface",
"{",
"}",
",",
"subresourcename",
"string",
",",
"wireExample",
"interface",
"{",
"}",
",",
"index",
"RestIndex",
",",
"find",
"RestFind",
",",
"post",
"RestPost",
... | //SubResource is for adding a subresource, analagous to Resource
//You must provide the name of the wire type, lower case and singular, to be used
//with this resource. This call panics if the provided parent wire example cannot be located because this indicates that
//the program is misconfigured and cannot work. | [
"SubResource",
"is",
"for",
"adding",
"a",
"subresource",
"analagous",
"to",
"Resource",
"You",
"must",
"provide",
"the",
"name",
"of",
"the",
"wire",
"type",
"lower",
"case",
"and",
"singular",
"to",
"be",
"used",
"with",
"this",
"resource",
".",
"This",
... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L182-L193 |
154,269 | seven5/seven5 | raw.go | SubResourceSeparate | func (self *RawDispatcher) SubResourceSeparate(parentWire interface{}, wireExample interface{}, index RestIndex,
find RestFind, post RestPost, put RestPut, del RestDelete) {
self.SubResource(parentWire, strings.ToLower(exampleTypeToName(wireExample)),
wireExample, index, find, post, put, del)
} | go | func (self *RawDispatcher) SubResourceSeparate(parentWire interface{}, wireExample interface{}, index RestIndex,
find RestFind, post RestPost, put RestPut, del RestDelete) {
self.SubResource(parentWire, strings.ToLower(exampleTypeToName(wireExample)),
wireExample, index, find, post, put, del)
} | [
"func",
"(",
"self",
"*",
"RawDispatcher",
")",
"SubResourceSeparate",
"(",
"parentWire",
"interface",
"{",
"}",
",",
"wireExample",
"interface",
"{",
"}",
",",
"index",
"RestIndex",
",",
"find",
"RestFind",
",",
"post",
"RestPost",
",",
"put",
"RestPut",
",... | //SubResourceSeparate is for adding a subresource, analagous to ResourceSeparate.
//It assumes that the subresource name is the same as the wire type.
//This call panics if the provided parent wire example cannot be located because this indicates that
//the program is misconfigured and cannot work. | [
"SubResourceSeparate",
"is",
"for",
"adding",
"a",
"subresource",
"analagous",
"to",
"ResourceSeparate",
".",
"It",
"assumes",
"that",
"the",
"subresource",
"name",
"is",
"the",
"same",
"as",
"the",
"wire",
"type",
".",
"This",
"call",
"panics",
"if",
"the",
... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L199-L204 |
154,270 | seven5/seven5 | raw.go | SubResourceUdid | func (self *RawDispatcher) SubResourceUdid(parentWire interface{}, subresourcename string, wireExample interface{}, index RestIndex,
find RestFindUdid, post RestPost, put RestPutUdid, del RestDeleteUdid) {
parent := self.FindWireType(sanityCheckParentWireExample(parentWire), self.Root)
if parent == nil {
panic(fmt.Sprintf("unable to find wire type (parent) %T", parentWire))
}
child := NewRestNode()
parent.ChildrenUdid[strings.ToLower(exampleTypeToName(wireExample))] = child
self.AddResourceSeparateUdid(child, subresourcename, wireExample, index,
find, post, put, del)
} | go | func (self *RawDispatcher) SubResourceUdid(parentWire interface{}, subresourcename string, wireExample interface{}, index RestIndex,
find RestFindUdid, post RestPost, put RestPutUdid, del RestDeleteUdid) {
parent := self.FindWireType(sanityCheckParentWireExample(parentWire), self.Root)
if parent == nil {
panic(fmt.Sprintf("unable to find wire type (parent) %T", parentWire))
}
child := NewRestNode()
parent.ChildrenUdid[strings.ToLower(exampleTypeToName(wireExample))] = child
self.AddResourceSeparateUdid(child, subresourcename, wireExample, index,
find, post, put, del)
} | [
"func",
"(",
"self",
"*",
"RawDispatcher",
")",
"SubResourceUdid",
"(",
"parentWire",
"interface",
"{",
"}",
",",
"subresourcename",
"string",
",",
"wireExample",
"interface",
"{",
"}",
",",
"index",
"RestIndex",
",",
"find",
"RestFindUdid",
",",
"post",
"Rest... | //SubResourceUdid is for adding a subresource udid, analagous to ResourceUdid.
//You must provide the subresource name, singular and lower case.
//If the provided parent wire example cannot be located because this indicates that
//the program is misconfigured and cannot work. | [
"SubResourceUdid",
"is",
"for",
"adding",
"a",
"subresource",
"udid",
"analagous",
"to",
"ResourceUdid",
".",
"You",
"must",
"provide",
"the",
"subresource",
"name",
"singular",
"and",
"lower",
"case",
".",
"If",
"the",
"provided",
"parent",
"wire",
"example",
... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L210-L221 |
154,271 | seven5/seven5 | raw.go | SubResourceSeparateUdid | func (self *RawDispatcher) SubResourceSeparateUdid(parentWire interface{}, wireExample interface{}, index RestIndex,
find RestFindUdid, post RestPost, put RestPutUdid, del RestDeleteUdid) {
self.SubResourceUdid(parentWire, strings.ToLower(exampleTypeToName(wireExample)),
wireExample, index, find, post, put, del)
} | go | func (self *RawDispatcher) SubResourceSeparateUdid(parentWire interface{}, wireExample interface{}, index RestIndex,
find RestFindUdid, post RestPost, put RestPutUdid, del RestDeleteUdid) {
self.SubResourceUdid(parentWire, strings.ToLower(exampleTypeToName(wireExample)),
wireExample, index, find, post, put, del)
} | [
"func",
"(",
"self",
"*",
"RawDispatcher",
")",
"SubResourceSeparateUdid",
"(",
"parentWire",
"interface",
"{",
"}",
",",
"wireExample",
"interface",
"{",
"}",
",",
"index",
"RestIndex",
",",
"find",
"RestFindUdid",
",",
"post",
"RestPost",
",",
"put",
"RestPu... | //SubResourceSeparateUdid is for adding a subresource udid, analagous to ResourceSeparateUdid.
//It assumes that the subresource name is the same as the wire type.
//If the provided parent wire example cannot be located because this indicates that
//the program is misconfigured and cannot work. | [
"SubResourceSeparateUdid",
"is",
"for",
"adding",
"a",
"subresource",
"udid",
"analagous",
"to",
"ResourceSeparateUdid",
".",
"It",
"assumes",
"that",
"the",
"subresource",
"name",
"is",
"the",
"same",
"as",
"the",
"wire",
"type",
".",
"If",
"the",
"provided",
... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L227-L231 |
154,272 | seven5/seven5 | raw.go | FindWireType | func (self *RawDispatcher) FindWireType(target reflect.Type, curr *RestNode) *RestNode {
for _, v := range curr.Res {
if v.typ == target {
return curr
}
}
for _, v := range curr.ResUdid {
if v.typ == target {
return curr
}
}
//we now need to recurse into children, does DFS
for _, child := range curr.Children {
if node := self.FindWireType(target, child); node != nil {
return node
}
}
for _, child := range curr.ChildrenUdid {
if node := self.FindWireType(target, child); node != nil {
return node
}
}
//loser
return nil
} | go | func (self *RawDispatcher) FindWireType(target reflect.Type, curr *RestNode) *RestNode {
for _, v := range curr.Res {
if v.typ == target {
return curr
}
}
for _, v := range curr.ResUdid {
if v.typ == target {
return curr
}
}
//we now need to recurse into children, does DFS
for _, child := range curr.Children {
if node := self.FindWireType(target, child); node != nil {
return node
}
}
for _, child := range curr.ChildrenUdid {
if node := self.FindWireType(target, child); node != nil {
return node
}
}
//loser
return nil
} | [
"func",
"(",
"self",
"*",
"RawDispatcher",
")",
"FindWireType",
"(",
"target",
"reflect",
".",
"Type",
",",
"curr",
"*",
"RestNode",
")",
"*",
"RestNode",
"{",
"for",
"_",
",",
"v",
":=",
"range",
"curr",
".",
"Res",
"{",
"if",
"v",
".",
"typ",
"==... | //FindWireType searches the tree of rest resources trying to find one that has the
//given type as a target. This is only of interest to dispatch implementors. | [
"FindWireType",
"searches",
"the",
"tree",
"of",
"rest",
"resources",
"trying",
"to",
"find",
"one",
"that",
"has",
"the",
"given",
"type",
"as",
"a",
"target",
".",
"This",
"is",
"only",
"of",
"interest",
"to",
"dispatch",
"implementors",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L235-L260 |
154,273 | seven5/seven5 | raw.go | location | func (self *RawDispatcher) location(name string, isUdid bool, i interface{}) string {
//we should have already checked that this object is a pointer to a struct with an Id field
//in the "right place" and "right type"
result := self.Prefix + "/" + name
p := reflect.ValueOf(i)
if p.Kind() != reflect.Ptr {
panic("unexpected kind for p")
}
e := p.Elem()
if e.Kind() != reflect.Struct {
panic("unexpected kind for e")
}
if !isUdid {
f := e.FieldByName("Id")
id := f.Int()
return fmt.Sprintf("%s/%d", result, id)
}
f := e.FieldByName("Udid")
id := f.String()
return fmt.Sprintf("%s/%s", result, id)
} | go | func (self *RawDispatcher) location(name string, isUdid bool, i interface{}) string {
//we should have already checked that this object is a pointer to a struct with an Id field
//in the "right place" and "right type"
result := self.Prefix + "/" + name
p := reflect.ValueOf(i)
if p.Kind() != reflect.Ptr {
panic("unexpected kind for p")
}
e := p.Elem()
if e.Kind() != reflect.Struct {
panic("unexpected kind for e")
}
if !isUdid {
f := e.FieldByName("Id")
id := f.Int()
return fmt.Sprintf("%s/%d", result, id)
}
f := e.FieldByName("Udid")
id := f.String()
return fmt.Sprintf("%s/%s", result, id)
} | [
"func",
"(",
"self",
"*",
"RawDispatcher",
")",
"location",
"(",
"name",
"string",
",",
"isUdid",
"bool",
",",
"i",
"interface",
"{",
"}",
")",
"string",
"{",
"//we should have already checked that this object is a pointer to a struct with an Id field",
"//in the \"right ... | //Location computes the url path to the object provided | [
"Location",
"computes",
"the",
"url",
"path",
"to",
"the",
"object",
"provided"
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L631-L652 |
154,274 | seven5/seven5 | raw.go | resolve | func (self *RawDispatcher) resolve(parts []string, node *RestNode) (string, string, *restObj, *restObjUdid) {
//case 1: simple path to a normal resource
rez, ok := node.Res[parts[0]]
if ok && len(parts) == 1 {
return parts[0], "", rez, nil
}
//case 2: simple path to a udid resource
rezUdid, okUdid := node.ResUdid[parts[0]]
if okUdid && len(parts) == 1 {
return parts[0], "", nil, rezUdid
}
id := parts[1]
uriPathParent := parts[0]
//case 3, path to a resource ID (int)
rez, ok = node.Res[uriPathParent]
if ok {
return parts[0], id, rez, nil
}
//case 4, path to a resource ID (UDID)
rezUdid, ok = node.ResUdid[uriPathParent]
if ok {
return parts[0], id, nil, rezUdid
}
//nothing, give up
return "", "", nil, nil
} | go | func (self *RawDispatcher) resolve(parts []string, node *RestNode) (string, string, *restObj, *restObjUdid) {
//case 1: simple path to a normal resource
rez, ok := node.Res[parts[0]]
if ok && len(parts) == 1 {
return parts[0], "", rez, nil
}
//case 2: simple path to a udid resource
rezUdid, okUdid := node.ResUdid[parts[0]]
if okUdid && len(parts) == 1 {
return parts[0], "", nil, rezUdid
}
id := parts[1]
uriPathParent := parts[0]
//case 3, path to a resource ID (int)
rez, ok = node.Res[uriPathParent]
if ok {
return parts[0], id, rez, nil
}
//case 4, path to a resource ID (UDID)
rezUdid, ok = node.ResUdid[uriPathParent]
if ok {
return parts[0], id, nil, rezUdid
}
//nothing, give up
return "", "", nil, nil
} | [
"func",
"(",
"self",
"*",
"RawDispatcher",
")",
"resolve",
"(",
"parts",
"[",
"]",
"string",
",",
"node",
"*",
"RestNode",
")",
"(",
"string",
",",
"string",
",",
"*",
"restObj",
",",
"*",
"restObjUdid",
")",
"{",
"//case 1: simple path to a normal resource"... | //resolve is used to find the matching resource for a particular request. It returns the match
//and the resource matched. If no match is found it returns nil for the type. resolve does not check
//that the resulting object is suitable for any purpose, only that it matches. | [
"resolve",
"is",
"used",
"to",
"find",
"the",
"matching",
"resource",
"for",
"a",
"particular",
"request",
".",
"It",
"returns",
"the",
"match",
"and",
"the",
"resource",
"matched",
".",
"If",
"no",
"match",
"is",
"found",
"it",
"returns",
"nil",
"for",
... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L657-L686 |
154,275 | seven5/seven5 | raw.go | ParseId | func ParseId(candidate string) (int64, string) {
var num int64
var err error
if num, err = strconv.ParseInt(candidate, 10, 64); err != nil {
return 0, fmt.Sprintf("resource ids must be non-negative integers (was %s): %s", candidate, err)
}
return num, ""
} | go | func ParseId(candidate string) (int64, string) {
var num int64
var err error
if num, err = strconv.ParseInt(candidate, 10, 64); err != nil {
return 0, fmt.Sprintf("resource ids must be non-negative integers (was %s): %s", candidate, err)
}
return num, ""
} | [
"func",
"ParseId",
"(",
"candidate",
"string",
")",
"(",
"int64",
",",
"string",
")",
"{",
"var",
"num",
"int64",
"\n",
"var",
"err",
"error",
"\n",
"if",
"num",
",",
"err",
"=",
"strconv",
".",
"ParseInt",
"(",
"candidate",
",",
"10",
",",
"64",
"... | //ParseId returns the id contained in a string or an error message about why the id is bad. | [
"ParseId",
"returns",
"the",
"id",
"contained",
"in",
"a",
"string",
"or",
"an",
"error",
"message",
"about",
"why",
"the",
"id",
"is",
"bad",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/raw.go#L708-L715 |
154,276 | salsaflow/salsaflow | github/issues/search.go | FindReviewIssueForCommit | func FindReviewIssueForCommit(
client *github.Client,
owner string,
repo string,
commitSHA string,
) (*github.Issue, error) {
// Find the relevant review issue.
substring := fmt.Sprintf("Review commit %v:", commitSHA[:7])
return findReviewIssue(client, owner, repo, substring, "in:title", matchesTitle(substring))
} | go | func FindReviewIssueForCommit(
client *github.Client,
owner string,
repo string,
commitSHA string,
) (*github.Issue, error) {
// Find the relevant review issue.
substring := fmt.Sprintf("Review commit %v:", commitSHA[:7])
return findReviewIssue(client, owner, repo, substring, "in:title", matchesTitle(substring))
} | [
"func",
"FindReviewIssueForCommit",
"(",
"client",
"*",
"github",
".",
"Client",
",",
"owner",
"string",
",",
"repo",
"string",
",",
"commitSHA",
"string",
",",
")",
"(",
"*",
"github",
".",
"Issue",
",",
"error",
")",
"{",
"// Find the relevant review issue."... | // FindReviewIssueForCommit returns the review issue
// associated with the given commit. | [
"FindReviewIssueForCommit",
"returns",
"the",
"review",
"issue",
"associated",
"with",
"the",
"given",
"commit",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/github/issues/search.go#L15-L25 |
154,277 | salsaflow/salsaflow | github/issues/search.go | FindReviewIssueForStory | func FindReviewIssueForStory(
client *github.Client,
owner string,
repo string,
storyId string,
) (*github.Issue, error) {
// Find the relevant review issue.
substring := fmt.Sprintf("Review story %v:", storyId)
return findReviewIssue(client, owner, repo, substring, "in:title", matchesTitle(substring))
} | go | func FindReviewIssueForStory(
client *github.Client,
owner string,
repo string,
storyId string,
) (*github.Issue, error) {
// Find the relevant review issue.
substring := fmt.Sprintf("Review story %v:", storyId)
return findReviewIssue(client, owner, repo, substring, "in:title", matchesTitle(substring))
} | [
"func",
"FindReviewIssueForStory",
"(",
"client",
"*",
"github",
".",
"Client",
",",
"owner",
"string",
",",
"repo",
"string",
",",
"storyId",
"string",
",",
")",
"(",
"*",
"github",
".",
"Issue",
",",
"error",
")",
"{",
"// Find the relevant review issue.",
... | // FindReviewIssueForStory returns the review issue
// associated with the given story. | [
"FindReviewIssueForStory",
"returns",
"the",
"review",
"issue",
"associated",
"with",
"the",
"given",
"story",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/github/issues/search.go#L29-L39 |
154,278 | salsaflow/salsaflow | github/issues/search.go | FindReviewIssueByCommitItem | func FindReviewIssueByCommitItem(
client *github.Client,
owner string,
repo string,
commitSHA string,
) (*github.Issue, error) {
// Use the first 7 chars from the commit hexsha.
shortSHA := commitSHA[:7]
// Commit item regexp.
re := regexp.MustCompile(fmt.Sprintf(`[-*] \[[xX ]\] %v[:]`, shortSHA))
// Perform the search.
return findReviewIssue(client, owner, repo, shortSHA, "in:body", matchesBodyRe(re))
} | go | func FindReviewIssueByCommitItem(
client *github.Client,
owner string,
repo string,
commitSHA string,
) (*github.Issue, error) {
// Use the first 7 chars from the commit hexsha.
shortSHA := commitSHA[:7]
// Commit item regexp.
re := regexp.MustCompile(fmt.Sprintf(`[-*] \[[xX ]\] %v[:]`, shortSHA))
// Perform the search.
return findReviewIssue(client, owner, repo, shortSHA, "in:body", matchesBodyRe(re))
} | [
"func",
"FindReviewIssueByCommitItem",
"(",
"client",
"*",
"github",
".",
"Client",
",",
"owner",
"string",
",",
"repo",
"string",
",",
"commitSHA",
"string",
",",
")",
"(",
"*",
"github",
".",
"Issue",
",",
"error",
")",
"{",
"// Use the first 7 chars from th... | // FindReviewIssueByCommitItem searches review issues for the one that
// contains the given commit in its commit checklist. | [
"FindReviewIssueByCommitItem",
"searches",
"review",
"issues",
"for",
"the",
"one",
"that",
"contains",
"the",
"given",
"commit",
"in",
"its",
"commit",
"checklist",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/github/issues/search.go#L43-L58 |
154,279 | seven5/seven5 | client/arith.go | AdditionConstraint | func AdditionConstraint(a1 IntegerAttribute, a2 IntegerAttribute, fn func(int, int) int) ArithmeticConstraint {
if fn != nil {
return NewArithmeticConstraint(FUNC_OP, []Attribute{a1, a2},
func(x []int) int {
return fn(x[0], x[1])
})
} else {
return NewArithmeticConstraint(ADD_OP, []Attribute{a1, a2}, nil)
}
} | go | func AdditionConstraint(a1 IntegerAttribute, a2 IntegerAttribute, fn func(int, int) int) ArithmeticConstraint {
if fn != nil {
return NewArithmeticConstraint(FUNC_OP, []Attribute{a1, a2},
func(x []int) int {
return fn(x[0], x[1])
})
} else {
return NewArithmeticConstraint(ADD_OP, []Attribute{a1, a2}, nil)
}
} | [
"func",
"AdditionConstraint",
"(",
"a1",
"IntegerAttribute",
",",
"a2",
"IntegerAttribute",
",",
"fn",
"func",
"(",
"int",
",",
"int",
")",
"int",
")",
"ArithmeticConstraint",
"{",
"if",
"fn",
"!=",
"nil",
"{",
"return",
"NewArithmeticConstraint",
"(",
"FUNC_O... | //AdditionConstraint creates a constraint that adds two values. The only reason
//to pass the function argument is to create a result that differs from the
//sum by a constant. Note that the function, if provided, must return the
//"sum" as well as adding any constants. | [
"AdditionConstraint",
"creates",
"a",
"constraint",
"that",
"adds",
"two",
"values",
".",
"The",
"only",
"reason",
"to",
"pass",
"the",
"function",
"argument",
"is",
"to",
"create",
"a",
"result",
"that",
"differs",
"from",
"the",
"sum",
"by",
"a",
"constant... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/arith.go#L106-L115 |
154,280 | seven5/seven5 | client/arith.go | SubtractionConstraint | func SubtractionConstraint(a1 IntegerAttribute, a2 IntegerAttribute, fn func(int, int) int) ArithmeticConstraint {
if fn != nil {
return NewArithmeticConstraint(FUNC_OP, []Attribute{a1, a2},
func(x []int) int {
return fn(x[0], x[1])
})
} else {
return NewArithmeticConstraint(SUB_OP, []Attribute{a1, a2}, nil)
}
} | go | func SubtractionConstraint(a1 IntegerAttribute, a2 IntegerAttribute, fn func(int, int) int) ArithmeticConstraint {
if fn != nil {
return NewArithmeticConstraint(FUNC_OP, []Attribute{a1, a2},
func(x []int) int {
return fn(x[0], x[1])
})
} else {
return NewArithmeticConstraint(SUB_OP, []Attribute{a1, a2}, nil)
}
} | [
"func",
"SubtractionConstraint",
"(",
"a1",
"IntegerAttribute",
",",
"a2",
"IntegerAttribute",
",",
"fn",
"func",
"(",
"int",
",",
"int",
")",
"int",
")",
"ArithmeticConstraint",
"{",
"if",
"fn",
"!=",
"nil",
"{",
"return",
"NewArithmeticConstraint",
"(",
"FUN... | //SubtractionConstraint creates a constraint that subtractions two values. The only reason
//to pass the function argument is to create a result that differs from the
//sum by a constant. Note that the function, if provided, must return the
//"difference" as well as subtracting anyok, constants. | [
"SubtractionConstraint",
"creates",
"a",
"constraint",
"that",
"subtractions",
"two",
"values",
".",
"The",
"only",
"reason",
"to",
"pass",
"the",
"function",
"argument",
"is",
"to",
"create",
"a",
"result",
"that",
"differs",
"from",
"the",
"sum",
"by",
"a",
... | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/arith.go#L121-L130 |
154,281 | seven5/seven5 | client/arith.go | SumConstraint | func SumConstraint(attr ...IntegerAttribute) ArithmeticConstraint {
attribute := make([]Attribute, len(attr))
for i, a := range attr {
attribute[i] = Attribute(a)
}
return NewArithmeticConstraint(ADD_OP, attribute, nil)
} | go | func SumConstraint(attr ...IntegerAttribute) ArithmeticConstraint {
attribute := make([]Attribute, len(attr))
for i, a := range attr {
attribute[i] = Attribute(a)
}
return NewArithmeticConstraint(ADD_OP, attribute, nil)
} | [
"func",
"SumConstraint",
"(",
"attr",
"...",
"IntegerAttribute",
")",
"ArithmeticConstraint",
"{",
"attribute",
":=",
"make",
"(",
"[",
"]",
"Attribute",
",",
"len",
"(",
"attr",
")",
")",
"\n",
"for",
"i",
",",
"a",
":=",
"range",
"attr",
"{",
"attribut... | //SumConstraint creates a constraint that add any number of attributes.
//The attribute values are copied so the caller can discard the slice
//after this use. | [
"SumConstraint",
"creates",
"a",
"constraint",
"that",
"add",
"any",
"number",
"of",
"attributes",
".",
"The",
"attribute",
"values",
"are",
"copied",
"so",
"the",
"caller",
"can",
"discard",
"the",
"slice",
"after",
"this",
"use",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/arith.go#L135-L141 |
154,282 | seven5/seven5 | client/arith.go | ProductConstraint | func ProductConstraint(attr ...IntegerAttribute) ArithmeticConstraint {
attribute := make([]Attribute, len(attr))
for i, a := range attr {
attribute[i] = Attribute(a)
}
return NewArithmeticConstraint(MULT_OP, attribute, nil)
} | go | func ProductConstraint(attr ...IntegerAttribute) ArithmeticConstraint {
attribute := make([]Attribute, len(attr))
for i, a := range attr {
attribute[i] = Attribute(a)
}
return NewArithmeticConstraint(MULT_OP, attribute, nil)
} | [
"func",
"ProductConstraint",
"(",
"attr",
"...",
"IntegerAttribute",
")",
"ArithmeticConstraint",
"{",
"attribute",
":=",
"make",
"(",
"[",
"]",
"Attribute",
",",
"len",
"(",
"attr",
")",
")",
"\n",
"for",
"i",
",",
"a",
":=",
"range",
"attr",
"{",
"attr... | //ProductConstraint creates a constraint that multiplies any number of attributes.
//The attribute vaules are copied so the slice can be discarded. | [
"ProductConstraint",
"creates",
"a",
"constraint",
"that",
"multiplies",
"any",
"number",
"of",
"attributes",
".",
"The",
"attribute",
"vaules",
"are",
"copied",
"so",
"the",
"slice",
"can",
"be",
"discarded",
"."
] | 19fef7e1f781b14fc25f545e580cb13f6f11634b | https://github.com/seven5/seven5/blob/19fef7e1f781b14fc25f545e580cb13f6f11634b/client/arith.go#L145-L151 |
154,283 | salsaflow/salsaflow | config/config_local.go | ReadLocalConfig | func ReadLocalConfig() (*LocalConfig, error) {
task := "Read and parse the local configuration file"
// Get the global configuration file absolute path.
path, err := LocalConfigFileAbsolutePath()
if err != nil {
return nil, errs.NewError(task, err)
}
// Read and parse the file.
var local LocalConfig
if err := readAndUnmarshalConfig(path, &local); err != nil {
return nil, errs.NewError(task, err)
}
// Return the config struct.
return &local, nil
} | go | func ReadLocalConfig() (*LocalConfig, error) {
task := "Read and parse the local configuration file"
// Get the global configuration file absolute path.
path, err := LocalConfigFileAbsolutePath()
if err != nil {
return nil, errs.NewError(task, err)
}
// Read and parse the file.
var local LocalConfig
if err := readAndUnmarshalConfig(path, &local); err != nil {
return nil, errs.NewError(task, err)
}
// Return the config struct.
return &local, nil
} | [
"func",
"ReadLocalConfig",
"(",
")",
"(",
"*",
"LocalConfig",
",",
"error",
")",
"{",
"task",
":=",
"\"",
"\"",
"\n\n",
"// Get the global configuration file absolute path.",
"path",
",",
"err",
":=",
"LocalConfigFileAbsolutePath",
"(",
")",
"\n",
"if",
"err",
"... | // ReadLocalConfig reads and parses the global configuration file
// and returns a struct representing the content. | [
"ReadLocalConfig",
"reads",
"and",
"parses",
"the",
"global",
"configuration",
"file",
"and",
"returns",
"a",
"struct",
"representing",
"the",
"content",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/config_local.go#L52-L69 |
154,284 | salsaflow/salsaflow | config/config_local.go | WriteLocalConfig | func WriteLocalConfig(config *LocalConfig) error {
task := "Write the local configuration file"
// Get the local configuration file absolute path.
path, err := LocalConfigFileAbsolutePath()
if err != nil {
return errs.NewError(task, err)
}
// Write the file.
if err := writeConfig(path, config, 0600); err != nil {
return errs.NewError(task, err)
}
return nil
} | go | func WriteLocalConfig(config *LocalConfig) error {
task := "Write the local configuration file"
// Get the local configuration file absolute path.
path, err := LocalConfigFileAbsolutePath()
if err != nil {
return errs.NewError(task, err)
}
// Write the file.
if err := writeConfig(path, config, 0600); err != nil {
return errs.NewError(task, err)
}
return nil
} | [
"func",
"WriteLocalConfig",
"(",
"config",
"*",
"LocalConfig",
")",
"error",
"{",
"task",
":=",
"\"",
"\"",
"\n\n",
"// Get the local configuration file absolute path.",
"path",
",",
"err",
":=",
"LocalConfigFileAbsolutePath",
"(",
")",
"\n",
"if",
"err",
"!=",
"n... | // WriteLocalConfig writes the given configuration struct
// into the global configuration file.
//
// In case the target path does not exist, it is created,
// including the parent directories.
//
// In case the file exists, it is truncated. | [
"WriteLocalConfig",
"writes",
"the",
"given",
"configuration",
"struct",
"into",
"the",
"global",
"configuration",
"file",
".",
"In",
"case",
"the",
"target",
"path",
"does",
"not",
"exist",
"it",
"is",
"created",
"including",
"the",
"parent",
"directories",
"."... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/config_local.go#L78-L93 |
154,285 | salsaflow/salsaflow | config/config_local.go | LocalConfigDirectoryAbsolutePath | func LocalConfigDirectoryAbsolutePath() (string, error) {
root, err := gitutil.RepositoryRootAbsolutePath()
if err != nil {
return "", err
}
return filepath.Join(root, LocalConfigDirname), nil
} | go | func LocalConfigDirectoryAbsolutePath() (string, error) {
root, err := gitutil.RepositoryRootAbsolutePath()
if err != nil {
return "", err
}
return filepath.Join(root, LocalConfigDirname), nil
} | [
"func",
"LocalConfigDirectoryAbsolutePath",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"root",
",",
"err",
":=",
"gitutil",
".",
"RepositoryRootAbsolutePath",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}... | // LocalConfigFileAbsolutePath returns the absolute path
// of the local configuration directory. | [
"LocalConfigFileAbsolutePath",
"returns",
"the",
"absolute",
"path",
"of",
"the",
"local",
"configuration",
"directory",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/config_local.go#L97-L103 |
154,286 | salsaflow/salsaflow | config/config_local.go | LocalConfigFileAbsolutePath | func LocalConfigFileAbsolutePath() (string, error) {
configDir, err := LocalConfigDirectoryAbsolutePath()
if err != nil {
return "", err
}
return filepath.Join(configDir, LocalConfigFilename), nil
} | go | func LocalConfigFileAbsolutePath() (string, error) {
configDir, err := LocalConfigDirectoryAbsolutePath()
if err != nil {
return "", err
}
return filepath.Join(configDir, LocalConfigFilename), nil
} | [
"func",
"LocalConfigFileAbsolutePath",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"configDir",
",",
"err",
":=",
"LocalConfigDirectoryAbsolutePath",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"... | // LocalConfigFileAbsolutePath returns the absolute path
// of the local configuration file. | [
"LocalConfigFileAbsolutePath",
"returns",
"the",
"absolute",
"path",
"of",
"the",
"local",
"configuration",
"file",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/config/config_local.go#L107-L113 |
154,287 | GeoNet/map180 | marker.go | SVGTriangle | func SVGTriangle(m Marker, b *bytes.Buffer) {
w := int(m.size / 2)
h := w * 2
c := int(float64(h) * 0.33)
b.WriteString(fmt.Sprintf("<g id=\"%s\"><path d=\"M%d %d l%d 0 l-%d -%d l-%d %d Z\" fill=\"%s\" opacity=\"0.5\">",
m.id, int(m.x), int(m.y)+c, w, w, h, w, h, m.svgColour))
b.WriteString(`<desc>` + m.label + `.</desc>`)
b.WriteString(fmt.Sprint(`<set attributeName="opacity" from="0.5" to="1" begin="mouseover" end="mouseout" dur="2s"/></path>`))
b.WriteString(fmt.Sprintf("<path d=\"M%d %d l%d 0 l-%d -%d l-%d %d Z\" stroke=\"%s\" stroke-width=\"1\" fill=\"none\" opacity=\"1\" /></g>",
int(m.x), int(m.y)+c, w, w, h, w, h, m.svgColour))
} | go | func SVGTriangle(m Marker, b *bytes.Buffer) {
w := int(m.size / 2)
h := w * 2
c := int(float64(h) * 0.33)
b.WriteString(fmt.Sprintf("<g id=\"%s\"><path d=\"M%d %d l%d 0 l-%d -%d l-%d %d Z\" fill=\"%s\" opacity=\"0.5\">",
m.id, int(m.x), int(m.y)+c, w, w, h, w, h, m.svgColour))
b.WriteString(`<desc>` + m.label + `.</desc>`)
b.WriteString(fmt.Sprint(`<set attributeName="opacity" from="0.5" to="1" begin="mouseover" end="mouseout" dur="2s"/></path>`))
b.WriteString(fmt.Sprintf("<path d=\"M%d %d l%d 0 l-%d -%d l-%d %d Z\" stroke=\"%s\" stroke-width=\"1\" fill=\"none\" opacity=\"1\" /></g>",
int(m.x), int(m.y)+c, w, w, h, w, h, m.svgColour))
} | [
"func",
"SVGTriangle",
"(",
"m",
"Marker",
",",
"b",
"*",
"bytes",
".",
"Buffer",
")",
"{",
"w",
":=",
"int",
"(",
"m",
".",
"size",
"/",
"2",
")",
"\n",
"h",
":=",
"w",
"*",
"2",
"\n",
"c",
":=",
"int",
"(",
"float64",
"(",
"h",
")",
"*",
... | // SVGTriangle is an SVGMarker func. | [
"SVGTriangle",
"is",
"an",
"SVGMarker",
"func",
"."
] | 9dfd58c339375915a35c96438b0db973c4ece9d4 | https://github.com/GeoNet/map180/blob/9dfd58c339375915a35c96438b0db973c4ece9d4/marker.go#L59-L70 |
154,288 | GeoNet/map180 | marker.go | labelMarkers | func labelMarkers(m []Marker, x, y int, anchor string, fontSize int, short bool, b *bytes.Buffer) {
b.WriteString(`<g id="marker_labels">`)
for _, mr := range m {
b.WriteString(fmt.Sprintf("<text x=\"%d\" y=\"%d\" font-size=\"%d\" visibility=\"hidden\" text-anchor=\"%s\">", x, y, fontSize, anchor))
if short {
b.WriteString(mr.shortLabel)
} else {
b.WriteString(mr.label)
}
b.WriteString(fmt.Sprintf("<set attributeName=\"visibility\" from=\"hidden\" to=\"visible\" begin=\"%s.mouseover\" end=\"%s.mouseout\" dur=\"2s\"/>",
mr.id, mr.id))
b.WriteString(`</text>`)
}
b.WriteString(`</g>`)
} | go | func labelMarkers(m []Marker, x, y int, anchor string, fontSize int, short bool, b *bytes.Buffer) {
b.WriteString(`<g id="marker_labels">`)
for _, mr := range m {
b.WriteString(fmt.Sprintf("<text x=\"%d\" y=\"%d\" font-size=\"%d\" visibility=\"hidden\" text-anchor=\"%s\">", x, y, fontSize, anchor))
if short {
b.WriteString(mr.shortLabel)
} else {
b.WriteString(mr.label)
}
b.WriteString(fmt.Sprintf("<set attributeName=\"visibility\" from=\"hidden\" to=\"visible\" begin=\"%s.mouseover\" end=\"%s.mouseout\" dur=\"2s\"/>",
mr.id, mr.id))
b.WriteString(`</text>`)
}
b.WriteString(`</g>`)
} | [
"func",
"labelMarkers",
"(",
"m",
"[",
"]",
"Marker",
",",
"x",
",",
"y",
"int",
",",
"anchor",
"string",
",",
"fontSize",
"int",
",",
"short",
"bool",
",",
"b",
"*",
"bytes",
".",
"Buffer",
")",
"{",
"b",
".",
"WriteString",
"(",
"`<g id=\"marker_la... | // puts the label or short label on the SVG image all at the same place.
// labels are made visible using mouseover on the marker with the same id. | [
"puts",
"the",
"label",
"or",
"short",
"label",
"on",
"the",
"SVG",
"image",
"all",
"at",
"the",
"same",
"place",
".",
"labels",
"are",
"made",
"visible",
"using",
"mouseover",
"on",
"the",
"marker",
"with",
"the",
"same",
"id",
"."
] | 9dfd58c339375915a35c96438b0db973c4ece9d4 | https://github.com/GeoNet/map180/blob/9dfd58c339375915a35c96438b0db973c4ece9d4/marker.go#L74-L88 |
154,289 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | first | func (ss *streamSafe) first(p Properties) {
if *ss != 0 {
panic("!= 0")
}
*ss = streamSafe(p.nTrailingNonStarters())
} | go | func (ss *streamSafe) first(p Properties) {
if *ss != 0 {
panic("!= 0")
}
*ss = streamSafe(p.nTrailingNonStarters())
} | [
"func",
"(",
"ss",
"*",
"streamSafe",
")",
"first",
"(",
"p",
"Properties",
")",
"{",
"if",
"*",
"ss",
"!=",
"0",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"*",
"ss",
"=",
"streamSafe",
"(",
"p",
".",
"nTrailingNonStarters",
"(",
")",
... | // first inserts the first rune of a segment. | [
"first",
"inserts",
"the",
"first",
"rune",
"of",
"a",
"segment",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L43-L48 |
154,290 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | next | func (ss *streamSafe) next(p Properties) ssState {
if *ss > maxNonStarters {
panic("streamSafe was not reset")
}
n := p.nLeadingNonStarters()
if *ss += streamSafe(n); *ss > maxNonStarters {
*ss = 0
return ssOverflow
}
// The Stream-Safe Text Processing prescribes that the counting can stop
// as soon as a starter is encountered. However, there are some starters,
// like Jamo V and T, that can combine with other runes, leaving their
// successive non-starters appended to the previous, possibly causing an
// overflow. We will therefore consider any rune with a non-zero nLead to
// be a non-starter. Note that it always hold that if nLead > 0 then
// nLead == nTrail.
if n == 0 {
*ss = 0
return ssStarter
}
return ssSuccess
} | go | func (ss *streamSafe) next(p Properties) ssState {
if *ss > maxNonStarters {
panic("streamSafe was not reset")
}
n := p.nLeadingNonStarters()
if *ss += streamSafe(n); *ss > maxNonStarters {
*ss = 0
return ssOverflow
}
// The Stream-Safe Text Processing prescribes that the counting can stop
// as soon as a starter is encountered. However, there are some starters,
// like Jamo V and T, that can combine with other runes, leaving their
// successive non-starters appended to the previous, possibly causing an
// overflow. We will therefore consider any rune with a non-zero nLead to
// be a non-starter. Note that it always hold that if nLead > 0 then
// nLead == nTrail.
if n == 0 {
*ss = 0
return ssStarter
}
return ssSuccess
} | [
"func",
"(",
"ss",
"*",
"streamSafe",
")",
"next",
"(",
"p",
"Properties",
")",
"ssState",
"{",
"if",
"*",
"ss",
">",
"maxNonStarters",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"n",
":=",
"p",
".",
"nLeadingNonStarters",
"(",
")",
"\n",... | // insert returns a ssState value to indicate whether a rune represented by p
// can be inserted. | [
"insert",
"returns",
"a",
"ssState",
"value",
"to",
"indicate",
"whether",
"a",
"rune",
"represented",
"by",
"p",
"can",
"be",
"inserted",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L52-L73 |
154,291 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | backwards | func (ss *streamSafe) backwards(p Properties) ssState {
if *ss > maxNonStarters {
panic("streamSafe was not reset")
}
c := *ss + streamSafe(p.nTrailingNonStarters())
if c > maxNonStarters {
return ssOverflow
}
*ss = c
if p.nLeadingNonStarters() == 0 {
return ssStarter
}
return ssSuccess
} | go | func (ss *streamSafe) backwards(p Properties) ssState {
if *ss > maxNonStarters {
panic("streamSafe was not reset")
}
c := *ss + streamSafe(p.nTrailingNonStarters())
if c > maxNonStarters {
return ssOverflow
}
*ss = c
if p.nLeadingNonStarters() == 0 {
return ssStarter
}
return ssSuccess
} | [
"func",
"(",
"ss",
"*",
"streamSafe",
")",
"backwards",
"(",
"p",
"Properties",
")",
"ssState",
"{",
"if",
"*",
"ss",
">",
"maxNonStarters",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"c",
":=",
"*",
"ss",
"+",
"streamSafe",
"(",
"p",
"... | // backwards is used for checking for overflow and segment starts
// when traversing a string backwards. Users do not need to call first
// for the first rune. The state of the streamSafe retains the count of
// the non-starters loaded. | [
"backwards",
"is",
"used",
"for",
"checking",
"for",
"overflow",
"and",
"segment",
"starts",
"when",
"traversing",
"a",
"string",
"backwards",
".",
"Users",
"do",
"not",
"need",
"to",
"call",
"first",
"for",
"the",
"first",
"rune",
".",
"The",
"state",
"of... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L79-L92 |
154,292 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | appendFlush | func appendFlush(rb *reorderBuffer) bool {
for i := 0; i < rb.nrune; i++ {
start := rb.rune[i].pos
end := start + rb.rune[i].size
rb.out = append(rb.out, rb.byte[start:end]...)
}
return true
} | go | func appendFlush(rb *reorderBuffer) bool {
for i := 0; i < rb.nrune; i++ {
start := rb.rune[i].pos
end := start + rb.rune[i].size
rb.out = append(rb.out, rb.byte[start:end]...)
}
return true
} | [
"func",
"appendFlush",
"(",
"rb",
"*",
"reorderBuffer",
")",
"bool",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"rb",
".",
"nrune",
";",
"i",
"++",
"{",
"start",
":=",
"rb",
".",
"rune",
"[",
"i",
"]",
".",
"pos",
"\n",
"end",
":=",
"start",
... | // appendFlush appends the normalized segment to rb.out. | [
"appendFlush",
"appends",
"the",
"normalized",
"segment",
"to",
"rb",
".",
"out",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L158-L165 |
154,293 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | flush | func (rb *reorderBuffer) flush(out []byte) []byte {
for i := 0; i < rb.nrune; i++ {
start := rb.rune[i].pos
end := start + rb.rune[i].size
out = append(out, rb.byte[start:end]...)
}
rb.reset()
return out
} | go | func (rb *reorderBuffer) flush(out []byte) []byte {
for i := 0; i < rb.nrune; i++ {
start := rb.rune[i].pos
end := start + rb.rune[i].size
out = append(out, rb.byte[start:end]...)
}
rb.reset()
return out
} | [
"func",
"(",
"rb",
"*",
"reorderBuffer",
")",
"flush",
"(",
"out",
"[",
"]",
"byte",
")",
"[",
"]",
"byte",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"rb",
".",
"nrune",
";",
"i",
"++",
"{",
"start",
":=",
"rb",
".",
"rune",
"[",
"i",
"]",... | // flush appends the normalized segment to out and resets rb. | [
"flush",
"appends",
"the",
"normalized",
"segment",
"to",
"out",
"and",
"resets",
"rb",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L168-L176 |
154,294 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | flushCopy | func (rb *reorderBuffer) flushCopy(buf []byte) int {
p := 0
for i := 0; i < rb.nrune; i++ {
runep := rb.rune[i]
p += copy(buf[p:], rb.byte[runep.pos:runep.pos+runep.size])
}
rb.reset()
return p
} | go | func (rb *reorderBuffer) flushCopy(buf []byte) int {
p := 0
for i := 0; i < rb.nrune; i++ {
runep := rb.rune[i]
p += copy(buf[p:], rb.byte[runep.pos:runep.pos+runep.size])
}
rb.reset()
return p
} | [
"func",
"(",
"rb",
"*",
"reorderBuffer",
")",
"flushCopy",
"(",
"buf",
"[",
"]",
"byte",
")",
"int",
"{",
"p",
":=",
"0",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"rb",
".",
"nrune",
";",
"i",
"++",
"{",
"runep",
":=",
"rb",
".",
"rune",
... | // flushCopy copies the normalized segment to buf and resets rb.
// It returns the number of bytes written to buf. | [
"flushCopy",
"copies",
"the",
"normalized",
"segment",
"to",
"buf",
"and",
"resets",
"rb",
".",
"It",
"returns",
"the",
"number",
"of",
"bytes",
"written",
"to",
"buf",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L180-L188 |
154,295 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | insertOrdered | func (rb *reorderBuffer) insertOrdered(info Properties) {
n := rb.nrune
b := rb.rune[:]
cc := info.ccc
if cc > 0 {
// Find insertion position + move elements to make room.
for ; n > 0; n-- {
if b[n-1].ccc <= cc {
break
}
b[n] = b[n-1]
}
}
rb.nrune += 1
pos := uint8(rb.nbyte)
rb.nbyte += utf8.UTFMax
info.pos = pos
b[n] = info
} | go | func (rb *reorderBuffer) insertOrdered(info Properties) {
n := rb.nrune
b := rb.rune[:]
cc := info.ccc
if cc > 0 {
// Find insertion position + move elements to make room.
for ; n > 0; n-- {
if b[n-1].ccc <= cc {
break
}
b[n] = b[n-1]
}
}
rb.nrune += 1
pos := uint8(rb.nbyte)
rb.nbyte += utf8.UTFMax
info.pos = pos
b[n] = info
} | [
"func",
"(",
"rb",
"*",
"reorderBuffer",
")",
"insertOrdered",
"(",
"info",
"Properties",
")",
"{",
"n",
":=",
"rb",
".",
"nrune",
"\n",
"b",
":=",
"rb",
".",
"rune",
"[",
":",
"]",
"\n",
"cc",
":=",
"info",
".",
"ccc",
"\n",
"if",
"cc",
">",
"... | // insertOrdered inserts a rune in the buffer, ordered by Canonical Combining Class.
// It returns false if the buffer is not large enough to hold the rune.
// It is used internally by insert and insertString only. | [
"insertOrdered",
"inserts",
"a",
"rune",
"in",
"the",
"buffer",
"ordered",
"by",
"Canonical",
"Combining",
"Class",
".",
"It",
"returns",
"false",
"if",
"the",
"buffer",
"is",
"not",
"large",
"enough",
"to",
"hold",
"the",
"rune",
".",
"It",
"is",
"used",
... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L193-L211 |
154,296 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | insertFlush | func (rb *reorderBuffer) insertFlush(src input, i int, info Properties) insertErr {
if rune := src.hangul(i); rune != 0 {
rb.decomposeHangul(rune)
return iSuccess
}
if info.hasDecomposition() {
return rb.insertDecomposed(info.Decomposition())
}
rb.insertSingle(src, i, info)
return iSuccess
} | go | func (rb *reorderBuffer) insertFlush(src input, i int, info Properties) insertErr {
if rune := src.hangul(i); rune != 0 {
rb.decomposeHangul(rune)
return iSuccess
}
if info.hasDecomposition() {
return rb.insertDecomposed(info.Decomposition())
}
rb.insertSingle(src, i, info)
return iSuccess
} | [
"func",
"(",
"rb",
"*",
"reorderBuffer",
")",
"insertFlush",
"(",
"src",
"input",
",",
"i",
"int",
",",
"info",
"Properties",
")",
"insertErr",
"{",
"if",
"rune",
":=",
"src",
".",
"hangul",
"(",
"i",
")",
";",
"rune",
"!=",
"0",
"{",
"rb",
".",
... | // insertFlush inserts the given rune in the buffer ordered by CCC.
// If a decomposition with multiple segments are encountered, they leading
// ones are flushed.
// It returns a non-zero error code if the rune was not inserted. | [
"insertFlush",
"inserts",
"the",
"given",
"rune",
"in",
"the",
"buffer",
"ordered",
"by",
"CCC",
".",
"If",
"a",
"decomposition",
"with",
"multiple",
"segments",
"are",
"encountered",
"they",
"leading",
"ones",
"are",
"flushed",
".",
"It",
"returns",
"a",
"n... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L227-L237 |
154,297 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | insertUnsafe | func (rb *reorderBuffer) insertUnsafe(src input, i int, info Properties) {
if rune := src.hangul(i); rune != 0 {
rb.decomposeHangul(rune)
}
if info.hasDecomposition() {
// TODO: inline.
rb.insertDecomposed(info.Decomposition())
} else {
rb.insertSingle(src, i, info)
}
} | go | func (rb *reorderBuffer) insertUnsafe(src input, i int, info Properties) {
if rune := src.hangul(i); rune != 0 {
rb.decomposeHangul(rune)
}
if info.hasDecomposition() {
// TODO: inline.
rb.insertDecomposed(info.Decomposition())
} else {
rb.insertSingle(src, i, info)
}
} | [
"func",
"(",
"rb",
"*",
"reorderBuffer",
")",
"insertUnsafe",
"(",
"src",
"input",
",",
"i",
"int",
",",
"info",
"Properties",
")",
"{",
"if",
"rune",
":=",
"src",
".",
"hangul",
"(",
"i",
")",
";",
"rune",
"!=",
"0",
"{",
"rb",
".",
"decomposeHang... | // insertUnsafe inserts the given rune in the buffer ordered by CCC.
// It is assumed there is sufficient space to hold the runes. It is the
// responsibility of the caller to ensure this. This can be done by checking
// the state returned by the streamSafe type. | [
"insertUnsafe",
"inserts",
"the",
"given",
"rune",
"in",
"the",
"buffer",
"ordered",
"by",
"CCC",
".",
"It",
"is",
"assumed",
"there",
"is",
"sufficient",
"space",
"to",
"hold",
"the",
"runes",
".",
"It",
"is",
"the",
"responsibility",
"of",
"the",
"caller... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L243-L253 |
154,298 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | insertDecomposed | func (rb *reorderBuffer) insertDecomposed(dcomp []byte) insertErr {
rb.tmpBytes.setBytes(dcomp)
for i := 0; i < len(dcomp); {
info := rb.f.info(rb.tmpBytes, i)
if info.BoundaryBefore() && rb.nrune > 0 && !rb.doFlush() {
return iShortDst
}
i += copy(rb.byte[rb.nbyte:], dcomp[i:i+int(info.size)])
rb.insertOrdered(info)
}
return iSuccess
} | go | func (rb *reorderBuffer) insertDecomposed(dcomp []byte) insertErr {
rb.tmpBytes.setBytes(dcomp)
for i := 0; i < len(dcomp); {
info := rb.f.info(rb.tmpBytes, i)
if info.BoundaryBefore() && rb.nrune > 0 && !rb.doFlush() {
return iShortDst
}
i += copy(rb.byte[rb.nbyte:], dcomp[i:i+int(info.size)])
rb.insertOrdered(info)
}
return iSuccess
} | [
"func",
"(",
"rb",
"*",
"reorderBuffer",
")",
"insertDecomposed",
"(",
"dcomp",
"[",
"]",
"byte",
")",
"insertErr",
"{",
"rb",
".",
"tmpBytes",
".",
"setBytes",
"(",
"dcomp",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"dcomp",
")"... | // insertDecomposed inserts an entry in to the reorderBuffer for each rune
// in dcomp. dcomp must be a sequence of decomposed UTF-8-encoded runes.
// It flushes the buffer on each new segment start. | [
"insertDecomposed",
"inserts",
"an",
"entry",
"in",
"to",
"the",
"reorderBuffer",
"for",
"each",
"rune",
"in",
"dcomp",
".",
"dcomp",
"must",
"be",
"a",
"sequence",
"of",
"decomposed",
"UTF",
"-",
"8",
"-",
"encoded",
"runes",
".",
"It",
"flushes",
"the",
... | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L258-L269 |
154,299 | salsaflow/salsaflow | Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go | insertSingle | func (rb *reorderBuffer) insertSingle(src input, i int, info Properties) {
src.copySlice(rb.byte[rb.nbyte:], i, i+int(info.size))
rb.insertOrdered(info)
} | go | func (rb *reorderBuffer) insertSingle(src input, i int, info Properties) {
src.copySlice(rb.byte[rb.nbyte:], i, i+int(info.size))
rb.insertOrdered(info)
} | [
"func",
"(",
"rb",
"*",
"reorderBuffer",
")",
"insertSingle",
"(",
"src",
"input",
",",
"i",
"int",
",",
"info",
"Properties",
")",
"{",
"src",
".",
"copySlice",
"(",
"rb",
".",
"byte",
"[",
"rb",
".",
"nbyte",
":",
"]",
",",
"i",
",",
"i",
"+",
... | // insertSingle inserts an entry in the reorderBuffer for the rune at
// position i. info is the runeInfo for the rune at position i. | [
"insertSingle",
"inserts",
"an",
"entry",
"in",
"the",
"reorderBuffer",
"for",
"the",
"rune",
"at",
"position",
"i",
".",
"info",
"is",
"the",
"runeInfo",
"for",
"the",
"rune",
"at",
"position",
"i",
"."
] | 1bc3d9415e3e35b5aad7b724c2955b1f53ccd145 | https://github.com/salsaflow/salsaflow/blob/1bc3d9415e3e35b5aad7b724c2955b1f53ccd145/Godeps/_workspace/src/golang.org/x/text/unicode/norm/composition.go#L273-L276 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.