id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
140,100 | rsc/rsc | cloudprint/print.go | UpdateJob | func (s *Server) UpdateJob(j *Job, status JobStatus, code int, message string) error {
var mr multipartRequest
mr.init()
mr.WriteField("jobid", j.ID)
mr.WriteField("printerid", j.PrinterID)
mr.WriteField("status", string(status))
if status == JobError {
mr.WriteField("code", fmt.Sprint(code))
mr.WriteField("m... | go | func (s *Server) UpdateJob(j *Job, status JobStatus, code int, message string) error {
var mr multipartRequest
mr.init()
mr.WriteField("jobid", j.ID)
mr.WriteField("printerid", j.PrinterID)
mr.WriteField("status", string(status))
if status == JobError {
mr.WriteField("code", fmt.Sprint(code))
mr.WriteField("m... | [
"func",
"(",
"s",
"*",
"Server",
")",
"UpdateJob",
"(",
"j",
"*",
"Job",
",",
"status",
"JobStatus",
",",
"code",
"int",
",",
"message",
"string",
")",
"error",
"{",
"var",
"mr",
"multipartRequest",
"\n",
"mr",
".",
"init",
"(",
")",
"\n",
"mr",
".... | // UpdateJob updates information about the given job.
// The only field that is stored back to the server is j.Status. | [
"UpdateJob",
"updates",
"information",
"about",
"the",
"given",
"job",
".",
"The",
"only",
"field",
"that",
"is",
"stored",
"back",
"to",
"the",
"server",
"is",
"j",
".",
"Status",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cloudprint/print.go#L460-L476 |
140,101 | rsc/rsc | cloudprint/print.go | ReadFile | func (s *Server) ReadFile(j *Job) ([]byte, error) {
data, err := httpGET(&s.auth, j.FileURL)
if err != nil {
return nil, fmt.Errorf("ReadFile: %v", err)
}
return data, nil
} | go | func (s *Server) ReadFile(j *Job) ([]byte, error) {
data, err := httpGET(&s.auth, j.FileURL)
if err != nil {
return nil, fmt.Errorf("ReadFile: %v", err)
}
return data, nil
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"ReadFile",
"(",
"j",
"*",
"Job",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"data",
",",
"err",
":=",
"httpGET",
"(",
"&",
"s",
".",
"auth",
",",
"j",
".",
"FileURL",
")",
"\n",
"if",
"err",
"... | // ReadFile reads the raw data to be printed by the given job. | [
"ReadFile",
"reads",
"the",
"raw",
"data",
"to",
"be",
"printed",
"by",
"the",
"given",
"job",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cloudprint/print.go#L479-L485 |
140,102 | rsc/rsc | cloudprint/print.go | NewClient | func NewClient(auth Auth) (*Client, error) {
c := &Client{
auth: auth,
}
return c, nil
} | go | func NewClient(auth Auth) (*Client, error) {
c := &Client{
auth: auth,
}
return c, nil
} | [
"func",
"NewClient",
"(",
"auth",
"Auth",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"c",
":=",
"&",
"Client",
"{",
"auth",
":",
"auth",
",",
"}",
"\n",
"return",
"c",
",",
"nil",
"\n",
"}"
] | // NewClient returns a new client using the given auth information. | [
"NewClient",
"returns",
"a",
"new",
"client",
"using",
"the",
"given",
"auth",
"information",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cloudprint/print.go#L493-L498 |
140,103 | rsc/rsc | cloudprint/print.go | Search | func (c *Client) Search(query string, all bool) ([]*Printer, error) {
var mr multipartRequest
mr.init()
if query != "" {
mr.WriteField("q", query)
}
if all {
mr.WriteField("connection_status", "ALL")
}
var resp printersResponse
err := jsonRPC(&c.auth, "POST", cloudprintURL+"/search", &mr, &resp)
if err != ... | go | func (c *Client) Search(query string, all bool) ([]*Printer, error) {
var mr multipartRequest
mr.init()
if query != "" {
mr.WriteField("q", query)
}
if all {
mr.WriteField("connection_status", "ALL")
}
var resp printersResponse
err := jsonRPC(&c.auth, "POST", cloudprintURL+"/search", &mr, &resp)
if err != ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Search",
"(",
"query",
"string",
",",
"all",
"bool",
")",
"(",
"[",
"]",
"*",
"Printer",
",",
"error",
")",
"{",
"var",
"mr",
"multipartRequest",
"\n",
"mr",
".",
"init",
"(",
")",
"\n",
"if",
"query",
"!=",... | // Search searches for printers the client can use.
// The query can be empty to return all printers.
// By default only printers that have been online recently are returned.
// To return all printers, pass all = true. | [
"Search",
"searches",
"for",
"printers",
"the",
"client",
"can",
"use",
".",
"The",
"query",
"can",
"be",
"empty",
"to",
"return",
"all",
"printers",
".",
"By",
"default",
"only",
"printers",
"that",
"have",
"been",
"online",
"recently",
"are",
"returned",
... | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cloudprint/print.go#L504-L523 |
140,104 | rsc/rsc | cloudprint/print.go | Printer | func (c *Client) Printer(id string) (*Printer, error) {
var mr multipartRequest
mr.init()
mr.WriteField("printerid", id)
mr.WriteField("printer_connection_Status", "true")
var resp printersResponse
err := jsonRPC(&c.auth, "POST", cloudprintURL+"/printer", &mr, &resp)
if err != nil {
return nil, fmt.Errorf("Pri... | go | func (c *Client) Printer(id string) (*Printer, error) {
var mr multipartRequest
mr.init()
mr.WriteField("printerid", id)
mr.WriteField("printer_connection_Status", "true")
var resp printersResponse
err := jsonRPC(&c.auth, "POST", cloudprintURL+"/printer", &mr, &resp)
if err != nil {
return nil, fmt.Errorf("Pri... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Printer",
"(",
"id",
"string",
")",
"(",
"*",
"Printer",
",",
"error",
")",
"{",
"var",
"mr",
"multipartRequest",
"\n",
"mr",
".",
"init",
"(",
")",
"\n",
"mr",
".",
"WriteField",
"(",
"\"",
"\"",
",",
"id",... | // Printer searches for the printer with the given ID. | [
"Printer",
"searches",
"for",
"the",
"printer",
"with",
"the",
"given",
"ID",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cloudprint/print.go#L526-L540 |
140,105 | rsc/rsc | cloudprint/print.go | DeleteJob | func (c *Client) DeleteJob(j *Job) error {
var mr multipartRequest
mr.init()
mr.WriteField("jobid", j.ID)
mr.WriteField("printerid", j.PrinterID)
err := jsonRPC(&c.auth, "POST", cloudprintURL+"/deletejob", &mr, nil)
if err != nil {
return fmt.Errorf("DeleteJob: %v", err)
}
return nil
} | go | func (c *Client) DeleteJob(j *Job) error {
var mr multipartRequest
mr.init()
mr.WriteField("jobid", j.ID)
mr.WriteField("printerid", j.PrinterID)
err := jsonRPC(&c.auth, "POST", cloudprintURL+"/deletejob", &mr, nil)
if err != nil {
return fmt.Errorf("DeleteJob: %v", err)
}
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteJob",
"(",
"j",
"*",
"Job",
")",
"error",
"{",
"var",
"mr",
"multipartRequest",
"\n",
"mr",
".",
"init",
"(",
")",
"\n",
"mr",
".",
"WriteField",
"(",
"\"",
"\"",
",",
"j",
".",
"ID",
")",
"\n",
"mr"... | // DeleteJob deletes the given print job. | [
"DeleteJob",
"deletes",
"the",
"given",
"print",
"job",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cloudprint/print.go#L548-L558 |
140,106 | rsc/rsc | cloudprint/print.go | Jobs | func (c *Client) Jobs(p *Printer) ([]*Job, error) {
var mr multipartRequest
mr.init()
if p != nil {
mr.WriteField("printerid", p.ID)
}
var resp jobsResponse
err := jsonRPC(&c.auth, "POST", cloudprintURL+"/jobs", &mr, &resp)
if err != nil {
return nil, fmt.Errorf("Jobs: %v", err)
}
var jobs []*Job
for _, d... | go | func (c *Client) Jobs(p *Printer) ([]*Job, error) {
var mr multipartRequest
mr.init()
if p != nil {
mr.WriteField("printerid", p.ID)
}
var resp jobsResponse
err := jsonRPC(&c.auth, "POST", cloudprintURL+"/jobs", &mr, &resp)
if err != nil {
return nil, fmt.Errorf("Jobs: %v", err)
}
var jobs []*Job
for _, d... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Jobs",
"(",
"p",
"*",
"Printer",
")",
"(",
"[",
"]",
"*",
"Job",
",",
"error",
")",
"{",
"var",
"mr",
"multipartRequest",
"\n",
"mr",
".",
"init",
"(",
")",
"\n",
"if",
"p",
"!=",
"nil",
"{",
"mr",
".",
... | // Jobs returns a list of jobs waiting to be printed.
// If p is not nil, the list is restricted to jobs sent to the given printer. | [
"Jobs",
"returns",
"a",
"list",
"of",
"jobs",
"waiting",
"to",
"be",
"printed",
".",
"If",
"p",
"is",
"not",
"nil",
"the",
"list",
"is",
"restricted",
"to",
"jobs",
"sent",
"to",
"the",
"given",
"printer",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cloudprint/print.go#L562-L578 |
140,107 | rsc/rsc | cloudprint/print.go | Print | func (c *Client) Print(p *Printer, info *JobInfo, data []byte) (*Job, error) {
var mr multipartRequest
mr.init()
mr.WriteField("printerid", p.ID)
mr.WriteField("title", info.Title)
mr.WriteField("contentType", "application/pdf")
for _, tag := range info.Tags {
mr.WriteField("tag", tag)
}
cap := info.Capabilit... | go | func (c *Client) Print(p *Printer, info *JobInfo, data []byte) (*Job, error) {
var mr multipartRequest
mr.init()
mr.WriteField("printerid", p.ID)
mr.WriteField("title", info.Title)
mr.WriteField("contentType", "application/pdf")
for _, tag := range info.Tags {
mr.WriteField("tag", tag)
}
cap := info.Capabilit... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Print",
"(",
"p",
"*",
"Printer",
",",
"info",
"*",
"JobInfo",
",",
"data",
"[",
"]",
"byte",
")",
"(",
"*",
"Job",
",",
"error",
")",
"{",
"var",
"mr",
"multipartRequest",
"\n",
"mr",
".",
"init",
"(",
")... | // Print creates a new print job printing to p with the given job information.
// The data is the raw PDF to print. | [
"Print",
"creates",
"a",
"new",
"print",
"job",
"printing",
"to",
"p",
"with",
"the",
"given",
"job",
"information",
".",
"The",
"data",
"is",
"the",
"raw",
"PDF",
"to",
"print",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cloudprint/print.go#L594-L619 |
140,108 | rsc/rsc | cc/parse.go | removeDuplicates | func removeDuplicates(prog *Prog) {
count := map[*Decl]int{}
for _, d := range prog.Decls {
count[d]++
}
var out []*Decl
for _, d := range prog.Decls {
count[d]--
if count[d] == 0 {
out = append(out, d)
}
}
prog.Decls = out
} | go | func removeDuplicates(prog *Prog) {
count := map[*Decl]int{}
for _, d := range prog.Decls {
count[d]++
}
var out []*Decl
for _, d := range prog.Decls {
count[d]--
if count[d] == 0 {
out = append(out, d)
}
}
prog.Decls = out
} | [
"func",
"removeDuplicates",
"(",
"prog",
"*",
"Prog",
")",
"{",
"count",
":=",
"map",
"[",
"*",
"Decl",
"]",
"int",
"{",
"}",
"\n",
"for",
"_",
",",
"d",
":=",
"range",
"prog",
".",
"Decls",
"{",
"count",
"[",
"d",
"]",
"++",
"\n",
"}",
"\n",
... | // removeDuplicates drops the duplicated declarations
// caused by forward decls from prog.
// It keeps the _last_ of each given declaration,
// assuming that's the complete one.
// This heuristic tends to preserve something like
// source order.
// It would be defeated by someone writing a "forward"
// declaration fol... | [
"removeDuplicates",
"drops",
"the",
"duplicated",
"declarations",
"caused",
"by",
"forward",
"decls",
"from",
"prog",
".",
"It",
"keeps",
"the",
"_last_",
"of",
"each",
"given",
"declaration",
"assuming",
"that",
"s",
"the",
"complete",
"one",
".",
"This",
"he... | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cc/parse.go#L102-L115 |
140,109 | rsc/rsc | rosetta/maze/maze.go | move | func (m *Maze) move(x, y int, dir Dir) (nx, ny int, ok bool) {
nx = x + dirs[dir].δx
ny = y + dirs[dir].δy
ok = 0 <= nx && nx < m.w && 0 <= ny && ny < m.h
return
} | go | func (m *Maze) move(x, y int, dir Dir) (nx, ny int, ok bool) {
nx = x + dirs[dir].δx
ny = y + dirs[dir].δy
ok = 0 <= nx && nx < m.w && 0 <= ny && ny < m.h
return
} | [
"func",
"(",
"m",
"*",
"Maze",
")",
"move",
"(",
"x",
",",
"y",
"int",
",",
"dir",
"Dir",
")",
"(",
"nx",
",",
"ny",
"int",
",",
"ok",
"bool",
")",
"{",
"nx",
"=",
"x",
"+",
"dirs",
"[",
"dir",
"]",
".",
"δx",
"\n",
"ny",
"=",
"y",
"+",... | // move returns the cell in the direction dir from position r, c.
// It returns ok==false if there is no cell in that direction. | [
"move",
"returns",
"the",
"cell",
"in",
"the",
"direction",
"dir",
"from",
"position",
"r",
"c",
".",
"It",
"returns",
"ok",
"==",
"false",
"if",
"there",
"is",
"no",
"cell",
"in",
"that",
"direction",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/rosetta/maze/maze.go#L52-L57 |
140,110 | rsc/rsc | rosetta/maze/maze.go | Move | func (m *Maze) Move(x, y int, dir Dir) (nx, ny int, ok bool) {
nx, ny, ok = m.move(x, y, dir)
ok = ok && m.grid[y][x]&(1<<dir) == 0
return
} | go | func (m *Maze) Move(x, y int, dir Dir) (nx, ny int, ok bool) {
nx, ny, ok = m.move(x, y, dir)
ok = ok && m.grid[y][x]&(1<<dir) == 0
return
} | [
"func",
"(",
"m",
"*",
"Maze",
")",
"Move",
"(",
"x",
",",
"y",
"int",
",",
"dir",
"Dir",
")",
"(",
"nx",
",",
"ny",
"int",
",",
"ok",
"bool",
")",
"{",
"nx",
",",
"ny",
",",
"ok",
"=",
"m",
".",
"move",
"(",
"x",
",",
"y",
",",
"dir",
... | // Move returns the cell in the direction dir from position x, y
// It returns ok==false if there is no cell in that direction
// or if a wall blocks movement in that direction. | [
"Move",
"returns",
"the",
"cell",
"in",
"the",
"direction",
"dir",
"from",
"position",
"x",
"y",
"It",
"returns",
"ok",
"==",
"false",
"if",
"there",
"is",
"no",
"cell",
"in",
"that",
"direction",
"or",
"if",
"a",
"wall",
"blocks",
"movement",
"in",
"t... | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/rosetta/maze/maze.go#L62-L66 |
140,111 | rsc/rsc | rosetta/maze/maze.go | NewMaze | func NewMaze(w, h int) *Maze {
// Allocate one slice for the whole 2-d cell grid and break up into rows.
all := make([]walls, w*h)
for i := range all {
all[i] = allWalls
}
m := &Maze{w: w, h: h, grid: make([][]walls, h)}
for i := range m.grid {
m.grid[i], all = all[:w], all[w:]
}
// All cells start with al... | go | func NewMaze(w, h int) *Maze {
// Allocate one slice for the whole 2-d cell grid and break up into rows.
all := make([]walls, w*h)
for i := range all {
all[i] = allWalls
}
m := &Maze{w: w, h: h, grid: make([][]walls, h)}
for i := range m.grid {
m.grid[i], all = all[:w], all[w:]
}
// All cells start with al... | [
"func",
"NewMaze",
"(",
"w",
",",
"h",
"int",
")",
"*",
"Maze",
"{",
"// Allocate one slice for the whole 2-d cell grid and break up into rows.",
"all",
":=",
"make",
"(",
"[",
"]",
"walls",
",",
"w",
"*",
"h",
")",
"\n",
"for",
"i",
":=",
"range",
"all",
... | // NewMaze returns a new, randomly generated maze
// of width w and height h. | [
"NewMaze",
"returns",
"a",
"new",
"randomly",
"generated",
"maze",
"of",
"width",
"w",
"and",
"height",
"h",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/rosetta/maze/maze.go#L70-L85 |
140,112 | rsc/rsc | rosetta/maze/maze.go | PathString | func (m *Maze) PathString(path []graph.Vertex) string {
var b bytes.Buffer
wall := func(w, m walls, ch byte) {
if w&m != 0 {
b.WriteByte(ch)
} else {
b.WriteByte(' ')
}
}
for _, row := range m.grid {
b.WriteByte('+')
for _, cell := range row {
wall(cell, 1<<North, '-')
b.WriteByte('+')
}
b... | go | func (m *Maze) PathString(path []graph.Vertex) string {
var b bytes.Buffer
wall := func(w, m walls, ch byte) {
if w&m != 0 {
b.WriteByte(ch)
} else {
b.WriteByte(' ')
}
}
for _, row := range m.grid {
b.WriteByte('+')
for _, cell := range row {
wall(cell, 1<<North, '-')
b.WriteByte('+')
}
b... | [
"func",
"(",
"m",
"*",
"Maze",
")",
"PathString",
"(",
"path",
"[",
"]",
"graph",
".",
"Vertex",
")",
"string",
"{",
"var",
"b",
"bytes",
".",
"Buffer",
"\n",
"wall",
":=",
"func",
"(",
"w",
",",
"m",
"walls",
",",
"ch",
"byte",
")",
"{",
"if",... | // PathString returns the multi-line string representation of the
// maze with the path marked on it. | [
"PathString",
"returns",
"the",
"multi",
"-",
"line",
"string",
"representation",
"of",
"the",
"maze",
"with",
"the",
"path",
"marked",
"on",
"it",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/rosetta/maze/maze.go#L107-L148 |
140,113 | rsc/rsc | smugmug/smug.go | Categories | func (c *Conn) Categories(nick string) ([]*Category, error) {
var out struct {
Categories []*Category
}
if err := c.do("smugmug.categories.get", &out, "NickName", nick); err != nil {
return nil, err
}
return out.Categories, nil
} | go | func (c *Conn) Categories(nick string) ([]*Category, error) {
var out struct {
Categories []*Category
}
if err := c.do("smugmug.categories.get", &out, "NickName", nick); err != nil {
return nil, err
}
return out.Categories, nil
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Categories",
"(",
"nick",
"string",
")",
"(",
"[",
"]",
"*",
"Category",
",",
"error",
")",
"{",
"var",
"out",
"struct",
"{",
"Categories",
"[",
"]",
"*",
"Category",
"\n",
"}",
"\n",
"if",
"err",
":=",
"c",
... | // Categories returns the album categories for the user identified by the nick name. | [
"Categories",
"returns",
"the",
"album",
"categories",
"for",
"the",
"user",
"identified",
"by",
"the",
"nick",
"name",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/smugmug/smug.go#L82-L90 |
140,114 | rsc/rsc | smugmug/smug.go | CreateCategory | func (c *Conn) CreateCategory(name string) (*Category, error) {
var out struct {
Category *Category
}
if err := c.do("smugmug.categories.create", &out, "Name", name); err != nil {
return nil, err
}
return out.Category, nil
} | go | func (c *Conn) CreateCategory(name string) (*Category, error) {
var out struct {
Category *Category
}
if err := c.do("smugmug.categories.create", &out, "Name", name); err != nil {
return nil, err
}
return out.Category, nil
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"CreateCategory",
"(",
"name",
"string",
")",
"(",
"*",
"Category",
",",
"error",
")",
"{",
"var",
"out",
"struct",
"{",
"Category",
"*",
"Category",
"\n",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"do",
"(",
"\"... | // CreateCategory creates a category with the given name. | [
"CreateCategory",
"creates",
"a",
"category",
"with",
"the",
"given",
"name",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/smugmug/smug.go#L93-L101 |
140,115 | rsc/rsc | smugmug/smug.go | DeleteCategory | func (c *Conn) DeleteCategory(cat *Category) error {
return c.do("smugmug.categories.delete", nil, "CategoryID", itoa64(cat.ID))
} | go | func (c *Conn) DeleteCategory(cat *Category) error {
return c.do("smugmug.categories.delete", nil, "CategoryID", itoa64(cat.ID))
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"DeleteCategory",
"(",
"cat",
"*",
"Category",
")",
"error",
"{",
"return",
"c",
".",
"do",
"(",
"\"",
"\"",
",",
"nil",
",",
"\"",
"\"",
",",
"itoa64",
"(",
"cat",
".",
"ID",
")",
")",
"\n",
"}"
] | // DeleteCategory deletes the category. | [
"DeleteCategory",
"deletes",
"the",
"category",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/smugmug/smug.go#L104-L106 |
140,116 | rsc/rsc | smugmug/smug.go | Albums | func (c *Conn) Albums(nick string) ([]*Album, error) {
var out struct {
Albums []*Album
}
if err := c.do("smugmug.albums.get", &out, "NickName", nick); err != nil {
return nil, err
}
return out.Albums, nil
} | go | func (c *Conn) Albums(nick string) ([]*Album, error) {
var out struct {
Albums []*Album
}
if err := c.do("smugmug.albums.get", &out, "NickName", nick); err != nil {
return nil, err
}
return out.Albums, nil
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Albums",
"(",
"nick",
"string",
")",
"(",
"[",
"]",
"*",
"Album",
",",
"error",
")",
"{",
"var",
"out",
"struct",
"{",
"Albums",
"[",
"]",
"*",
"Album",
"\n",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"do",
... | // Albums returns the albums for the user identified by the nick name.
// Use c.NickName for the logged-in user. | [
"Albums",
"returns",
"the",
"albums",
"for",
"the",
"user",
"identified",
"by",
"the",
"nick",
"name",
".",
"Use",
"c",
".",
"NickName",
"for",
"the",
"logged",
"-",
"in",
"user",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/smugmug/smug.go#L118-L126 |
140,117 | rsc/rsc | smugmug/smug.go | CreateAlbum | func (c *Conn) CreateAlbum(title string) (*Album, error) {
var out struct {
Album *Album
}
if err := c.do("smugmug.albums.create", &out,
"Title", title,
"Public", "0",
"WorldSearchable", "0",
"SmugSearchable", "0",
); err != nil {
return nil, err
}
if out.Album == nil || out.Album.Key == "" {
retur... | go | func (c *Conn) CreateAlbum(title string) (*Album, error) {
var out struct {
Album *Album
}
if err := c.do("smugmug.albums.create", &out,
"Title", title,
"Public", "0",
"WorldSearchable", "0",
"SmugSearchable", "0",
); err != nil {
return nil, err
}
if out.Album == nil || out.Album.Key == "" {
retur... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"CreateAlbum",
"(",
"title",
"string",
")",
"(",
"*",
"Album",
",",
"error",
")",
"{",
"var",
"out",
"struct",
"{",
"Album",
"*",
"Album",
"\n",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"do",
"(",
"\"",
"\"",
... | // CreateAlbum creates a new album. | [
"CreateAlbum",
"creates",
"a",
"new",
"album",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/smugmug/smug.go#L129-L146 |
140,118 | rsc/rsc | smugmug/smug.go | AlbumInfo | func (c *Conn) AlbumInfo(album *Album) (*AlbumInfo, error) {
var out struct {
Album *AlbumInfo
}
if err := c.do("smugmug.albums.getInfo", &out,
"AlbumID", itoa64(album.ID),
"AlbumKey", album.Key,
); err != nil {
return nil, err
}
if out.Album == nil || out.Album.ID == 0 {
return nil, fmt.Errorf("unable... | go | func (c *Conn) AlbumInfo(album *Album) (*AlbumInfo, error) {
var out struct {
Album *AlbumInfo
}
if err := c.do("smugmug.albums.getInfo", &out,
"AlbumID", itoa64(album.ID),
"AlbumKey", album.Key,
); err != nil {
return nil, err
}
if out.Album == nil || out.Album.ID == 0 {
return nil, fmt.Errorf("unable... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"AlbumInfo",
"(",
"album",
"*",
"Album",
")",
"(",
"*",
"AlbumInfo",
",",
"error",
")",
"{",
"var",
"out",
"struct",
"{",
"Album",
"*",
"AlbumInfo",
"\n",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"do",
"(",
"\... | // AlbumInfo returns detailed metadata about an album. | [
"AlbumInfo",
"returns",
"detailed",
"metadata",
"about",
"an",
"album",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/smugmug/smug.go#L149-L164 |
140,119 | rsc/rsc | smugmug/smug.go | DeleteAlbum | func (c *Conn) DeleteAlbum(album *Album) error {
return c.do("smugmug.albums.delete", nil, "AlbumID", itoa64(album.ID))
} | go | func (c *Conn) DeleteAlbum(album *Album) error {
return c.do("smugmug.albums.delete", nil, "AlbumID", itoa64(album.ID))
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"DeleteAlbum",
"(",
"album",
"*",
"Album",
")",
"error",
"{",
"return",
"c",
".",
"do",
"(",
"\"",
"\"",
",",
"nil",
",",
"\"",
"\"",
",",
"itoa64",
"(",
"album",
".",
"ID",
")",
")",
"\n",
"}"
] | // DeleteAlbum deletes an album. | [
"DeleteAlbum",
"deletes",
"an",
"album",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/smugmug/smug.go#L261-L263 |
140,120 | rsc/rsc | smugmug/smug.go | Images | func (c *Conn) Images(album *Album) ([]*Image, error) {
var out struct {
Album struct {
Images []*Image
}
}
if err := c.do("smugmug.images.get", &out,
"AlbumID", itoa64(album.ID),
"AlbumKey", album.Key,
"Heavy", "1",
); err != nil {
return nil, err
}
return out.Album.Images, nil
} | go | func (c *Conn) Images(album *Album) ([]*Image, error) {
var out struct {
Album struct {
Images []*Image
}
}
if err := c.do("smugmug.images.get", &out,
"AlbumID", itoa64(album.ID),
"AlbumKey", album.Key,
"Heavy", "1",
); err != nil {
return nil, err
}
return out.Album.Images, nil
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"Images",
"(",
"album",
"*",
"Album",
")",
"(",
"[",
"]",
"*",
"Image",
",",
"error",
")",
"{",
"var",
"out",
"struct",
"{",
"Album",
"struct",
"{",
"Images",
"[",
"]",
"*",
"Image",
"\n",
"}",
"\n",
"}",
"... | // Images returns a list of images for an album. | [
"Images",
"returns",
"a",
"list",
"of",
"images",
"for",
"an",
"album",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/smugmug/smug.go#L273-L289 |
140,121 | rsc/rsc | smugmug/smug.go | ImageInfo | func (c *Conn) ImageInfo(image *Image) (*ImageInfo, error) {
var out struct {
Image *ImageInfo
}
if err := c.do("smugmug.images.getInfo", &out,
"ImageID", itoa64(image.ID),
"ImageKey", image.Key,
); err != nil {
return nil, err
}
if out.Image == nil || out.Image.ID == 0 {
return nil, fmt.Errorf("unable... | go | func (c *Conn) ImageInfo(image *Image) (*ImageInfo, error) {
var out struct {
Image *ImageInfo
}
if err := c.do("smugmug.images.getInfo", &out,
"ImageID", itoa64(image.ID),
"ImageKey", image.Key,
); err != nil {
return nil, err
}
if out.Image == nil || out.Image.ID == 0 {
return nil, fmt.Errorf("unable... | [
"func",
"(",
"c",
"*",
"Conn",
")",
"ImageInfo",
"(",
"image",
"*",
"Image",
")",
"(",
"*",
"ImageInfo",
",",
"error",
")",
"{",
"var",
"out",
"struct",
"{",
"Image",
"*",
"ImageInfo",
"\n",
"}",
"\n",
"if",
"err",
":=",
"c",
".",
"do",
"(",
"\... | // ImageInfo returns detailed metadata about an image. | [
"ImageInfo",
"returns",
"detailed",
"metadata",
"about",
"an",
"image",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/smugmug/smug.go#L331-L346 |
140,122 | rsc/rsc | smugmug/smug.go | DeleteImage | func (c *Conn) DeleteImage(image *Image) error {
return c.do("smugmug.images.delete", nil, "ImageID", itoa64(image.ID))
} | go | func (c *Conn) DeleteImage(image *Image) error {
return c.do("smugmug.images.delete", nil, "ImageID", itoa64(image.ID))
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"DeleteImage",
"(",
"image",
"*",
"Image",
")",
"error",
"{",
"return",
"c",
".",
"do",
"(",
"\"",
"\"",
",",
"nil",
",",
"\"",
"\"",
",",
"itoa64",
"(",
"image",
".",
"ID",
")",
")",
"\n",
"}"
] | // DeleteImage deletes an image. | [
"DeleteImage",
"deletes",
"an",
"image",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/smugmug/smug.go#L415-L417 |
140,123 | rsc/rsc | smugmug/smug.go | AddImage | func (c *Conn) AddImage(name string, data []byte, a *Album) (*Image, error) {
return c.upload(name, data, "AlbumID", a.ID)
} | go | func (c *Conn) AddImage(name string, data []byte, a *Album) (*Image, error) {
return c.upload(name, data, "AlbumID", a.ID)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"AddImage",
"(",
"name",
"string",
",",
"data",
"[",
"]",
"byte",
",",
"a",
"*",
"Album",
")",
"(",
"*",
"Image",
",",
"error",
")",
"{",
"return",
"c",
".",
"upload",
"(",
"name",
",",
"data",
",",
"\"",
"... | // AddImage uploads a new image to an album.
// The name is the file name that will be displayed on SmugMug.
// The data is the raw image data. | [
"AddImage",
"uploads",
"a",
"new",
"image",
"to",
"an",
"album",
".",
"The",
"name",
"is",
"the",
"file",
"name",
"that",
"will",
"be",
"displayed",
"on",
"SmugMug",
".",
"The",
"data",
"is",
"the",
"raw",
"image",
"data",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/smugmug/smug.go#L422-L424 |
140,124 | rsc/rsc | smugmug/smug.go | ReplaceImage | func (c *Conn) ReplaceImage(name string, data []byte, image *Image) (*Image, error) {
return c.upload(name, data, "ImageID", image.ID)
} | go | func (c *Conn) ReplaceImage(name string, data []byte, image *Image) (*Image, error) {
return c.upload(name, data, "ImageID", image.ID)
} | [
"func",
"(",
"c",
"*",
"Conn",
")",
"ReplaceImage",
"(",
"name",
"string",
",",
"data",
"[",
"]",
"byte",
",",
"image",
"*",
"Image",
")",
"(",
"*",
"Image",
",",
"error",
")",
"{",
"return",
"c",
".",
"upload",
"(",
"name",
",",
"data",
",",
"... | // ReplaceImage replaces an image.
// The name is the file name that will be displayed on SmugMug.
// The data is the raw image data. | [
"ReplaceImage",
"replaces",
"an",
"image",
".",
"The",
"name",
"is",
"the",
"file",
"name",
"that",
"will",
"be",
"displayed",
"on",
"SmugMug",
".",
"The",
"data",
"is",
"the",
"raw",
"image",
"data",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/smugmug/smug.go#L429-L431 |
140,125 | rsc/rsc | appfs/fs/fs.go | NewContext | func NewContext(req *http.Request) *Context {
if ae != nil {
ctxt := ae.NewContext(req)
return &Context{ae: ctxt}
}
return newContext(req)
} | go | func NewContext(req *http.Request) *Context {
if ae != nil {
ctxt := ae.NewContext(req)
return &Context{ae: ctxt}
}
return newContext(req)
} | [
"func",
"NewContext",
"(",
"req",
"*",
"http",
".",
"Request",
")",
"*",
"Context",
"{",
"if",
"ae",
"!=",
"nil",
"{",
"ctxt",
":=",
"ae",
".",
"NewContext",
"(",
"req",
")",
"\n",
"return",
"&",
"Context",
"{",
"ae",
":",
"ctxt",
"}",
"\n",
"}",... | // NewContext returns a context associated with the given HTTP request. | [
"NewContext",
"returns",
"a",
"context",
"associated",
"with",
"the",
"given",
"HTTP",
"request",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/appfs/fs/fs.go#L60-L66 |
140,126 | rsc/rsc | appfs/fs/fs.go | CacheRead | func (c *Context) CacheRead(name, path string) (ckey CacheKey, data []byte, found bool) {
if ae != nil {
key, data, found := ae.CacheRead(c.ae, name, path)
return CacheKey{ae: key}, data, found
}
return c.cacheRead(ckey, path)
} | go | func (c *Context) CacheRead(name, path string) (ckey CacheKey, data []byte, found bool) {
if ae != nil {
key, data, found := ae.CacheRead(c.ae, name, path)
return CacheKey{ae: key}, data, found
}
return c.cacheRead(ckey, path)
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"CacheRead",
"(",
"name",
",",
"path",
"string",
")",
"(",
"ckey",
"CacheKey",
",",
"data",
"[",
"]",
"byte",
",",
"found",
"bool",
")",
"{",
"if",
"ae",
"!=",
"nil",
"{",
"key",
",",
"data",
",",
"found",
... | // CacheRead reads from cache the entry with the given name and path.
// The path specifies the scope of information stored in the cache entry.
// An entry is invalidated by a write to any location in the file tree rooted at path.
// The name is an uninterpreted identifier to distinguish the cache entry
// from other e... | [
"CacheRead",
"reads",
"from",
"cache",
"the",
"entry",
"with",
"the",
"given",
"name",
"and",
"path",
".",
"The",
"path",
"specifies",
"the",
"scope",
"of",
"information",
"stored",
"in",
"the",
"cache",
"entry",
".",
"An",
"entry",
"is",
"invalidated",
"b... | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/appfs/fs/fs.go#L99-L105 |
140,127 | rsc/rsc | appfs/fs/fs.go | CacheLoad | func (c *Context) CacheLoad(name, path string, value interface{}) (ckey CacheKey, found bool) {
ckey, data, found := c.CacheRead(name, path)
if found {
if err := gob.NewDecoder(bytes.NewBuffer(data)).Decode(value); err != nil {
c.Criticalf("gob Decode: %v", err)
found = false
}
}
return
} | go | func (c *Context) CacheLoad(name, path string, value interface{}) (ckey CacheKey, found bool) {
ckey, data, found := c.CacheRead(name, path)
if found {
if err := gob.NewDecoder(bytes.NewBuffer(data)).Decode(value); err != nil {
c.Criticalf("gob Decode: %v", err)
found = false
}
}
return
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"CacheLoad",
"(",
"name",
",",
"path",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"(",
"ckey",
"CacheKey",
",",
"found",
"bool",
")",
"{",
"ckey",
",",
"data",
",",
"found",
":=",
"c",
".",
"CacheRead... | // CacheLoad uses CacheRead to load gob-encoded data and decodes it into value. | [
"CacheLoad",
"uses",
"CacheRead",
"to",
"load",
"gob",
"-",
"encoded",
"data",
"and",
"decodes",
"it",
"into",
"value",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/appfs/fs/fs.go#L108-L117 |
140,128 | rsc/rsc | appfs/fs/fs.go | CacheWrite | func (c *Context) CacheWrite(ckey CacheKey, data []byte) {
if ae != nil {
ae.CacheWrite(c.ae, ckey.ae, data)
return
}
c.cacheWrite(ckey, data)
} | go | func (c *Context) CacheWrite(ckey CacheKey, data []byte) {
if ae != nil {
ae.CacheWrite(c.ae, ckey.ae, data)
return
}
c.cacheWrite(ckey, data)
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"CacheWrite",
"(",
"ckey",
"CacheKey",
",",
"data",
"[",
"]",
"byte",
")",
"{",
"if",
"ae",
"!=",
"nil",
"{",
"ae",
".",
"CacheWrite",
"(",
"c",
".",
"ae",
",",
"ckey",
".",
"ae",
",",
"data",
")",
"\n",
... | // CacheWrite writes an entry to the cache with the given key, path, and data.
// The cache entry will be invalidated the next time the file tree rooted at path is
// modified in anyway. | [
"CacheWrite",
"writes",
"an",
"entry",
"to",
"the",
"cache",
"with",
"the",
"given",
"key",
"path",
"and",
"data",
".",
"The",
"cache",
"entry",
"will",
"be",
"invalidated",
"the",
"next",
"time",
"the",
"file",
"tree",
"rooted",
"at",
"path",
"is",
"mod... | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/appfs/fs/fs.go#L122-L128 |
140,129 | rsc/rsc | appfs/fs/fs.go | CacheStore | func (c *Context) CacheStore(ckey CacheKey, value interface{}) {
var buf bytes.Buffer
if err := gob.NewEncoder(&buf).Encode(value); err != nil {
c.Criticalf("gob Encode: %v", err)
return
}
c.CacheWrite(ckey, buf.Bytes())
} | go | func (c *Context) CacheStore(ckey CacheKey, value interface{}) {
var buf bytes.Buffer
if err := gob.NewEncoder(&buf).Encode(value); err != nil {
c.Criticalf("gob Encode: %v", err)
return
}
c.CacheWrite(ckey, buf.Bytes())
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"CacheStore",
"(",
"ckey",
"CacheKey",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"var",
"buf",
"bytes",
".",
"Buffer",
"\n",
"if",
"err",
":=",
"gob",
".",
"NewEncoder",
"(",
"&",
"buf",
")",
".",
"Encode... | // CacheStore uses CacheWrite to save the gob-encoded form of value. | [
"CacheStore",
"uses",
"CacheWrite",
"to",
"save",
"the",
"gob",
"-",
"encoded",
"form",
"of",
"value",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/appfs/fs/fs.go#L131-L138 |
140,130 | rsc/rsc | appfs/fs/fs.go | Read | func (c *Context) Read(path string) ([]byte, *proto.FileInfo, error) {
if ae != nil {
return ae.Read(c.ae, path)
}
return c.read(path)
} | go | func (c *Context) Read(path string) ([]byte, *proto.FileInfo, error) {
if ae != nil {
return ae.Read(c.ae, path)
}
return c.read(path)
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"Read",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"*",
"proto",
".",
"FileInfo",
",",
"error",
")",
"{",
"if",
"ae",
"!=",
"nil",
"{",
"return",
"ae",
".",
"Read",
"(",
"c",
".",
"ae",
",",... | // Read returns the data associated with the file named by path.
// It is a copy and can be modified without affecting the file. | [
"Read",
"returns",
"the",
"data",
"associated",
"with",
"the",
"file",
"named",
"by",
"path",
".",
"It",
"is",
"a",
"copy",
"and",
"can",
"be",
"modified",
"without",
"affecting",
"the",
"file",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/appfs/fs/fs.go#L142-L147 |
140,131 | rsc/rsc | appfs/fs/fs.go | Write | func (c *Context) Write(path string, data []byte) error {
if ae != nil {
return ae.Write(c.ae, path, data)
}
return c.write(path, data)
} | go | func (c *Context) Write(path string, data []byte) error {
if ae != nil {
return ae.Write(c.ae, path, data)
}
return c.write(path, data)
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"Write",
"(",
"path",
"string",
",",
"data",
"[",
"]",
"byte",
")",
"error",
"{",
"if",
"ae",
"!=",
"nil",
"{",
"return",
"ae",
".",
"Write",
"(",
"c",
".",
"ae",
",",
"path",
",",
"data",
")",
"\n",
"}"... | // Write replaces the data associated with the file named by path. | [
"Write",
"replaces",
"the",
"data",
"associated",
"with",
"the",
"file",
"named",
"by",
"path",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/appfs/fs/fs.go#L150-L155 |
140,132 | rsc/rsc | appfs/fs/fs.go | Remove | func (c *Context) Remove(path string) error {
if ae != nil {
return ae.Remove(c.ae, path)
}
return c.remove(path)
} | go | func (c *Context) Remove(path string) error {
if ae != nil {
return ae.Remove(c.ae, path)
}
return c.remove(path)
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"Remove",
"(",
"path",
"string",
")",
"error",
"{",
"if",
"ae",
"!=",
"nil",
"{",
"return",
"ae",
".",
"Remove",
"(",
"c",
".",
"ae",
",",
"path",
")",
"\n",
"}",
"\n",
"return",
"c",
".",
"remove",
"(",
... | // Remove removes the file named by path. | [
"Remove",
"removes",
"the",
"file",
"named",
"by",
"path",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/appfs/fs/fs.go#L158-L163 |
140,133 | rsc/rsc | appfs/fs/fs.go | Mkdir | func (c *Context) Mkdir(path string) error {
if ae != nil {
return ae.Mkdir(c.ae, path)
}
return c.mkdir(path)
} | go | func (c *Context) Mkdir(path string) error {
if ae != nil {
return ae.Mkdir(c.ae, path)
}
return c.mkdir(path)
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"Mkdir",
"(",
"path",
"string",
")",
"error",
"{",
"if",
"ae",
"!=",
"nil",
"{",
"return",
"ae",
".",
"Mkdir",
"(",
"c",
".",
"ae",
",",
"path",
")",
"\n",
"}",
"\n",
"return",
"c",
".",
"mkdir",
"(",
"p... | // Mkdir creates a directory with the given path.
// If the path already exists and is a directory, Mkdir returns no error. | [
"Mkdir",
"creates",
"a",
"directory",
"with",
"the",
"given",
"path",
".",
"If",
"the",
"path",
"already",
"exists",
"and",
"is",
"a",
"directory",
"Mkdir",
"returns",
"no",
"error",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/appfs/fs/fs.go#L167-L172 |
140,134 | rsc/rsc | appfs/fs/fs.go | ReadDir | func (c *Context) ReadDir(path string) ([]proto.FileInfo, error) {
if ae != nil {
return ae.ReadDir(c.ae, path)
}
return c.readdir(path)
} | go | func (c *Context) ReadDir(path string) ([]proto.FileInfo, error) {
if ae != nil {
return ae.ReadDir(c.ae, path)
}
return c.readdir(path)
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"ReadDir",
"(",
"path",
"string",
")",
"(",
"[",
"]",
"proto",
".",
"FileInfo",
",",
"error",
")",
"{",
"if",
"ae",
"!=",
"nil",
"{",
"return",
"ae",
".",
"ReadDir",
"(",
"c",
".",
"ae",
",",
"path",
")",
... | // ReadDir returns the contents of the directory named by the path. | [
"ReadDir",
"returns",
"the",
"contents",
"of",
"the",
"directory",
"named",
"by",
"the",
"path",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/appfs/fs/fs.go#L175-L180 |
140,135 | rsc/rsc | appfs/fs/fs.go | ServeFile | func (c *Context) ServeFile(w http.ResponseWriter, req *http.Request, name string) {
root := &httpFS{c, name}
http.FileServer(root).ServeHTTP(w, req)
} | go | func (c *Context) ServeFile(w http.ResponseWriter, req *http.Request, name string) {
root := &httpFS{c, name}
http.FileServer(root).ServeHTTP(w, req)
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"ServeFile",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"req",
"*",
"http",
".",
"Request",
",",
"name",
"string",
")",
"{",
"root",
":=",
"&",
"httpFS",
"{",
"c",
",",
"name",
"}",
"\n",
"http",
".",
"Fi... | // ServeFile serves the named file as the response to the HTTP request. | [
"ServeFile",
"serves",
"the",
"named",
"file",
"as",
"the",
"response",
"to",
"the",
"HTTP",
"request",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/appfs/fs/fs.go#L183-L186 |
140,136 | rsc/rsc | appfs/fs/fs.go | Criticalf | func (c *Context) Criticalf(format string, args ...interface{}) {
if ae != nil {
ae.Criticalf(c.ae, format, args...)
}
log.Printf(format, args...)
} | go | func (c *Context) Criticalf(format string, args ...interface{}) {
if ae != nil {
ae.Criticalf(c.ae, format, args...)
}
log.Printf(format, args...)
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"Criticalf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"ae",
"!=",
"nil",
"{",
"ae",
".",
"Criticalf",
"(",
"c",
".",
"ae",
",",
"format",
",",
"args",
"...",
")",
... | // Criticalf logs the message at critical priority. | [
"Criticalf",
"logs",
"the",
"message",
"at",
"critical",
"priority",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/appfs/fs/fs.go#L189-L194 |
140,137 | rsc/rsc | appfs/fs/fs.go | User | func (c *Context) User() string {
if ae != nil {
return ae.User(c.ae)
}
return os.Getenv("USER")
} | go | func (c *Context) User() string {
if ae != nil {
return ae.User(c.ae)
}
return os.Getenv("USER")
} | [
"func",
"(",
"c",
"*",
"Context",
")",
"User",
"(",
")",
"string",
"{",
"if",
"ae",
"!=",
"nil",
"{",
"return",
"ae",
".",
"User",
"(",
"c",
".",
"ae",
")",
"\n",
"}",
"\n",
"return",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // User returns the name of the user running the request. | [
"User",
"returns",
"the",
"name",
"of",
"the",
"user",
"running",
"the",
"request",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/appfs/fs/fs.go#L197-L202 |
140,138 | rsc/rsc | oauthprompt/oauth.go | GoogleToken | func GoogleToken(file, clientID, clientSecret, scope string) (*oauth.Transport, error) {
cfg := &oauth.Config{
ClientId: clientID,
ClientSecret: clientSecret,
Scope: scope,
AuthURL: "https://accounts.google.com/o/oauth2/auth",
TokenURL: "https://accounts.google.com/o/oauth2/token",
}
re... | go | func GoogleToken(file, clientID, clientSecret, scope string) (*oauth.Transport, error) {
cfg := &oauth.Config{
ClientId: clientID,
ClientSecret: clientSecret,
Scope: scope,
AuthURL: "https://accounts.google.com/o/oauth2/auth",
TokenURL: "https://accounts.google.com/o/oauth2/token",
}
re... | [
"func",
"GoogleToken",
"(",
"file",
",",
"clientID",
",",
"clientSecret",
",",
"scope",
"string",
")",
"(",
"*",
"oauth",
".",
"Transport",
",",
"error",
")",
"{",
"cfg",
":=",
"&",
"oauth",
".",
"Config",
"{",
"ClientId",
":",
"clientID",
",",
"Client... | // GoogleToken is like Token but assumes the Google AuthURL and TokenURL,
// so that only the client ID and secret and desired scope must be specified. | [
"GoogleToken",
"is",
"like",
"Token",
"but",
"assumes",
"the",
"Google",
"AuthURL",
"and",
"TokenURL",
"so",
"that",
"only",
"the",
"client",
"ID",
"and",
"secret",
"and",
"desired",
"scope",
"must",
"be",
"specified",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/oauthprompt/oauth.go#L135-L144 |
140,139 | rsc/rsc | cc/lex.go | enum | func (lx *lexer) enum(x Syntax) {
switch x := x.(type) {
default:
panic(fmt.Errorf("order: unexpected type %T", x))
case nil:
return
case *Expr:
if x == nil {
return
}
lx.enum(x.Left)
lx.enum(x.Right)
for _, y := range x.List {
lx.enum(y)
}
case *Init:
if x == nil {
return
}
lx.enum(... | go | func (lx *lexer) enum(x Syntax) {
switch x := x.(type) {
default:
panic(fmt.Errorf("order: unexpected type %T", x))
case nil:
return
case *Expr:
if x == nil {
return
}
lx.enum(x.Left)
lx.enum(x.Right)
for _, y := range x.List {
lx.enum(y)
}
case *Init:
if x == nil {
return
}
lx.enum(... | [
"func",
"(",
"lx",
"*",
"lexer",
")",
"enum",
"(",
"x",
"Syntax",
")",
"{",
"switch",
"x",
":=",
"x",
".",
"(",
"type",
")",
"{",
"default",
":",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"x",
")",
")",
"\n",
"case",
"nil",
... | // Comment assignment.
// We build two lists of all subexpressions, preorder and postorder.
// The preorder list is ordered by start location, with outer expressions first.
// The postorder list is ordered by end location, with outer expressions last.
// We use the preorder list to assign each whole-line comment to the... | [
"Comment",
"assignment",
".",
"We",
"build",
"two",
"lists",
"of",
"all",
"subexpressions",
"preorder",
"and",
"postorder",
".",
"The",
"preorder",
"list",
"is",
"ordered",
"by",
"start",
"location",
"with",
"outer",
"expressions",
"first",
".",
"The",
"postor... | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cc/lex.go#L609-L678 |
140,140 | rsc/rsc | xmpp/xmpp.go | Recv | func (c *Client) Recv() (chat Chat, err error) {
for {
_, val, err := next(c.p)
if err != nil {
return Chat{}, err
}
switch val := val.(type) {
case *clientMessage:
return Chat{Remote: val.From, Type: val.Type, Text: val.Body}, nil
case *clientQuery:
var r Roster
for _, item := range val.Item {... | go | func (c *Client) Recv() (chat Chat, err error) {
for {
_, val, err := next(c.p)
if err != nil {
return Chat{}, err
}
switch val := val.(type) {
case *clientMessage:
return Chat{Remote: val.From, Type: val.Type, Text: val.Body}, nil
case *clientQuery:
var r Roster
for _, item := range val.Item {... | [
"func",
"(",
"c",
"*",
"Client",
")",
"Recv",
"(",
")",
"(",
"chat",
"Chat",
",",
"err",
"error",
")",
"{",
"for",
"{",
"_",
",",
"val",
",",
"err",
":=",
"next",
"(",
"c",
".",
"p",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"Chat... | // Recv wait next token of chat. | [
"Recv",
"wait",
"next",
"token",
"of",
"chat",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/xmpp/xmpp.go#L264-L290 |
140,141 | rsc/rsc | xmpp/xmpp.go | Send | func (c *Client) Send(chat Chat) error {
fmt.Fprintf(c.tls, "<message to='%s' from='%s' type='chat' xml:lang='en'>"+
"<body>%s</body></message>",
xmlEscape(chat.Remote), xmlEscape(c.jid),
xmlEscape(chat.Text))
return nil
} | go | func (c *Client) Send(chat Chat) error {
fmt.Fprintf(c.tls, "<message to='%s' from='%s' type='chat' xml:lang='en'>"+
"<body>%s</body></message>",
xmlEscape(chat.Remote), xmlEscape(c.jid),
xmlEscape(chat.Text))
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Send",
"(",
"chat",
"Chat",
")",
"error",
"{",
"fmt",
".",
"Fprintf",
"(",
"c",
".",
"tls",
",",
"\"",
"\"",
"+",
"\"",
"\"",
",",
"xmlEscape",
"(",
"chat",
".",
"Remote",
")",
",",
"xmlEscape",
"(",
"c",
... | // Send sends message text. | [
"Send",
"sends",
"message",
"text",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/xmpp/xmpp.go#L293-L299 |
140,142 | rsc/rsc | xmpp/xmpp.go | Roster | func (c *Client) Roster() error {
fmt.Fprintf(c.tls, "<iq from='%s' type='get' id='roster1'><query xmlns='jabber:iq:roster'/></iq>\n", xmlEscape(c.jid))
return nil
} | go | func (c *Client) Roster() error {
fmt.Fprintf(c.tls, "<iq from='%s' type='get' id='roster1'><query xmlns='jabber:iq:roster'/></iq>\n", xmlEscape(c.jid))
return nil
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"Roster",
"(",
")",
"error",
"{",
"fmt",
".",
"Fprintf",
"(",
"c",
".",
"tls",
",",
"\"",
"\\n",
"\"",
",",
"xmlEscape",
"(",
"c",
".",
"jid",
")",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // Roster asks for the chat roster. | [
"Roster",
"asks",
"for",
"the",
"chat",
"roster",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/xmpp/xmpp.go#L302-L305 |
140,143 | rsc/rsc | xmpp/xmpp.go | nextStart | func nextStart(p *xml.Decoder) (xml.StartElement, error) {
for {
t, err := p.Token()
if err != nil {
log.Fatal("token", err)
}
switch t := t.(type) {
case xml.StartElement:
return t, nil
}
}
panic("unreachable")
} | go | func nextStart(p *xml.Decoder) (xml.StartElement, error) {
for {
t, err := p.Token()
if err != nil {
log.Fatal("token", err)
}
switch t := t.(type) {
case xml.StartElement:
return t, nil
}
}
panic("unreachable")
} | [
"func",
"nextStart",
"(",
"p",
"*",
"xml",
".",
"Decoder",
")",
"(",
"xml",
".",
"StartElement",
",",
"error",
")",
"{",
"for",
"{",
"t",
",",
"err",
":=",
"p",
".",
"Token",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Fatal",
... | // Scan XML token stream to find next StartElement. | [
"Scan",
"XML",
"token",
"stream",
"to",
"find",
"next",
"StartElement",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/xmpp/xmpp.go#L469-L481 |
140,144 | rsc/rsc | xmpp/xmpp.go | next | func next(p *xml.Decoder) (xml.Name, interface{}, error) {
// Read start element to find out what type we want.
se, err := nextStart(p)
if err != nil {
return xml.Name{}, nil, err
}
// Put it in an interface and allocate one.
var nv interface{}
switch se.Name.Space + " " + se.Name.Local {
case nsStream + " f... | go | func next(p *xml.Decoder) (xml.Name, interface{}, error) {
// Read start element to find out what type we want.
se, err := nextStart(p)
if err != nil {
return xml.Name{}, nil, err
}
// Put it in an interface and allocate one.
var nv interface{}
switch se.Name.Space + " " + se.Name.Local {
case nsStream + " f... | [
"func",
"next",
"(",
"p",
"*",
"xml",
".",
"Decoder",
")",
"(",
"xml",
".",
"Name",
",",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"// Read start element to find out what type we want.",
"se",
",",
"err",
":=",
"nextStart",
"(",
"p",
")",
"\n",
"if"... | // Scan XML token stream for next element and save into val.
// If val == nil, allocate new element based on proto map.
// Either way, return val. | [
"Scan",
"XML",
"token",
"stream",
"for",
"next",
"element",
"and",
"save",
"into",
"val",
".",
"If",
"val",
"==",
"nil",
"allocate",
"new",
"element",
"based",
"on",
"proto",
"map",
".",
"Either",
"way",
"return",
"val",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/xmpp/xmpp.go#L486-L538 |
140,145 | rsc/rsc | imap/imap.go | cmdsx0 | func (c *Client) cmdsx0(format string, args ...interface{}) (*sx, error) {
c.io.mustBeLocked()
if c.rw == nil || !c.connected {
return nil, fmt.Errorf("not connected")
}
cmd := fmt.Sprintf(format, args...)
if Debug {
fmt.Fprintf(os.Stderr, ">>> %s %s\n", tag, cmd)
}
if _, err := fmt.Fprintf(c.rw, "%s %s\r\n... | go | func (c *Client) cmdsx0(format string, args ...interface{}) (*sx, error) {
c.io.mustBeLocked()
if c.rw == nil || !c.connected {
return nil, fmt.Errorf("not connected")
}
cmd := fmt.Sprintf(format, args...)
if Debug {
fmt.Fprintf(os.Stderr, ">>> %s %s\n", tag, cmd)
}
if _, err := fmt.Fprintf(c.rw, "%s %s\r\n... | [
"func",
"(",
"c",
"*",
"Client",
")",
"cmdsx0",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"*",
"sx",
",",
"error",
")",
"{",
"c",
".",
"io",
".",
"mustBeLocked",
"(",
")",
"\n",
"if",
"c",
".",
"rw",
"==",
... | // cmdsx0 runs a single command and return the sx. Does not redial. | [
"cmdsx0",
"runs",
"a",
"single",
"command",
"and",
"return",
"the",
"sx",
".",
"Does",
"not",
"redial",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/imap/imap.go#L258-L273 |
140,146 | rsc/rsc | imap/imap.go | cmdsx | func (c *Client) cmdsx(b *Box, format string, args ...interface{}) (*sx, error) {
c.io.mustBeLocked()
c.nextBox = b
Trying:
for tries := 0; ; tries++ {
if c.rw == nil || !c.connected {
if !c.autoReconnect {
return nil, fmt.Errorf("not connected")
}
if err := c.reconnect(); err != nil {
return nil... | go | func (c *Client) cmdsx(b *Box, format string, args ...interface{}) (*sx, error) {
c.io.mustBeLocked()
c.nextBox = b
Trying:
for tries := 0; ; tries++ {
if c.rw == nil || !c.connected {
if !c.autoReconnect {
return nil, fmt.Errorf("not connected")
}
if err := c.reconnect(); err != nil {
return nil... | [
"func",
"(",
"c",
"*",
"Client",
")",
"cmdsx",
"(",
"b",
"*",
"Box",
",",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"(",
"*",
"sx",
",",
"error",
")",
"{",
"c",
".",
"io",
".",
"mustBeLocked",
"(",
")",
"\n",
"c",
".... | // cmdsx runs a command on box b. It does redial. | [
"cmdsx",
"runs",
"a",
"command",
"on",
"box",
"b",
".",
"It",
"does",
"redial",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/imap/imap.go#L276-L322 |
140,147 | rsc/rsc | ext2/fs.go | Open | func Open(name string) (*FS, error) {
var off int64
if i := strings.Index(name, "@"); i >= 0 {
v, err := strconv.ParseInt(name[i+1:], 0, 64)
if err != nil {
return nil, fmt.Errorf("invalid offset in name %q", name)
}
off = v
name = name[:i]
}
f, err := os.Open(name)
if err != nil {
return nil, err
... | go | func Open(name string) (*FS, error) {
var off int64
if i := strings.Index(name, "@"); i >= 0 {
v, err := strconv.ParseInt(name[i+1:], 0, 64)
if err != nil {
return nil, fmt.Errorf("invalid offset in name %q", name)
}
off = v
name = name[:i]
}
f, err := os.Open(name)
if err != nil {
return nil, err
... | [
"func",
"Open",
"(",
"name",
"string",
")",
"(",
"*",
"FS",
",",
"error",
")",
"{",
"var",
"off",
"int64",
"\n",
"if",
"i",
":=",
"strings",
".",
"Index",
"(",
"name",
",",
"\"",
"\"",
")",
";",
"i",
">=",
"0",
"{",
"v",
",",
"err",
":=",
"... | // Open opens the file system in the named file.
//
// If the name contains an @ sign, it is taken to be
// of the form file@offset, where offset is a decimal,
// hexadecimal, or octal number according to its prefix,
// and the file system is assumed to start at the given
// offset in the file instead of at the beginni... | [
"Open",
"opens",
"the",
"file",
"system",
"in",
"the",
"named",
"file",
".",
"If",
"the",
"name",
"contains",
"an"
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/ext2/fs.go#L186-L214 |
140,148 | rsc/rsc | ext2/fs.go | Init | func Init(r io.ReaderAt) (*FS, error) {
fs := &FS{
r: r,
buf: make([]byte, 1024),
BlockSize: superSize,
}
var super diskSuper
if _, err := fs.read(superOff, 0, &super); err != nil {
return nil, err
}
if super.Magic != superMagic {
return nil, fmt.Errorf("bad magic %#x wanted %#x", super.... | go | func Init(r io.ReaderAt) (*FS, error) {
fs := &FS{
r: r,
buf: make([]byte, 1024),
BlockSize: superSize,
}
var super diskSuper
if _, err := fs.read(superOff, 0, &super); err != nil {
return nil, err
}
if super.Magic != superMagic {
return nil, fmt.Errorf("bad magic %#x wanted %#x", super.... | [
"func",
"Init",
"(",
"r",
"io",
".",
"ReaderAt",
")",
"(",
"*",
"FS",
",",
"error",
")",
"{",
"fs",
":=",
"&",
"FS",
"{",
"r",
":",
"r",
",",
"buf",
":",
"make",
"(",
"[",
"]",
"byte",
",",
"1024",
")",
",",
"BlockSize",
":",
"superSize",
"... | // Init returns an FS reading from the file system stored in r. | [
"Init",
"returns",
"an",
"FS",
"reading",
"from",
"the",
"file",
"system",
"stored",
"in",
"r",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/ext2/fs.go#L217-L255 |
140,149 | rsc/rsc | ext2/fs.go | File | func (fs *FS) File(inode uint32) (*File, error) {
g, ioff, err := fs.igroup(inode)
if err != nil {
return nil, err
}
addr := int64(fs.BlockSize) * int64(g.Inodeaddr+ioff/fs.inodesPerBlock)
ivoff := (ioff % fs.inodesPerBlock) * fs.inodeSize
file := &File{fs: fs, inum: inode}
if _, err := fs.read(addr, int(ivo... | go | func (fs *FS) File(inode uint32) (*File, error) {
g, ioff, err := fs.igroup(inode)
if err != nil {
return nil, err
}
addr := int64(fs.BlockSize) * int64(g.Inodeaddr+ioff/fs.inodesPerBlock)
ivoff := (ioff % fs.inodesPerBlock) * fs.inodeSize
file := &File{fs: fs, inum: inode}
if _, err := fs.read(addr, int(ivo... | [
"func",
"(",
"fs",
"*",
"FS",
")",
"File",
"(",
"inode",
"uint32",
")",
"(",
"*",
"File",
",",
"error",
")",
"{",
"g",
",",
"ioff",
",",
"err",
":=",
"fs",
".",
"igroup",
"(",
"inode",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil"... | // File returns the file with the given inode number. | [
"File",
"returns",
"the",
"file",
"with",
"the",
"given",
"inode",
"number",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/ext2/fs.go#L265-L287 |
140,150 | rsc/rsc | ext2/fs.go | Size | func (f *File) Size() int64 {
size := int64(f.ino.Size)
if f.ino.Mode&ifmt == ifreg {
size |= int64(f.ino.Diracl) << 32
}
return size
} | go | func (f *File) Size() int64 {
size := int64(f.ino.Size)
if f.ino.Mode&ifmt == ifreg {
size |= int64(f.ino.Diracl) << 32
}
return size
} | [
"func",
"(",
"f",
"*",
"File",
")",
"Size",
"(",
")",
"int64",
"{",
"size",
":=",
"int64",
"(",
"f",
".",
"ino",
".",
"Size",
")",
"\n",
"if",
"f",
".",
"ino",
".",
"Mode",
"&",
"ifmt",
"==",
"ifreg",
"{",
"size",
"|=",
"int64",
"(",
"f",
"... | // Size returns the file's size in bytes. | [
"Size",
"returns",
"the",
"file",
"s",
"size",
"in",
"bytes",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/ext2/fs.go#L321-L327 |
140,151 | rsc/rsc | ext2/fs.go | Mode | func (f *File) Mode() os.FileMode {
mode := os.FileMode(f.ino.Mode & 0777)
switch f.ino.Mode & ifmt {
case ififo:
mode |= os.ModeNamedPipe
default: // ifchr, ifblk, unknown
mode |= os.ModeDevice
case ifdir:
mode |= os.ModeDir
case ifreg:
// no bits
case iflnk:
mode |= os.ModeSymlink
case ifsock:
mod... | go | func (f *File) Mode() os.FileMode {
mode := os.FileMode(f.ino.Mode & 0777)
switch f.ino.Mode & ifmt {
case ififo:
mode |= os.ModeNamedPipe
default: // ifchr, ifblk, unknown
mode |= os.ModeDevice
case ifdir:
mode |= os.ModeDir
case ifreg:
// no bits
case iflnk:
mode |= os.ModeSymlink
case ifsock:
mod... | [
"func",
"(",
"f",
"*",
"File",
")",
"Mode",
"(",
")",
"os",
".",
"FileMode",
"{",
"mode",
":=",
"os",
".",
"FileMode",
"(",
"f",
".",
"ino",
".",
"Mode",
"&",
"0777",
")",
"\n",
"switch",
"f",
".",
"ino",
".",
"Mode",
"&",
"ifmt",
"{",
"case"... | // Mode returns the file's mode. | [
"Mode",
"returns",
"the",
"file",
"s",
"mode",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/ext2/fs.go#L330-L347 |
140,152 | rsc/rsc | ext2/fs.go | ModTime | func (f *File) ModTime() time.Time {
return time.Unix(int64(f.ino.Mtime), 0)
} | go | func (f *File) ModTime() time.Time {
return time.Unix(int64(f.ino.Mtime), 0)
} | [
"func",
"(",
"f",
"*",
"File",
")",
"ModTime",
"(",
")",
"time",
".",
"Time",
"{",
"return",
"time",
".",
"Unix",
"(",
"int64",
"(",
"f",
".",
"ino",
".",
"Mtime",
")",
",",
"0",
")",
"\n",
"}"
] | // ModTime returns the file's modification time. | [
"ModTime",
"returns",
"the",
"file",
"s",
"modification",
"time",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/ext2/fs.go#L354-L356 |
140,153 | rsc/rsc | ext2/fs.go | ReadAt | func (f *File) ReadAt(buf []byte, off int64) (n int, err error) {
size := f.Size()
if off >= size {
return 0, io.EOF
}
if n = len(buf); int64(n) > size-off {
n = int(size - off)
}
lfrag := int(uint32(off) % uint32(f.fs.BlockSize))
off -= int64(lfrag)
want := lfrag + n
rfrag := -want & (f.fs.BlockSize - 1)... | go | func (f *File) ReadAt(buf []byte, off int64) (n int, err error) {
size := f.Size()
if off >= size {
return 0, io.EOF
}
if n = len(buf); int64(n) > size-off {
n = int(size - off)
}
lfrag := int(uint32(off) % uint32(f.fs.BlockSize))
off -= int64(lfrag)
want := lfrag + n
rfrag := -want & (f.fs.BlockSize - 1)... | [
"func",
"(",
"f",
"*",
"File",
")",
"ReadAt",
"(",
"buf",
"[",
"]",
"byte",
",",
"off",
"int64",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"size",
":=",
"f",
".",
"Size",
"(",
")",
"\n",
"if",
"off",
">=",
"size",
"{",
"return",
... | // ReadAt implements the io.ReaderAt interface. | [
"ReadAt",
"implements",
"the",
"io",
".",
"ReaderAt",
"interface",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/ext2/fs.go#L359-L391 |
140,154 | rsc/rsc | ext2/fs.go | ReadLink | func (f *File) ReadLink() (string, error) {
if f.ino.Mode&ifmt != iflnk {
return "", fmt.Errorf("not a symbolic link")
}
size := f.ino.Size
if f.ino.Nblock != 0 {
if size > uint32(f.fs.BlockSize) {
return "", fmt.Errorf("invalid symlink size")
}
// Symlink fits in one block.
b, err := f.dblock(0)
i... | go | func (f *File) ReadLink() (string, error) {
if f.ino.Mode&ifmt != iflnk {
return "", fmt.Errorf("not a symbolic link")
}
size := f.ino.Size
if f.ino.Nblock != 0 {
if size > uint32(f.fs.BlockSize) {
return "", fmt.Errorf("invalid symlink size")
}
// Symlink fits in one block.
b, err := f.dblock(0)
i... | [
"func",
"(",
"f",
"*",
"File",
")",
"ReadLink",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"f",
".",
"ino",
".",
"Mode",
"&",
"ifmt",
"!=",
"iflnk",
"{",
"return",
"\"",
"\"",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",... | // ReadLink returns the symbolic link content of f. | [
"ReadLink",
"returns",
"the",
"symbolic",
"link",
"content",
"of",
"f",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/ext2/fs.go#L394-L425 |
140,155 | rsc/rsc | ext2/fs.go | ReadDir | func (f *File) ReadDir() ([]Dir, error) {
var dirs []Dir
err := f.walkDir(func(name []byte, ino uint32) bool {
dirs = append(dirs, Dir{string(name), ino})
return true
})
return dirs, err
} | go | func (f *File) ReadDir() ([]Dir, error) {
var dirs []Dir
err := f.walkDir(func(name []byte, ino uint32) bool {
dirs = append(dirs, Dir{string(name), ino})
return true
})
return dirs, err
} | [
"func",
"(",
"f",
"*",
"File",
")",
"ReadDir",
"(",
")",
"(",
"[",
"]",
"Dir",
",",
"error",
")",
"{",
"var",
"dirs",
"[",
"]",
"Dir",
"\n",
"err",
":=",
"f",
".",
"walkDir",
"(",
"func",
"(",
"name",
"[",
"]",
"byte",
",",
"ino",
"uint32",
... | // ReadDir returns all the directory entries in f. | [
"ReadDir",
"returns",
"all",
"the",
"directory",
"entries",
"in",
"f",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/ext2/fs.go#L477-L484 |
140,156 | rsc/rsc | ext2/fs.go | Lookup | func (f *File) Lookup(name string) (*File, error) {
var bino uint32
bname := []byte(name)
err := f.walkDir(func(name []byte, ino uint32) bool {
if bytes.Equal(bname, name) {
bino = ino
return false
}
return true
})
if err != nil {
return nil, err
}
if bino == 0 {
return nil, fmt.Errorf("file not ... | go | func (f *File) Lookup(name string) (*File, error) {
var bino uint32
bname := []byte(name)
err := f.walkDir(func(name []byte, ino uint32) bool {
if bytes.Equal(bname, name) {
bino = ino
return false
}
return true
})
if err != nil {
return nil, err
}
if bino == 0 {
return nil, fmt.Errorf("file not ... | [
"func",
"(",
"f",
"*",
"File",
")",
"Lookup",
"(",
"name",
"string",
")",
"(",
"*",
"File",
",",
"error",
")",
"{",
"var",
"bino",
"uint32",
"\n",
"bname",
":=",
"[",
"]",
"byte",
"(",
"name",
")",
"\n",
"err",
":=",
"f",
".",
"walkDir",
"(",
... | // Lookup looks up the name in the directory f, returning the corresponding child file. | [
"Lookup",
"looks",
"up",
"the",
"name",
"in",
"the",
"directory",
"f",
"returning",
"the",
"corresponding",
"child",
"file",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/ext2/fs.go#L487-L504 |
140,157 | rsc/rsc | ext2/fs.go | Open | func (f *File) Open() (io.Reader, error) {
if f.ino.Mode&ifmt != ifreg {
return nil, fmt.Errorf("not a regular file")
}
return &fileReader{f, 0}, nil
} | go | func (f *File) Open() (io.Reader, error) {
if f.ino.Mode&ifmt != ifreg {
return nil, fmt.Errorf("not a regular file")
}
return &fileReader{f, 0}, nil
} | [
"func",
"(",
"f",
"*",
"File",
")",
"Open",
"(",
")",
"(",
"io",
".",
"Reader",
",",
"error",
")",
"{",
"if",
"f",
".",
"ino",
".",
"Mode",
"&",
"ifmt",
"!=",
"ifreg",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"... | // Open returns an io.Reader for the file. | [
"Open",
"returns",
"an",
"io",
".",
"Reader",
"for",
"the",
"file",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/ext2/fs.go#L563-L568 |
140,158 | rsc/rsc | cmd/acmego/read.go | readByte | func (r *importReader) readByte() byte {
c, err := r.b.ReadByte()
if err == nil {
r.buf = append(r.buf, c)
if c == 0 {
err = errNUL
}
}
if err != nil {
if err == io.EOF {
r.eof = true
} else if r.err == nil {
r.err = err
}
c = 0
}
return c
} | go | func (r *importReader) readByte() byte {
c, err := r.b.ReadByte()
if err == nil {
r.buf = append(r.buf, c)
if c == 0 {
err = errNUL
}
}
if err != nil {
if err == io.EOF {
r.eof = true
} else if r.err == nil {
r.err = err
}
c = 0
}
return c
} | [
"func",
"(",
"r",
"*",
"importReader",
")",
"readByte",
"(",
")",
"byte",
"{",
"c",
",",
"err",
":=",
"r",
".",
"b",
".",
"ReadByte",
"(",
")",
"\n",
"if",
"err",
"==",
"nil",
"{",
"r",
".",
"buf",
"=",
"append",
"(",
"r",
".",
"buf",
",",
... | // readByte reads the next byte from the input, saves it in buf, and returns it.
// If an error occurs, readByte records the error in r.err and returns 0. | [
"readByte",
"reads",
"the",
"next",
"byte",
"from",
"the",
"input",
"saves",
"it",
"in",
"buf",
"and",
"returns",
"it",
".",
"If",
"an",
"error",
"occurs",
"readByte",
"records",
"the",
"error",
"in",
"r",
".",
"err",
"and",
"returns",
"0",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cmd/acmego/read.go#L40-L57 |
140,159 | rsc/rsc | cmd/acmego/read.go | peekByte | func (r *importReader) peekByte(skipSpace bool) byte {
if r.err != nil {
if r.nerr++; r.nerr > 10000 {
panic("go/build: import reader looping")
}
return 0
}
// Use r.peek as first input byte.
// Don't just return r.peek here: it might have been left by peekByte(false)
// and this might be peekByte(true).... | go | func (r *importReader) peekByte(skipSpace bool) byte {
if r.err != nil {
if r.nerr++; r.nerr > 10000 {
panic("go/build: import reader looping")
}
return 0
}
// Use r.peek as first input byte.
// Don't just return r.peek here: it might have been left by peekByte(false)
// and this might be peekByte(true).... | [
"func",
"(",
"r",
"*",
"importReader",
")",
"peekByte",
"(",
"skipSpace",
"bool",
")",
"byte",
"{",
"if",
"r",
".",
"err",
"!=",
"nil",
"{",
"if",
"r",
".",
"nerr",
"++",
";",
"r",
".",
"nerr",
">",
"10000",
"{",
"panic",
"(",
"\"",
"\"",
")",
... | // peekByte returns the next byte from the input reader but does not advance beyond it.
// If skipSpace is set, peekByte skips leading spaces and comments. | [
"peekByte",
"returns",
"the",
"next",
"byte",
"from",
"the",
"input",
"reader",
"but",
"does",
"not",
"advance",
"beyond",
"it",
".",
"If",
"skipSpace",
"is",
"set",
"peekByte",
"skips",
"leading",
"spaces",
"and",
"comments",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cmd/acmego/read.go#L61-L110 |
140,160 | rsc/rsc | cmd/acmego/read.go | nextByte | func (r *importReader) nextByte(skipSpace bool) byte {
c := r.peekByte(skipSpace)
r.peek = 0
return c
} | go | func (r *importReader) nextByte(skipSpace bool) byte {
c := r.peekByte(skipSpace)
r.peek = 0
return c
} | [
"func",
"(",
"r",
"*",
"importReader",
")",
"nextByte",
"(",
"skipSpace",
"bool",
")",
"byte",
"{",
"c",
":=",
"r",
".",
"peekByte",
"(",
"skipSpace",
")",
"\n",
"r",
".",
"peek",
"=",
"0",
"\n",
"return",
"c",
"\n",
"}"
] | // nextByte is like peekByte but advances beyond the returned byte. | [
"nextByte",
"is",
"like",
"peekByte",
"but",
"advances",
"beyond",
"the",
"returned",
"byte",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cmd/acmego/read.go#L113-L117 |
140,161 | rsc/rsc | cmd/acmego/read.go | readKeyword | func (r *importReader) readKeyword(kw string) {
r.peekByte(true)
for i := 0; i < len(kw); i++ {
if r.nextByte(false) != kw[i] {
r.syntaxError()
return
}
}
if isIdent(r.peekByte(false)) {
r.syntaxError()
}
} | go | func (r *importReader) readKeyword(kw string) {
r.peekByte(true)
for i := 0; i < len(kw); i++ {
if r.nextByte(false) != kw[i] {
r.syntaxError()
return
}
}
if isIdent(r.peekByte(false)) {
r.syntaxError()
}
} | [
"func",
"(",
"r",
"*",
"importReader",
")",
"readKeyword",
"(",
"kw",
"string",
")",
"{",
"r",
".",
"peekByte",
"(",
"true",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"kw",
")",
";",
"i",
"++",
"{",
"if",
"r",
".",
"nextByt... | // readKeyword reads the given keyword from the input.
// If the keyword is not present, readKeyword records a syntax error. | [
"readKeyword",
"reads",
"the",
"given",
"keyword",
"from",
"the",
"input",
".",
"If",
"the",
"keyword",
"is",
"not",
"present",
"readKeyword",
"records",
"a",
"syntax",
"error",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cmd/acmego/read.go#L121-L132 |
140,162 | rsc/rsc | cmd/acmego/read.go | readIdent | func (r *importReader) readIdent() {
c := r.peekByte(true)
if !isIdent(c) {
r.syntaxError()
return
}
for isIdent(r.peekByte(false)) {
r.peek = 0
}
} | go | func (r *importReader) readIdent() {
c := r.peekByte(true)
if !isIdent(c) {
r.syntaxError()
return
}
for isIdent(r.peekByte(false)) {
r.peek = 0
}
} | [
"func",
"(",
"r",
"*",
"importReader",
")",
"readIdent",
"(",
")",
"{",
"c",
":=",
"r",
".",
"peekByte",
"(",
"true",
")",
"\n",
"if",
"!",
"isIdent",
"(",
"c",
")",
"{",
"r",
".",
"syntaxError",
"(",
")",
"\n",
"return",
"\n",
"}",
"\n",
"for"... | // readIdent reads an identifier from the input.
// If an identifier is not present, readIdent records a syntax error. | [
"readIdent",
"reads",
"an",
"identifier",
"from",
"the",
"input",
".",
"If",
"an",
"identifier",
"is",
"not",
"present",
"readIdent",
"records",
"a",
"syntax",
"error",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cmd/acmego/read.go#L136-L145 |
140,163 | rsc/rsc | cmd/acmego/read.go | readString | func (r *importReader) readString() {
switch r.nextByte(true) {
case '`':
for r.err == nil {
if r.nextByte(false) == '`' {
break
}
if r.eof {
r.syntaxError()
}
}
case '"':
for r.err == nil {
c := r.nextByte(false)
if c == '"' {
break
}
if r.eof || c == '\n' {
r.syntaxErr... | go | func (r *importReader) readString() {
switch r.nextByte(true) {
case '`':
for r.err == nil {
if r.nextByte(false) == '`' {
break
}
if r.eof {
r.syntaxError()
}
}
case '"':
for r.err == nil {
c := r.nextByte(false)
if c == '"' {
break
}
if r.eof || c == '\n' {
r.syntaxErr... | [
"func",
"(",
"r",
"*",
"importReader",
")",
"readString",
"(",
")",
"{",
"switch",
"r",
".",
"nextByte",
"(",
"true",
")",
"{",
"case",
"'`'",
":",
"for",
"r",
".",
"err",
"==",
"nil",
"{",
"if",
"r",
".",
"nextByte",
"(",
"false",
")",
"==",
"... | // readString reads a quoted string literal from the input.
// If an identifier is not present, readString records a syntax error. | [
"readString",
"reads",
"a",
"quoted",
"string",
"literal",
"from",
"the",
"input",
".",
"If",
"an",
"identifier",
"is",
"not",
"present",
"readString",
"records",
"a",
"syntax",
"error",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cmd/acmego/read.go#L149-L176 |
140,164 | rsc/rsc | cmd/acmego/read.go | readImport | func (r *importReader) readImport() {
c := r.peekByte(true)
if c == '.' {
r.peek = 0
} else if isIdent(c) {
r.readIdent()
}
r.readString()
} | go | func (r *importReader) readImport() {
c := r.peekByte(true)
if c == '.' {
r.peek = 0
} else if isIdent(c) {
r.readIdent()
}
r.readString()
} | [
"func",
"(",
"r",
"*",
"importReader",
")",
"readImport",
"(",
")",
"{",
"c",
":=",
"r",
".",
"peekByte",
"(",
"true",
")",
"\n",
"if",
"c",
"==",
"'.'",
"{",
"r",
".",
"peek",
"=",
"0",
"\n",
"}",
"else",
"if",
"isIdent",
"(",
"c",
")",
"{",... | // readImport reads an import clause - optional identifier followed by quoted string -
// from the input. | [
"readImport",
"reads",
"an",
"import",
"clause",
"-",
"optional",
"identifier",
"followed",
"by",
"quoted",
"string",
"-",
"from",
"the",
"input",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cmd/acmego/read.go#L180-L188 |
140,165 | rsc/rsc | cmd/acmego/read.go | readComments | func readComments(f io.Reader) ([]byte, error) {
r := &importReader{b: bufio.NewReader(f)}
r.peekByte(true)
if r.err == nil && !r.eof {
// Didn't reach EOF, so must have found a non-space byte. Remove it.
r.buf = r.buf[:len(r.buf)-1]
}
return r.buf, r.err
} | go | func readComments(f io.Reader) ([]byte, error) {
r := &importReader{b: bufio.NewReader(f)}
r.peekByte(true)
if r.err == nil && !r.eof {
// Didn't reach EOF, so must have found a non-space byte. Remove it.
r.buf = r.buf[:len(r.buf)-1]
}
return r.buf, r.err
} | [
"func",
"readComments",
"(",
"f",
"io",
".",
"Reader",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"r",
":=",
"&",
"importReader",
"{",
"b",
":",
"bufio",
".",
"NewReader",
"(",
"f",
")",
"}",
"\n",
"r",
".",
"peekByte",
"(",
"true",
")... | // readComments is like ioutil.ReadAll, except that it only reads the leading
// block of comments in the file. | [
"readComments",
"is",
"like",
"ioutil",
".",
"ReadAll",
"except",
"that",
"it",
"only",
"reads",
"the",
"leading",
"block",
"of",
"comments",
"in",
"the",
"file",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cmd/acmego/read.go#L192-L200 |
140,166 | rsc/rsc | cmd/acmego/read.go | readImports | func readImports(f io.Reader, reportSyntaxError bool) ([]byte, error) {
r := &importReader{b: bufio.NewReader(f)}
r.readKeyword("package")
r.readIdent()
for r.peekByte(true) == 'i' {
r.readKeyword("import")
if r.peekByte(true) == '(' {
r.nextByte(false)
for r.peekByte(true) != ')' && r.err == nil {
r... | go | func readImports(f io.Reader, reportSyntaxError bool) ([]byte, error) {
r := &importReader{b: bufio.NewReader(f)}
r.readKeyword("package")
r.readIdent()
for r.peekByte(true) == 'i' {
r.readKeyword("import")
if r.peekByte(true) == '(' {
r.nextByte(false)
for r.peekByte(true) != ')' && r.err == nil {
r... | [
"func",
"readImports",
"(",
"f",
"io",
".",
"Reader",
",",
"reportSyntaxError",
"bool",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"r",
":=",
"&",
"importReader",
"{",
"b",
":",
"bufio",
".",
"NewReader",
"(",
"f",
")",
"}",
"\n\n",
"r",
... | // readImports is like ioutil.ReadAll, except that it expects a Go file as input
// and stops reading the input once the imports have completed. | [
"readImports",
"is",
"like",
"ioutil",
".",
"ReadAll",
"except",
"that",
"it",
"expects",
"a",
"Go",
"file",
"as",
"input",
"and",
"stops",
"reading",
"the",
"input",
"once",
"the",
"imports",
"have",
"completed",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cmd/acmego/read.go#L204-L238 |
140,167 | rsc/rsc | fuse/fuse.go | Mount | func Mount(dir string) (*Conn, error) {
// TODO(rsc): mount options (...string?)
fd, errstr := mount(dir)
if errstr != "" {
return nil, errors.New(errstr)
}
return &Conn{fd: fd}, nil
} | go | func Mount(dir string) (*Conn, error) {
// TODO(rsc): mount options (...string?)
fd, errstr := mount(dir)
if errstr != "" {
return nil, errors.New(errstr)
}
return &Conn{fd: fd}, nil
} | [
"func",
"Mount",
"(",
"dir",
"string",
")",
"(",
"*",
"Conn",
",",
"error",
")",
"{",
"// TODO(rsc): mount options (...string?)",
"fd",
",",
"errstr",
":=",
"mount",
"(",
"dir",
")",
"\n",
"if",
"errstr",
"!=",
"\"",
"\"",
"{",
"return",
"nil",
",",
"e... | // Mount mounts a new FUSE connection on the named directory
// and returns a connection for reading and writing FUSE messages. | [
"Mount",
"mounts",
"a",
"new",
"FUSE",
"connection",
"on",
"the",
"named",
"directory",
"and",
"returns",
"a",
"connection",
"for",
"reading",
"and",
"writing",
"FUSE",
"messages",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/fuse/fuse.go#L111-L119 |
140,168 | rsc/rsc | fuse/fuse.go | Respond | func (r *SetxattrRequest) Respond() {
out := &outHeader{Unique: uint64(r.ID)}
r.Conn.respond(out, unsafe.Sizeof(*out))
} | go | func (r *SetxattrRequest) Respond() {
out := &outHeader{Unique: uint64(r.ID)}
r.Conn.respond(out, unsafe.Sizeof(*out))
} | [
"func",
"(",
"r",
"*",
"SetxattrRequest",
")",
"Respond",
"(",
")",
"{",
"out",
":=",
"&",
"outHeader",
"{",
"Unique",
":",
"uint64",
"(",
"r",
".",
"ID",
")",
"}",
"\n",
"r",
".",
"Conn",
".",
"respond",
"(",
"out",
",",
"unsafe",
".",
"Sizeof",... | // Respond replies to the request, indicating that the extended attribute was set. | [
"Respond",
"replies",
"to",
"the",
"request",
"indicating",
"that",
"the",
"extended",
"attribute",
"was",
"set",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/fuse/fuse.go#L1062-L1065 |
140,169 | rsc/rsc | fuse/fuse.go | AppendDirent | func AppendDirent(data []byte, dir Dirent) []byte {
de := dirent{
Ino: dir.Inode,
Namelen: uint32(len(dir.Name)),
Type: dir.Type,
}
de.Off = uint64(len(data) + direntSize + (len(dir.Name)+7)&^7)
data = append(data, (*[direntSize]byte)(unsafe.Pointer(&de))[:]...)
data = append(data, dir.Name...)
n := ... | go | func AppendDirent(data []byte, dir Dirent) []byte {
de := dirent{
Ino: dir.Inode,
Namelen: uint32(len(dir.Name)),
Type: dir.Type,
}
de.Off = uint64(len(data) + direntSize + (len(dir.Name)+7)&^7)
data = append(data, (*[direntSize]byte)(unsafe.Pointer(&de))[:]...)
data = append(data, dir.Name...)
n := ... | [
"func",
"AppendDirent",
"(",
"data",
"[",
"]",
"byte",
",",
"dir",
"Dirent",
")",
"[",
"]",
"byte",
"{",
"de",
":=",
"dirent",
"{",
"Ino",
":",
"dir",
".",
"Inode",
",",
"Namelen",
":",
"uint32",
"(",
"len",
"(",
"dir",
".",
"Name",
")",
")",
"... | // AppendDirent appends the encoded form of a directory entry to data
// and returns the resulting slice. | [
"AppendDirent",
"appends",
"the",
"encoded",
"form",
"of",
"a",
"directory",
"entry",
"to",
"data",
"and",
"returns",
"the",
"resulting",
"slice",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/fuse/fuse.go#L1312-L1327 |
140,170 | rsc/rsc | fuse/fuse.go | Respond | func (r *SetattrRequest) Respond(resp *SetattrResponse) {
out := &attrOut{
outHeader: outHeader{Unique: uint64(r.ID)},
AttrValid: uint64(resp.AttrValid / time.Second),
AttrValidNsec: uint32(resp.AttrValid % time.Second / time.Nanosecond),
Attr: resp.Attr.attr(),
}
r.Conn.respond(&out.outHead... | go | func (r *SetattrRequest) Respond(resp *SetattrResponse) {
out := &attrOut{
outHeader: outHeader{Unique: uint64(r.ID)},
AttrValid: uint64(resp.AttrValid / time.Second),
AttrValidNsec: uint32(resp.AttrValid % time.Second / time.Nanosecond),
Attr: resp.Attr.attr(),
}
r.Conn.respond(&out.outHead... | [
"func",
"(",
"r",
"*",
"SetattrRequest",
")",
"Respond",
"(",
"resp",
"*",
"SetattrResponse",
")",
"{",
"out",
":=",
"&",
"attrOut",
"{",
"outHeader",
":",
"outHeader",
"{",
"Unique",
":",
"uint64",
"(",
"r",
".",
"ID",
")",
"}",
",",
"AttrValid",
":... | // Respond replies to the request with the given response,
// giving the updated attributes. | [
"Respond",
"replies",
"to",
"the",
"request",
"with",
"the",
"given",
"response",
"giving",
"the",
"updated",
"attributes",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/fuse/fuse.go#L1434-L1442 |
140,171 | rsc/rsc | keychain/doc.go | UserPasswd | func UserPasswd(server, preferredUser string) (user, passwd string, err error) {
user, passwd, err = userPasswd(server, preferredUser)
if err != nil {
if preferredUser != "" {
err = fmt.Errorf("loading password for %s@%s: %v", preferredUser, server, err)
} else {
err = fmt.Errorf("loading password for %s: %... | go | func UserPasswd(server, preferredUser string) (user, passwd string, err error) {
user, passwd, err = userPasswd(server, preferredUser)
if err != nil {
if preferredUser != "" {
err = fmt.Errorf("loading password for %s@%s: %v", preferredUser, server, err)
} else {
err = fmt.Errorf("loading password for %s: %... | [
"func",
"UserPasswd",
"(",
"server",
",",
"preferredUser",
"string",
")",
"(",
"user",
",",
"passwd",
"string",
",",
"err",
"error",
")",
"{",
"user",
",",
"passwd",
",",
"err",
"=",
"userPasswd",
"(",
"server",
",",
"preferredUser",
")",
"\n",
"if",
"... | // UserPasswd returns the user name and password for authenticating
// to the named server. If the user argument is non-empty, UserPasswd
// restricts its search to passwords for the named user. | [
"UserPasswd",
"returns",
"the",
"user",
"name",
"and",
"password",
"for",
"authenticating",
"to",
"the",
"named",
"server",
".",
"If",
"the",
"user",
"argument",
"is",
"non",
"-",
"empty",
"UserPasswd",
"restricts",
"its",
"search",
"to",
"passwords",
"for",
... | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/keychain/doc.go#L18-L28 |
140,172 | rsc/rsc | scancab/database/db.go | Open | func Open(name string) (*DB, error) {
_, err := os.Stat(name)
if err != nil {
return nil, err
}
meta, err := sql.Open("sqlite3", name)
if err != nil {
return nil, err
}
store := new(dbstore.Storage)
store.Register(new(Doc))
store.Register(new(thumb))
store.Register(new(text))
return &DB{meta, store, name... | go | func Open(name string) (*DB, error) {
_, err := os.Stat(name)
if err != nil {
return nil, err
}
meta, err := sql.Open("sqlite3", name)
if err != nil {
return nil, err
}
store := new(dbstore.Storage)
store.Register(new(Doc))
store.Register(new(thumb))
store.Register(new(text))
return &DB{meta, store, name... | [
"func",
"Open",
"(",
"name",
"string",
")",
"(",
"*",
"DB",
",",
"error",
")",
"{",
"_",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"meta",
",",
... | // Open opens the database in the named file. | [
"Open",
"opens",
"the",
"database",
"in",
"the",
"named",
"file",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/scancab/database/db.go#L33-L47 |
140,173 | rsc/rsc | scancab/database/db.go | Write | func (db *DB) Write(doc *Doc) error {
tx, err := db.meta.Begin()
if err != nil {
return err
}
defer tx.Rollback() // no-op if tx.Commit called already
id := doc.ID
if err := db.store.Insert(tx, doc); err != nil {
doc.ID = id
return err
}
txt := text{
ID: doc.ID,
Desc: strings.ToLower(doc.Desc),
T... | go | func (db *DB) Write(doc *Doc) error {
tx, err := db.meta.Begin()
if err != nil {
return err
}
defer tx.Rollback() // no-op if tx.Commit called already
id := doc.ID
if err := db.store.Insert(tx, doc); err != nil {
doc.ID = id
return err
}
txt := text{
ID: doc.ID,
Desc: strings.ToLower(doc.Desc),
T... | [
"func",
"(",
"db",
"*",
"DB",
")",
"Write",
"(",
"doc",
"*",
"Doc",
")",
"error",
"{",
"tx",
",",
"err",
":=",
"db",
".",
"meta",
".",
"Begin",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"defer",
"tx",
... | // Write adds doc to the database, overwriting any existing
// entry with the same doc.ID. | [
"Write",
"adds",
"doc",
"to",
"the",
"database",
"overwriting",
"any",
"existing",
"entry",
"with",
"the",
"same",
"doc",
".",
"ID",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/scancab/database/db.go#L108-L135 |
140,174 | rsc/rsc | scancab/database/db.go | Search | func (db *DB) Search(query, sortBy string, offset, count int) ([]*Doc, error) {
var docs []*Doc
err := db.store.Select(db.meta, &docs, `where "ID" in (select "ID" from "rsc.io/rsc/scancab/database.text" where "rsc.io/rsc/scancab/database.text" match ?) order by `+sortBy+` limit ? offset ?`, query, count, offset)
if ... | go | func (db *DB) Search(query, sortBy string, offset, count int) ([]*Doc, error) {
var docs []*Doc
err := db.store.Select(db.meta, &docs, `where "ID" in (select "ID" from "rsc.io/rsc/scancab/database.text" where "rsc.io/rsc/scancab/database.text" match ?) order by `+sortBy+` limit ? offset ?`, query, count, offset)
if ... | [
"func",
"(",
"db",
"*",
"DB",
")",
"Search",
"(",
"query",
",",
"sortBy",
"string",
",",
"offset",
",",
"count",
"int",
")",
"(",
"[",
"]",
"*",
"Doc",
",",
"error",
")",
"{",
"var",
"docs",
"[",
"]",
"*",
"Doc",
"\n",
"err",
":=",
"db",
".",... | // Search returns documents matching query, an SQLITE full-text search.
// The results are ordered by 'sortBy', and at most count results are returned
// after skipping the first offset results. | [
"Search",
"returns",
"documents",
"matching",
"query",
"an",
"SQLITE",
"full",
"-",
"text",
"search",
".",
"The",
"results",
"are",
"ordered",
"by",
"sortBy",
"and",
"at",
"most",
"count",
"results",
"are",
"returned",
"after",
"skipping",
"the",
"first",
"o... | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/scancab/database/db.go#L169-L176 |
140,175 | rsc/rsc | scancab/database/db.go | Pending | func (db *DB) Pending(sortBy string, offset, count int) ([]*Doc, error) {
var docs []*Doc
err := db.store.Select(db.meta, &docs, `where "Time" = ? order by `+sortBy+` limit ? offset ?`, time.Time{}, count, offset)
if err != nil {
return nil, err
}
return docs, nil
} | go | func (db *DB) Pending(sortBy string, offset, count int) ([]*Doc, error) {
var docs []*Doc
err := db.store.Select(db.meta, &docs, `where "Time" = ? order by `+sortBy+` limit ? offset ?`, time.Time{}, count, offset)
if err != nil {
return nil, err
}
return docs, nil
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"Pending",
"(",
"sortBy",
"string",
",",
"offset",
",",
"count",
"int",
")",
"(",
"[",
"]",
"*",
"Doc",
",",
"error",
")",
"{",
"var",
"docs",
"[",
"]",
"*",
"Doc",
"\n",
"err",
":=",
"db",
".",
"store",
"."... | // Pending enumerates the unfiled documents in the database,
// sorting them by 'sortBy', and then returning at most count documents
// after skipping offset. | [
"Pending",
"enumerates",
"the",
"unfiled",
"documents",
"in",
"the",
"database",
"sorting",
"them",
"by",
"sortBy",
"and",
"then",
"returning",
"at",
"most",
"count",
"documents",
"after",
"skipping",
"offset",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/scancab/database/db.go#L193-L200 |
140,176 | rsc/rsc | scancab/database/db.go | SearchFile | func (db *DB) SearchFile(name string) (*Doc, error) {
var doc *Doc
err := db.store.Select(db.meta, &doc, `where "File" = ?`, name)
if err != nil {
return nil, err
}
if doc == nil {
return nil, ErrNotFound
}
return doc, nil
} | go | func (db *DB) SearchFile(name string) (*Doc, error) {
var doc *Doc
err := db.store.Select(db.meta, &doc, `where "File" = ?`, name)
if err != nil {
return nil, err
}
if doc == nil {
return nil, ErrNotFound
}
return doc, nil
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"SearchFile",
"(",
"name",
"string",
")",
"(",
"*",
"Doc",
",",
"error",
")",
"{",
"var",
"doc",
"*",
"Doc",
"\n",
"err",
":=",
"db",
".",
"store",
".",
"Select",
"(",
"db",
".",
"meta",
",",
"&",
"doc",
","... | // SearchFile searches the database for the document describing the named file. | [
"SearchFile",
"searches",
"the",
"database",
"for",
"the",
"document",
"describing",
"the",
"named",
"file",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/scancab/database/db.go#L205-L215 |
140,177 | rsc/rsc | scancab/database/db.go | SearchID | func (db *DB) SearchID(id int64) (*Doc, error) {
var doc *Doc
err := db.store.Select(db.meta, &doc, `where "ID" = ?`, id)
if err != nil {
return nil, err
}
return doc, nil
} | go | func (db *DB) SearchID(id int64) (*Doc, error) {
var doc *Doc
err := db.store.Select(db.meta, &doc, `where "ID" = ?`, id)
if err != nil {
return nil, err
}
return doc, nil
} | [
"func",
"(",
"db",
"*",
"DB",
")",
"SearchID",
"(",
"id",
"int64",
")",
"(",
"*",
"Doc",
",",
"error",
")",
"{",
"var",
"doc",
"*",
"Doc",
"\n",
"err",
":=",
"db",
".",
"store",
".",
"Select",
"(",
"db",
".",
"meta",
",",
"&",
"doc",
",",
"... | // SearchID searches the database for the document with the given ID. | [
"SearchID",
"searches",
"the",
"database",
"for",
"the",
"document",
"with",
"the",
"given",
"ID",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/scancab/database/db.go#L218-L225 |
140,178 | rsc/rsc | cloudprint/xmpp.go | Recv | func (c *xmppClient) Recv() error {
for {
_, val, err := next(c.p)
if err != nil {
return err
}
switch val.(type) {
case *clientMessage:
return nil
default:
}
}
} | go | func (c *xmppClient) Recv() error {
for {
_, val, err := next(c.p)
if err != nil {
return err
}
switch val.(type) {
case *clientMessage:
return nil
default:
}
}
} | [
"func",
"(",
"c",
"*",
"xmppClient",
")",
"Recv",
"(",
")",
"error",
"{",
"for",
"{",
"_",
",",
"val",
",",
"err",
":=",
"next",
"(",
"c",
".",
"p",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"switch",
"val",
... | // Recv receives the next XMPP message.
// It returns only the possible error - there's no body worth mentioning. | [
"Recv",
"receives",
"the",
"next",
"XMPP",
"message",
".",
"It",
"returns",
"only",
"the",
"possible",
"error",
"-",
"there",
"s",
"no",
"body",
"worth",
"mentioning",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cloudprint/xmpp.go#L208-L220 |
140,179 | rsc/rsc | cloudprint/xmpp.go | Subscribe | func (c *xmppClient) Subscribe() error {
barejid := c.jid
i := strings.Index(barejid, "/")
if i >= 0 {
barejid = barejid[:i]
}
println("\nok\n", "jid", c.jid, "\n")
fmt.Fprintf(c.tls, "<iq type='set' id='z1'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq>")
fmt.Fprintf(c.tls, "<iq type='set' to='%s... | go | func (c *xmppClient) Subscribe() error {
barejid := c.jid
i := strings.Index(barejid, "/")
if i >= 0 {
barejid = barejid[:i]
}
println("\nok\n", "jid", c.jid, "\n")
fmt.Fprintf(c.tls, "<iq type='set' id='z1'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq>")
fmt.Fprintf(c.tls, "<iq type='set' to='%s... | [
"func",
"(",
"c",
"*",
"xmppClient",
")",
"Subscribe",
"(",
")",
"error",
"{",
"barejid",
":=",
"c",
".",
"jid",
"\n",
"i",
":=",
"strings",
".",
"Index",
"(",
"barejid",
",",
"\"",
"\"",
")",
"\n",
"if",
"i",
">=",
"0",
"{",
"barejid",
"=",
"b... | // Subscribe sends a subscription request. | [
"Subscribe",
"sends",
"a",
"subscription",
"request",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cloudprint/xmpp.go#L223-L233 |
140,180 | rsc/rsc | cloudprint/xmpp.go | Status | func (c *xmppClient) Status(status, msg string) error {
fmt.Fprintf(c.tls, "<presence xml:lang='en'><show>%s</show><status>%s</status></presence>", status, xmlEscape(msg))
return nil
} | go | func (c *xmppClient) Status(status, msg string) error {
fmt.Fprintf(c.tls, "<presence xml:lang='en'><show>%s</show><status>%s</status></presence>", status, xmlEscape(msg))
return nil
} | [
"func",
"(",
"c",
"*",
"xmppClient",
")",
"Status",
"(",
"status",
",",
"msg",
"string",
")",
"error",
"{",
"fmt",
".",
"Fprintf",
"(",
"c",
".",
"tls",
",",
"\"",
"\"",
",",
"status",
",",
"xmlEscape",
"(",
"msg",
")",
")",
"\n",
"return",
"nil"... | // Status sends a presence update. | [
"Status",
"sends",
"a",
"presence",
"update",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cloudprint/xmpp.go#L236-L239 |
140,181 | rsc/rsc | cc/typecheck.go | promote2 | func promote2(l, r *Type) *Type {
l = promote1(l)
r = promote1(r)
// if mixed signedness, make l signed and r unsigned.
// specifically, if l is unsigned, swap with r.
if (l.Kind-Char)&1 == 1 {
l, r = r, l
}
switch {
case l.Kind == Void || r.Kind == Void || l.Kind > Double || r.Kind > Double:
return nil
... | go | func promote2(l, r *Type) *Type {
l = promote1(l)
r = promote1(r)
// if mixed signedness, make l signed and r unsigned.
// specifically, if l is unsigned, swap with r.
if (l.Kind-Char)&1 == 1 {
l, r = r, l
}
switch {
case l.Kind == Void || r.Kind == Void || l.Kind > Double || r.Kind > Double:
return nil
... | [
"func",
"promote2",
"(",
"l",
",",
"r",
"*",
"Type",
")",
"*",
"Type",
"{",
"l",
"=",
"promote1",
"(",
"l",
")",
"\n",
"r",
"=",
"promote1",
"(",
"r",
")",
"\n\n",
"// if mixed signedness, make l signed and r unsigned.",
"// specifically, if l is unsigned, swap ... | // The "usual arithmetic conversions". | [
"The",
"usual",
"arithmetic",
"conversions",
"."
] | fc62025902295658a9c7e89418e095fd598b2682 | https://github.com/rsc/rsc/blob/fc62025902295658a9c7e89418e095fd598b2682/cc/typecheck.go#L473-L518 |
140,182 | tvdburgt/go-argon2 | argon2.go | Hash | func Hash(ctx *Context, password, salt []byte) ([]byte, error) {
if ctx == nil {
return nil, ErrContext
}
return ctx.hash(password, salt)
} | go | func Hash(ctx *Context, password, salt []byte) ([]byte, error) {
if ctx == nil {
return nil, ErrContext
}
return ctx.hash(password, salt)
} | [
"func",
"Hash",
"(",
"ctx",
"*",
"Context",
",",
"password",
",",
"salt",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"ctx",
"==",
"nil",
"{",
"return",
"nil",
",",
"ErrContext",
"\n",
"}",
"\n\n",
"return",
"ctx",... | // Set C.FLAG_clear_internal_memory = 0 to disable internal memory clearing
// Hash hashes a password given a salt and an initialized Argon2 context. It
// returns the calculated hash as an output of raw bytes. | [
"Set",
"C",
".",
"FLAG_clear_internal_memory",
"=",
"0",
"to",
"disable",
"internal",
"memory",
"clearing",
"Hash",
"hashes",
"a",
"password",
"given",
"a",
"salt",
"and",
"an",
"initialized",
"Argon2",
"context",
".",
"It",
"returns",
"the",
"calculated",
"ha... | 49d0f0e5973cfdf45080ac824b9a67c24aa38725 | https://github.com/tvdburgt/go-argon2/blob/49d0f0e5973cfdf45080ac824b9a67c24aa38725/argon2.go#L44-L50 |
140,183 | tvdburgt/go-argon2 | argon2.go | HashEncoded | func HashEncoded(ctx *Context, password []byte, salt []byte) (string, error) {
if ctx == nil {
return "", ErrContext
}
if len(password) == 0 {
return "", ErrPassword
}
if len(salt) == 0 {
return "", ErrSalt
}
encodedlen := C.argon2_encodedlen(
C.uint32_t(ctx.Iterations),
C.uint32_t(ctx.Memory),
C.u... | go | func HashEncoded(ctx *Context, password []byte, salt []byte) (string, error) {
if ctx == nil {
return "", ErrContext
}
if len(password) == 0 {
return "", ErrPassword
}
if len(salt) == 0 {
return "", ErrSalt
}
encodedlen := C.argon2_encodedlen(
C.uint32_t(ctx.Iterations),
C.uint32_t(ctx.Memory),
C.u... | [
"func",
"HashEncoded",
"(",
"ctx",
"*",
"Context",
",",
"password",
"[",
"]",
"byte",
",",
"salt",
"[",
"]",
"byte",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"ctx",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"ErrContext",
"\n",
"}",
"\... | // HashEncoded hashes a password and produces a crypt-like encoded string. | [
"HashEncoded",
"hashes",
"a",
"password",
"and",
"produces",
"a",
"crypt",
"-",
"like",
"encoded",
"string",
"."
] | 49d0f0e5973cfdf45080ac824b9a67c24aa38725 | https://github.com/tvdburgt/go-argon2/blob/49d0f0e5973cfdf45080ac824b9a67c24aa38725/argon2.go#L53-L93 |
140,184 | tvdburgt/go-argon2 | argon2.go | Verify | func Verify(ctx *Context, hash, password, salt []byte) (bool, error) {
if ctx == nil {
return false, ErrContext
}
if len(hash) == 0 {
return false, ErrHash
}
hash2, err := ctx.hash(password, salt)
if err != nil {
return false, err
}
return subtle.ConstantTimeCompare(hash, hash2) == 1, nil
} | go | func Verify(ctx *Context, hash, password, salt []byte) (bool, error) {
if ctx == nil {
return false, ErrContext
}
if len(hash) == 0 {
return false, ErrHash
}
hash2, err := ctx.hash(password, salt)
if err != nil {
return false, err
}
return subtle.ConstantTimeCompare(hash, hash2) == 1, nil
} | [
"func",
"Verify",
"(",
"ctx",
"*",
"Context",
",",
"hash",
",",
"password",
",",
"salt",
"[",
"]",
"byte",
")",
"(",
"bool",
",",
"error",
")",
"{",
"if",
"ctx",
"==",
"nil",
"{",
"return",
"false",
",",
"ErrContext",
"\n",
"}",
"\n",
"if",
"len"... | // Verify verifies an Argon2 hash against a plaintext password. | [
"Verify",
"verifies",
"an",
"Argon2",
"hash",
"against",
"a",
"plaintext",
"password",
"."
] | 49d0f0e5973cfdf45080ac824b9a67c24aa38725 | https://github.com/tvdburgt/go-argon2/blob/49d0f0e5973cfdf45080ac824b9a67c24aa38725/argon2.go#L96-L110 |
140,185 | tvdburgt/go-argon2 | argon2.go | VerifyEncoded | func VerifyEncoded(s string, password []byte) (bool, error) {
mode, err := getMode(s)
if err != nil {
return false, err
}
cs := C.CString(s)
defer C.free(unsafe.Pointer(cs))
result := C.argon2_verify(
cs,
unsafe.Pointer(&password[0]),
C.size_t(len(password)),
C.argon2_type(mode))
if result == C.AR... | go | func VerifyEncoded(s string, password []byte) (bool, error) {
mode, err := getMode(s)
if err != nil {
return false, err
}
cs := C.CString(s)
defer C.free(unsafe.Pointer(cs))
result := C.argon2_verify(
cs,
unsafe.Pointer(&password[0]),
C.size_t(len(password)),
C.argon2_type(mode))
if result == C.AR... | [
"func",
"VerifyEncoded",
"(",
"s",
"string",
",",
"password",
"[",
"]",
"byte",
")",
"(",
"bool",
",",
"error",
")",
"{",
"mode",
",",
"err",
":=",
"getMode",
"(",
"s",
")",
"\n\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\... | // VerifyEncoded verifies an encoded Argon2 hash s against a plaintext password. | [
"VerifyEncoded",
"verifies",
"an",
"encoded",
"Argon2",
"hash",
"s",
"against",
"a",
"plaintext",
"password",
"."
] | 49d0f0e5973cfdf45080ac824b9a67c24aa38725 | https://github.com/tvdburgt/go-argon2/blob/49d0f0e5973cfdf45080ac824b9a67c24aa38725/argon2.go#L113-L137 |
140,186 | tvdburgt/go-argon2 | argon2.go | getMode | func getMode(s string) (int, error) {
switch {
case strings.HasPrefix(s, "$argon2d"):
return ModeArgon2d, nil
case strings.HasPrefix(s, "$argon2id"):
return ModeArgon2id, nil
case strings.HasPrefix(s, "$argon2i"):
return ModeArgon2i, nil
default:
return -1, ErrDecodingFail
}
} | go | func getMode(s string) (int, error) {
switch {
case strings.HasPrefix(s, "$argon2d"):
return ModeArgon2d, nil
case strings.HasPrefix(s, "$argon2id"):
return ModeArgon2id, nil
case strings.HasPrefix(s, "$argon2i"):
return ModeArgon2i, nil
default:
return -1, ErrDecodingFail
}
} | [
"func",
"getMode",
"(",
"s",
"string",
")",
"(",
"int",
",",
"error",
")",
"{",
"switch",
"{",
"case",
"strings",
".",
"HasPrefix",
"(",
"s",
",",
"\"",
"\"",
")",
":",
"return",
"ModeArgon2d",
",",
"nil",
"\n",
"case",
"strings",
".",
"HasPrefix",
... | // getMode tries to extract the mode from an Argon2 encoded string. | [
"getMode",
"tries",
"to",
"extract",
"the",
"mode",
"from",
"an",
"Argon2",
"encoded",
"string",
"."
] | 49d0f0e5973cfdf45080ac824b9a67c24aa38725 | https://github.com/tvdburgt/go-argon2/blob/49d0f0e5973cfdf45080ac824b9a67c24aa38725/argon2.go#L140-L151 |
140,187 | tvdburgt/go-argon2 | context.go | NewContext | func NewContext(mode ...int) *Context {
context := &Context{
Iterations: 3,
Memory: 1 << 12, // 4 MiB
Parallelism: 1,
HashLen: 32,
Mode: ModeArgon2i,
Version: VersionDefault,
}
if len(mode) >= 1 {
context.Mode = mode[0]
}
return context
} | go | func NewContext(mode ...int) *Context {
context := &Context{
Iterations: 3,
Memory: 1 << 12, // 4 MiB
Parallelism: 1,
HashLen: 32,
Mode: ModeArgon2i,
Version: VersionDefault,
}
if len(mode) >= 1 {
context.Mode = mode[0]
}
return context
} | [
"func",
"NewContext",
"(",
"mode",
"...",
"int",
")",
"*",
"Context",
"{",
"context",
":=",
"&",
"Context",
"{",
"Iterations",
":",
"3",
",",
"Memory",
":",
"1",
"<<",
"12",
",",
"// 4 MiB",
"Parallelism",
":",
"1",
",",
"HashLen",
":",
"32",
",",
... | // NewContext initializes a new Argon2 context with reasonable defaults.
// allows the mode to be set as an optional paramter | [
"NewContext",
"initializes",
"a",
"new",
"Argon2",
"context",
"with",
"reasonable",
"defaults",
".",
"allows",
"the",
"mode",
"to",
"be",
"set",
"as",
"an",
"optional",
"paramter"
] | 49d0f0e5973cfdf45080ac824b9a67c24aa38725 | https://github.com/tvdburgt/go-argon2/blob/49d0f0e5973cfdf45080ac824b9a67c24aa38725/context.go#L24-L37 |
140,188 | tvdburgt/go-argon2 | context.go | hash | func (ctx *Context) hash(password []byte, salt []byte) ([]byte, error) {
if len(password) == 0 {
return nil, ErrPassword
}
if len(salt) == 0 {
return nil, ErrSalt
}
hash := make([]byte, ctx.HashLen)
// optional secret
secret := (*C.uint8_t)(nil)
if len(ctx.Secret) > 0 {
secret = (*C.uint8_t)(&ctx.Secre... | go | func (ctx *Context) hash(password []byte, salt []byte) ([]byte, error) {
if len(password) == 0 {
return nil, ErrPassword
}
if len(salt) == 0 {
return nil, ErrSalt
}
hash := make([]byte, ctx.HashLen)
// optional secret
secret := (*C.uint8_t)(nil)
if len(ctx.Secret) > 0 {
secret = (*C.uint8_t)(&ctx.Secre... | [
"func",
"(",
"ctx",
"*",
"Context",
")",
"hash",
"(",
"password",
"[",
"]",
"byte",
",",
"salt",
"[",
"]",
"byte",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"len",
"(",
"password",
")",
"==",
"0",
"{",
"return",
"nil",
",",
"E... | // hash password and salt | [
"hash",
"password",
"and",
"salt"
] | 49d0f0e5973cfdf45080ac824b9a67c24aa38725 | https://github.com/tvdburgt/go-argon2/blob/49d0f0e5973cfdf45080ac824b9a67c24aa38725/context.go#L40-L96 |
140,189 | jetbasrawi/go.geteventstore | client.go | SetBasicAuth | func (c *Client) SetBasicAuth(username, password string) {
c.credentials = &basicAuthCredentials{
Username: username,
Password: password,
}
} | go | func (c *Client) SetBasicAuth(username, password string) {
c.credentials = &basicAuthCredentials{
Username: username,
Password: password,
}
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetBasicAuth",
"(",
"username",
",",
"password",
"string",
")",
"{",
"c",
".",
"credentials",
"=",
"&",
"basicAuthCredentials",
"{",
"Username",
":",
"username",
",",
"Password",
":",
"password",
",",
"}",
"\n",
"}"... | // SetBasicAuth sets the credentials for requests.
//
// Credentials will be read from the client before each request. | [
"SetBasicAuth",
"sets",
"the",
"credentials",
"for",
"requests",
".",
"Credentials",
"will",
"be",
"read",
"from",
"the",
"client",
"before",
"each",
"request",
"."
] | 79eb478399b05a176102a5b0b6493f4692fdfc1a | https://github.com/jetbasrawi/go.geteventstore/blob/79eb478399b05a176102a5b0b6493f4692fdfc1a/client.go#L141-L146 |
140,190 | jetbasrawi/go.geteventstore | client.go | GetFeedPath | func (c *Client) GetFeedPath(stream, direction string, version int, pageSize int) (string, error) {
ps := pageSize
dir := ""
switch direction {
case "forward", "backward":
dir = direction
default:
return "", fmt.Errorf("Invalid Direction %s. Allowed values are \"forward\" or \"backward\" \n", direction)
}
... | go | func (c *Client) GetFeedPath(stream, direction string, version int, pageSize int) (string, error) {
ps := pageSize
dir := ""
switch direction {
case "forward", "backward":
dir = direction
default:
return "", fmt.Errorf("Invalid Direction %s. Allowed values are \"forward\" or \"backward\" \n", direction)
}
... | [
"func",
"(",
"c",
"*",
"Client",
")",
"GetFeedPath",
"(",
"stream",
",",
"direction",
"string",
",",
"version",
"int",
",",
"pageSize",
"int",
")",
"(",
"string",
",",
"error",
")",
"{",
"ps",
":=",
"pageSize",
"\n\n",
"dir",
":=",
"\"",
"\"",
"\n",
... | // GetFeedPath returns the path for a feedpage
//
// Valid directions are "forward" and "backward".
//
// To get the path to the head of the stream, pass a negative integer in the version
// argument and "backward" as the direction. | [
"GetFeedPath",
"returns",
"the",
"path",
"for",
"a",
"feedpage",
"Valid",
"directions",
"are",
"forward",
"and",
"backward",
".",
"To",
"get",
"the",
"path",
"to",
"the",
"head",
"of",
"the",
"stream",
"pass",
"a",
"negative",
"integer",
"in",
"the",
"vers... | 79eb478399b05a176102a5b0b6493f4692fdfc1a | https://github.com/jetbasrawi/go.geteventstore/blob/79eb478399b05a176102a5b0b6493f4692fdfc1a/client.go#L244-L265 |
140,191 | jetbasrawi/go.geteventstore | client.go | SetHeader | func (c *Client) SetHeader(key, value string) {
c.headers[key] = value
} | go | func (c *Client) SetHeader(key, value string) {
c.headers[key] = value
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetHeader",
"(",
"key",
",",
"value",
"string",
")",
"{",
"c",
".",
"headers",
"[",
"key",
"]",
"=",
"value",
"\n",
"}"
] | // SetHeader adds a header to the collection of headers that will be used on http requests.
//
// Any headers that are set on the client will be included in requests to the eventstore. | [
"SetHeader",
"adds",
"a",
"header",
"to",
"the",
"collection",
"of",
"headers",
"that",
"will",
"be",
"used",
"on",
"http",
"requests",
".",
"Any",
"headers",
"that",
"are",
"set",
"on",
"the",
"client",
"will",
"be",
"included",
"in",
"requests",
"to",
... | 79eb478399b05a176102a5b0b6493f4692fdfc1a | https://github.com/jetbasrawi/go.geteventstore/blob/79eb478399b05a176102a5b0b6493f4692fdfc1a/client.go#L294-L296 |
140,192 | jetbasrawi/go.geteventstore | client.go | getError | func getError(r *http.Response, req *http.Request) error {
if c := r.StatusCode; 200 <= c && c <= 299 {
return nil
}
errorResponse := &ErrorResponse{Response: r}
data, err := ioutil.ReadAll(r.Body)
if err == nil && data != nil {
json.Unmarshal(data, errorResponse)
}
errorResponse.Status = r.Status
errorRes... | go | func getError(r *http.Response, req *http.Request) error {
if c := r.StatusCode; 200 <= c && c <= 299 {
return nil
}
errorResponse := &ErrorResponse{Response: r}
data, err := ioutil.ReadAll(r.Body)
if err == nil && data != nil {
json.Unmarshal(data, errorResponse)
}
errorResponse.Status = r.Status
errorRes... | [
"func",
"getError",
"(",
"r",
"*",
"http",
".",
"Response",
",",
"req",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"if",
"c",
":=",
"r",
".",
"StatusCode",
";",
"200",
"<=",
"c",
"&&",
"c",
"<=",
"299",
"{",
"return",
"nil",
"\n",
"}",
"\n... | // getError inspects the HTTP response and constructs an appropriate error if
// the response was an error. | [
"getError",
"inspects",
"the",
"HTTP",
"response",
"and",
"constructs",
"an",
"appropriate",
"error",
"if",
"the",
"response",
"was",
"an",
"error",
"."
] | 79eb478399b05a176102a5b0b6493f4692fdfc1a | https://github.com/jetbasrawi/go.geteventstore/blob/79eb478399b05a176102a5b0b6493f4692fdfc1a/client.go#L434-L462 |
140,193 | jetbasrawi/go.geteventstore | internal/uuid/uuid.go | And | func And(u1 UUID, u2 UUID) UUID {
u := UUID{}
for i := 0; i < 16; i++ {
u[i] = u1[i] & u2[i]
}
return u
} | go | func And(u1 UUID, u2 UUID) UUID {
u := UUID{}
for i := 0; i < 16; i++ {
u[i] = u1[i] & u2[i]
}
return u
} | [
"func",
"And",
"(",
"u1",
"UUID",
",",
"u2",
"UUID",
")",
"UUID",
"{",
"u",
":=",
"UUID",
"{",
"}",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"16",
";",
"i",
"++",
"{",
"u",
"[",
"i",
"]",
"=",
"u1",
"[",
"i",
"]",
"&",
"u2",
"[",
"... | // And returns result of binary AND of two UUIDs. | [
"And",
"returns",
"result",
"of",
"binary",
"AND",
"of",
"two",
"UUIDs",
"."
] | 79eb478399b05a176102a5b0b6493f4692fdfc1a | https://github.com/jetbasrawi/go.geteventstore/blob/79eb478399b05a176102a5b0b6493f4692fdfc1a/internal/uuid/uuid.go#L152-L158 |
140,194 | jetbasrawi/go.geteventstore | internal/uuid/uuid.go | Or | func Or(u1 UUID, u2 UUID) UUID {
u := UUID{}
for i := 0; i < 16; i++ {
u[i] = u1[i] | u2[i]
}
return u
} | go | func Or(u1 UUID, u2 UUID) UUID {
u := UUID{}
for i := 0; i < 16; i++ {
u[i] = u1[i] | u2[i]
}
return u
} | [
"func",
"Or",
"(",
"u1",
"UUID",
",",
"u2",
"UUID",
")",
"UUID",
"{",
"u",
":=",
"UUID",
"{",
"}",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"16",
";",
"i",
"++",
"{",
"u",
"[",
"i",
"]",
"=",
"u1",
"[",
"i",
"]",
"|",
"u2",
"[",
"i... | // Or returns result of binary OR of two UUIDs. | [
"Or",
"returns",
"result",
"of",
"binary",
"OR",
"of",
"two",
"UUIDs",
"."
] | 79eb478399b05a176102a5b0b6493f4692fdfc1a | https://github.com/jetbasrawi/go.geteventstore/blob/79eb478399b05a176102a5b0b6493f4692fdfc1a/internal/uuid/uuid.go#L161-L167 |
140,195 | jetbasrawi/go.geteventstore | examples/02-longpoll/main.go | writeEvents | func writeEvents(client *goes.Client, streamName string) {
existingEvents := createTestEvents(10, streamName, serverURL, "FooEvent")
writer := client.NewStreamWriter(streamName)
err := writer.Append(nil, existingEvents...)
if err != nil {
log.Fatal(err)
}
ticker := time.NewTicker(time.Second * 2)
go func() {... | go | func writeEvents(client *goes.Client, streamName string) {
existingEvents := createTestEvents(10, streamName, serverURL, "FooEvent")
writer := client.NewStreamWriter(streamName)
err := writer.Append(nil, existingEvents...)
if err != nil {
log.Fatal(err)
}
ticker := time.NewTicker(time.Second * 2)
go func() {... | [
"func",
"writeEvents",
"(",
"client",
"*",
"goes",
".",
"Client",
",",
"streamName",
"string",
")",
"{",
"existingEvents",
":=",
"createTestEvents",
"(",
"10",
",",
"streamName",
",",
"serverURL",
",",
"\"",
"\"",
")",
"\n\n",
"writer",
":=",
"client",
"."... | // writeEvents will create an initial set of events and then write them to
// the eventstore.
// At two second intervals a random number of events between 1 and 5 will be written
// to the eventstore. | [
"writeEvents",
"will",
"create",
"an",
"initial",
"set",
"of",
"events",
"and",
"then",
"write",
"them",
"to",
"the",
"eventstore",
".",
"At",
"two",
"second",
"intervals",
"a",
"random",
"number",
"of",
"events",
"between",
"1",
"and",
"5",
"will",
"be",
... | 79eb478399b05a176102a5b0b6493f4692fdfc1a | https://github.com/jetbasrawi/go.geteventstore/blob/79eb478399b05a176102a5b0b6493f4692fdfc1a/examples/02-longpoll/main.go#L112-L130 |
140,196 | jetbasrawi/go.geteventstore | atom/atom.go | GetLink | func (f *Feed) GetLink(name string) *Link {
if f == nil {
return nil
}
for _, v := range f.Link {
if v.Rel == name {
return &v
}
}
return nil
} | go | func (f *Feed) GetLink(name string) *Link {
if f == nil {
return nil
}
for _, v := range f.Link {
if v.Rel == name {
return &v
}
}
return nil
} | [
"func",
"(",
"f",
"*",
"Feed",
")",
"GetLink",
"(",
"name",
"string",
")",
"*",
"Link",
"{",
"if",
"f",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"v",
":=",
"range",
"f",
".",
"Link",
"{",
"if",
"v",
".",
"Rel",
... | // GetLink gets the link with the name specified by the link argument. | [
"GetLink",
"gets",
"the",
"link",
"with",
"the",
"name",
"specified",
"by",
"the",
"link",
"argument",
"."
] | 79eb478399b05a176102a5b0b6493f4692fdfc1a | https://github.com/jetbasrawi/go.geteventstore/blob/79eb478399b05a176102a5b0b6493f4692fdfc1a/atom/atom.go#L23-L34 |
140,197 | jetbasrawi/go.geteventstore | atom/atom.go | PrettyPrint | func (f *Feed) PrettyPrint() string {
b, err := xml.MarshalIndent(f, "", " ")
if err != nil {
panic(err)
}
return string(b)
} | go | func (f *Feed) PrettyPrint() string {
b, err := xml.MarshalIndent(f, "", " ")
if err != nil {
panic(err)
}
return string(b)
} | [
"func",
"(",
"f",
"*",
"Feed",
")",
"PrettyPrint",
"(",
")",
"string",
"{",
"b",
",",
"err",
":=",
"xml",
".",
"MarshalIndent",
"(",
"f",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\... | // PrettyPrint returns an indented string representation of the feed. | [
"PrettyPrint",
"returns",
"an",
"indented",
"string",
"representation",
"of",
"the",
"feed",
"."
] | 79eb478399b05a176102a5b0b6493f4692fdfc1a | https://github.com/jetbasrawi/go.geteventstore/blob/79eb478399b05a176102a5b0b6493f4692fdfc1a/atom/atom.go#L37-L43 |
140,198 | jetbasrawi/go.geteventstore | atom/atom.go | GetEventURLs | func (f *Feed) GetEventURLs() ([]string, error) {
s := make([]string, len(f.Entry))
for i := 0; i < len(f.Entry); i++ {
e := f.Entry[i]
s[i] = strings.TrimRight(e.Link[1].Href, "/")
}
return s, nil
} | go | func (f *Feed) GetEventURLs() ([]string, error) {
s := make([]string, len(f.Entry))
for i := 0; i < len(f.Entry); i++ {
e := f.Entry[i]
s[i] = strings.TrimRight(e.Link[1].Href, "/")
}
return s, nil
} | [
"func",
"(",
"f",
"*",
"Feed",
")",
"GetEventURLs",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"s",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"f",
".",
"Entry",
")",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
... | // GetEventURLs extracts a slice of event urls from the feed object. | [
"GetEventURLs",
"extracts",
"a",
"slice",
"of",
"event",
"urls",
"from",
"the",
"feed",
"object",
"."
] | 79eb478399b05a176102a5b0b6493f4692fdfc1a | https://github.com/jetbasrawi/go.geteventstore/blob/79eb478399b05a176102a5b0b6493f4692fdfc1a/atom/atom.go#L46-L53 |
140,199 | jetbasrawi/go.geteventstore | events.go | PrettyPrint | func (e *EventResponse) PrettyPrint() string {
b, err := json.MarshalIndent(e, "", " ")
if err != nil {
panic(err)
}
return string(b)
} | go | func (e *EventResponse) PrettyPrint() string {
b, err := json.MarshalIndent(e, "", " ")
if err != nil {
panic(err)
}
return string(b)
} | [
"func",
"(",
"e",
"*",
"EventResponse",
")",
"PrettyPrint",
"(",
")",
"string",
"{",
"b",
",",
"err",
":=",
"json",
".",
"MarshalIndent",
"(",
"e",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
... | // PrettyPrint renders an indented json view of the EventResponse. | [
"PrettyPrint",
"renders",
"an",
"indented",
"json",
"view",
"of",
"the",
"EventResponse",
"."
] | 79eb478399b05a176102a5b0b6493f4692fdfc1a | https://github.com/jetbasrawi/go.geteventstore/blob/79eb478399b05a176102a5b0b6493f4692fdfc1a/events.go#L31-L39 |
Subsets and Splits
SQL Console for google/code_x_glue_ct_code_to_text
This query implements a thoughtful three-tier curation strategy to build a balanced safety dataset, categorizing code by destructive operations, safe I/O operations, and pure computational negatives with subsampling—revealing important patterns about how destructive intent manifests in Python code for model safety research.
SQL Console for google/code_x_glue_ct_code_to_text
This query performs meaningful classification of Python code samples into safety-relevant tiers based on destructive operations, I/O patterns, and pure computation, which could be valuable for building safety classifiers or curating training data, though the output itself is a filtered/ranked dataset rather than revealing novel statistical insights.