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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
31,400 | go-telegram-bot-api/telegram-bot-api | configs.go | values | func (config StickerConfig) values() (url.Values, error) {
v, err := config.BaseChat.values()
if err != nil {
return v, err
}
v.Add(config.name(), config.FileID)
return v, nil
} | go | func (config StickerConfig) values() (url.Values, error) {
v, err := config.BaseChat.values()
if err != nil {
return v, err
}
v.Add(config.name(), config.FileID)
return v, nil
} | [
"func",
"(",
"config",
"StickerConfig",
")",
"values",
"(",
")",
"(",
"url",
".",
"Values",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"config",
".",
"BaseChat",
".",
"values",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"v",
","... | // values returns a url.Values representation of StickerConfig. | [
"values",
"returns",
"a",
"url",
".",
"Values",
"representation",
"of",
"StickerConfig",
"."
] | 87e7035a900c7cb1fd896e5f33b461c96c3ac31e | https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/configs.go#L419-L428 |
31,401 | go-telegram-bot-api/telegram-bot-api | configs.go | values | func (config VideoConfig) values() (url.Values, error) {
v, err := config.BaseChat.values()
if err != nil {
return v, err
}
v.Add(config.name(), config.FileID)
if config.Duration != 0 {
v.Add("duration", strconv.Itoa(config.Duration))
}
if config.Caption != "" {
v.Add("caption", config.Caption)
if confi... | go | func (config VideoConfig) values() (url.Values, error) {
v, err := config.BaseChat.values()
if err != nil {
return v, err
}
v.Add(config.name(), config.FileID)
if config.Duration != 0 {
v.Add("duration", strconv.Itoa(config.Duration))
}
if config.Caption != "" {
v.Add("caption", config.Caption)
if confi... | [
"func",
"(",
"config",
"VideoConfig",
")",
"values",
"(",
")",
"(",
"url",
".",
"Values",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"config",
".",
"BaseChat",
".",
"values",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"v",
",",
... | // values returns a url.Values representation of VideoConfig. | [
"values",
"returns",
"a",
"url",
".",
"Values",
"representation",
"of",
"VideoConfig",
"."
] | 87e7035a900c7cb1fd896e5f33b461c96c3ac31e | https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/configs.go#L456-L474 |
31,402 | go-telegram-bot-api/telegram-bot-api | configs.go | values | func (config VideoNoteConfig) values() (url.Values, error) {
v, err := config.BaseChat.values()
if err != nil {
return v, err
}
v.Add(config.name(), config.FileID)
if config.Duration != 0 {
v.Add("duration", strconv.Itoa(config.Duration))
}
// Telegram API seems to have a bug, if no length is provided or i... | go | func (config VideoNoteConfig) values() (url.Values, error) {
v, err := config.BaseChat.values()
if err != nil {
return v, err
}
v.Add(config.name(), config.FileID)
if config.Duration != 0 {
v.Add("duration", strconv.Itoa(config.Duration))
}
// Telegram API seems to have a bug, if no length is provided or i... | [
"func",
"(",
"config",
"VideoNoteConfig",
")",
"values",
"(",
")",
"(",
"url",
".",
"Values",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"config",
".",
"BaseChat",
".",
"values",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"v",
"... | // values returns a url.Values representation of VideoNoteConfig. | [
"values",
"returns",
"a",
"url",
".",
"Values",
"representation",
"of",
"VideoNoteConfig",
"."
] | 87e7035a900c7cb1fd896e5f33b461c96c3ac31e | https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/configs.go#L561-L578 |
31,403 | go-telegram-bot-api/telegram-bot-api | configs.go | values | func (config LocationConfig) values() (url.Values, error) {
v, err := config.BaseChat.values()
if err != nil {
return v, err
}
v.Add("latitude", strconv.FormatFloat(config.Latitude, 'f', 6, 64))
v.Add("longitude", strconv.FormatFloat(config.Longitude, 'f', 6, 64))
return v, nil
} | go | func (config LocationConfig) values() (url.Values, error) {
v, err := config.BaseChat.values()
if err != nil {
return v, err
}
v.Add("latitude", strconv.FormatFloat(config.Latitude, 'f', 6, 64))
v.Add("longitude", strconv.FormatFloat(config.Longitude, 'f', 6, 64))
return v, nil
} | [
"func",
"(",
"config",
"LocationConfig",
")",
"values",
"(",
")",
"(",
"url",
".",
"Values",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"config",
".",
"BaseChat",
".",
"values",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"v",
",... | // values returns a url.Values representation of LocationConfig. | [
"values",
"returns",
"a",
"url",
".",
"Values",
"representation",
"of",
"LocationConfig",
"."
] | 87e7035a900c7cb1fd896e5f33b461c96c3ac31e | https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/configs.go#L694-L704 |
31,404 | go-telegram-bot-api/telegram-bot-api | configs.go | values | func (config ChatActionConfig) values() (url.Values, error) {
v, err := config.BaseChat.values()
if err != nil {
return v, err
}
v.Add("action", config.Action)
return v, nil
} | go | func (config ChatActionConfig) values() (url.Values, error) {
v, err := config.BaseChat.values()
if err != nil {
return v, err
}
v.Add("action", config.Action)
return v, nil
} | [
"func",
"(",
"config",
"ChatActionConfig",
")",
"values",
"(",
")",
"(",
"url",
".",
"Values",
",",
"error",
")",
"{",
"v",
",",
"err",
":=",
"config",
".",
"BaseChat",
".",
"values",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"v",
... | // values returns a url.Values representation of ChatActionConfig. | [
"values",
"returns",
"a",
"url",
".",
"Values",
"representation",
"of",
"ChatActionConfig",
"."
] | 87e7035a900c7cb1fd896e5f33b461c96c3ac31e | https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/configs.go#L862-L869 |
31,405 | go-telegram-bot-api/telegram-bot-api | log.go | SetLogger | func SetLogger(logger BotLogger) error {
if logger == nil {
return errors.New("logger is nil")
}
log = logger
return nil
} | go | func SetLogger(logger BotLogger) error {
if logger == nil {
return errors.New("logger is nil")
}
log = logger
return nil
} | [
"func",
"SetLogger",
"(",
"logger",
"BotLogger",
")",
"error",
"{",
"if",
"logger",
"==",
"nil",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"log",
"=",
"logger",
"\n",
"return",
"nil",
"\n",
"}"
] | // SetLogger specifies the logger that the package should use. | [
"SetLogger",
"specifies",
"the",
"logger",
"that",
"the",
"package",
"should",
"use",
"."
] | 87e7035a900c7cb1fd896e5f33b461c96c3ac31e | https://github.com/go-telegram-bot-api/telegram-bot-api/blob/87e7035a900c7cb1fd896e5f33b461c96c3ac31e/log.go#L21-L27 |
31,406 | nsf/termbox-go | termbox_windows.go | prepare_diff_messages | func prepare_diff_messages() {
// clear buffers
diffbuf = diffbuf[:0]
charbuf = charbuf[:0]
var diff diff_msg
gbeg := 0
for y := 0; y < front_buffer.height; y++ {
same := true
line_offset := y * front_buffer.width
for x := 0; x < front_buffer.width; x++ {
cell_offset := line_offset + x
back := &back_... | go | func prepare_diff_messages() {
// clear buffers
diffbuf = diffbuf[:0]
charbuf = charbuf[:0]
var diff diff_msg
gbeg := 0
for y := 0; y < front_buffer.height; y++ {
same := true
line_offset := y * front_buffer.width
for x := 0; x < front_buffer.width; x++ {
cell_offset := line_offset + x
back := &back_... | [
"func",
"prepare_diff_messages",
"(",
")",
"{",
"// clear buffers",
"diffbuf",
"=",
"diffbuf",
"[",
":",
"0",
"]",
"\n",
"charbuf",
"=",
"charbuf",
"[",
":",
"0",
"]",
"\n\n",
"var",
"diff",
"diff_msg",
"\n",
"gbeg",
":=",
"0",
"\n",
"for",
"y",
":=",
... | // compares 'back_buffer' with 'front_buffer' and prepares all changes in the form of
// 'diff_msg's in the 'diff_buf' | [
"compares",
"back_buffer",
"with",
"front_buffer",
"and",
"prepares",
"all",
"changes",
"in",
"the",
"form",
"of",
"diff_msg",
"s",
"in",
"the",
"diff_buf"
] | 288510b9734e30e7966ec2f22b87c5f8e67345e3 | https://github.com/nsf/termbox-go/blob/288510b9734e30e7966ec2f22b87c5f8e67345e3/termbox_windows.go#L577-L615 |
31,407 | nsf/termbox-go | api_windows.go | SetCell | func SetCell(x, y int, ch rune, fg, bg Attribute) {
if x < 0 || x >= back_buffer.width {
return
}
if y < 0 || y >= back_buffer.height {
return
}
back_buffer.cells[y*back_buffer.width+x] = Cell{ch, fg, bg}
} | go | func SetCell(x, y int, ch rune, fg, bg Attribute) {
if x < 0 || x >= back_buffer.width {
return
}
if y < 0 || y >= back_buffer.height {
return
}
back_buffer.cells[y*back_buffer.width+x] = Cell{ch, fg, bg}
} | [
"func",
"SetCell",
"(",
"x",
",",
"y",
"int",
",",
"ch",
"rune",
",",
"fg",
",",
"bg",
"Attribute",
")",
"{",
"if",
"x",
"<",
"0",
"||",
"x",
">=",
"back_buffer",
".",
"width",
"{",
"return",
"\n",
"}",
"\n",
"if",
"y",
"<",
"0",
"||",
"y",
... | // Changes cell's parameters in the internal back buffer at the specified
// position. | [
"Changes",
"cell",
"s",
"parameters",
"in",
"the",
"internal",
"back",
"buffer",
"at",
"the",
"specified",
"position",
"."
] | 288510b9734e30e7966ec2f22b87c5f8e67345e3 | https://github.com/nsf/termbox-go/blob/288510b9734e30e7966ec2f22b87c5f8e67345e3/api_windows.go#L154-L163 |
31,408 | nsf/termbox-go | _demos/editbox.go | Draw | func (eb *EditBox) Draw(x, y, w, h int) {
eb.AdjustVOffset(w)
const coldef = termbox.ColorDefault
fill(x, y, w, h, termbox.Cell{Ch: ' '})
t := eb.text
lx := 0
tabstop := 0
for {
rx := lx - eb.line_voffset
if len(t) == 0 {
break
}
if lx == tabstop {
tabstop += tabstop_length
}
if rx >= w {
... | go | func (eb *EditBox) Draw(x, y, w, h int) {
eb.AdjustVOffset(w)
const coldef = termbox.ColorDefault
fill(x, y, w, h, termbox.Cell{Ch: ' '})
t := eb.text
lx := 0
tabstop := 0
for {
rx := lx - eb.line_voffset
if len(t) == 0 {
break
}
if lx == tabstop {
tabstop += tabstop_length
}
if rx >= w {
... | [
"func",
"(",
"eb",
"*",
"EditBox",
")",
"Draw",
"(",
"x",
",",
"y",
",",
"w",
",",
"h",
"int",
")",
"{",
"eb",
".",
"AdjustVOffset",
"(",
"w",
")",
"\n\n",
"const",
"coldef",
"=",
"termbox",
".",
"ColorDefault",
"\n",
"fill",
"(",
"x",
",",
"y"... | // Draws the EditBox in the given location, 'h' is not used at the moment | [
"Draws",
"the",
"EditBox",
"in",
"the",
"given",
"location",
"h",
"is",
"not",
"used",
"at",
"the",
"moment"
] | 288510b9734e30e7966ec2f22b87c5f8e67345e3 | https://github.com/nsf/termbox-go/blob/288510b9734e30e7966ec2f22b87c5f8e67345e3/_demos/editbox.go#L79-L129 |
31,409 | nsf/termbox-go | _demos/editbox.go | AdjustVOffset | func (eb *EditBox) AdjustVOffset(width int) {
ht := preferred_horizontal_threshold
max_h_threshold := (width - 1) / 2
if ht > max_h_threshold {
ht = max_h_threshold
}
threshold := width - 1
if eb.line_voffset != 0 {
threshold = width - ht
}
if eb.cursor_voffset-eb.line_voffset >= threshold {
eb.line_voff... | go | func (eb *EditBox) AdjustVOffset(width int) {
ht := preferred_horizontal_threshold
max_h_threshold := (width - 1) / 2
if ht > max_h_threshold {
ht = max_h_threshold
}
threshold := width - 1
if eb.line_voffset != 0 {
threshold = width - ht
}
if eb.cursor_voffset-eb.line_voffset >= threshold {
eb.line_voff... | [
"func",
"(",
"eb",
"*",
"EditBox",
")",
"AdjustVOffset",
"(",
"width",
"int",
")",
"{",
"ht",
":=",
"preferred_horizontal_threshold",
"\n",
"max_h_threshold",
":=",
"(",
"width",
"-",
"1",
")",
"/",
"2",
"\n",
"if",
"ht",
">",
"max_h_threshold",
"{",
"ht... | // Adjusts line visual offset to a proper value depending on width | [
"Adjusts",
"line",
"visual",
"offset",
"to",
"a",
"proper",
"value",
"depending",
"on",
"width"
] | 288510b9734e30e7966ec2f22b87c5f8e67345e3 | https://github.com/nsf/termbox-go/blob/288510b9734e30e7966ec2f22b87c5f8e67345e3/_demos/editbox.go#L132-L153 |
31,410 | nsf/termbox-go | api.go | PollEvent | func PollEvent() Event {
// Constant governing macOS specific behavior. See https://github.com/nsf/termbox-go/issues/132
// This is an arbitrary delay which hopefully will be enough time for any lagging
// partial escape sequences to come through.
const esc_wait_delay = 100 * time.Millisecond
var event Event
var... | go | func PollEvent() Event {
// Constant governing macOS specific behavior. See https://github.com/nsf/termbox-go/issues/132
// This is an arbitrary delay which hopefully will be enough time for any lagging
// partial escape sequences to come through.
const esc_wait_delay = 100 * time.Millisecond
var event Event
var... | [
"func",
"PollEvent",
"(",
")",
"Event",
"{",
"// Constant governing macOS specific behavior. See https://github.com/nsf/termbox-go/issues/132",
"// This is an arbitrary delay which hopefully will be enough time for any lagging",
"// partial escape sequences to come through.",
"const",
"esc_wait_... | // Wait for an event and return it. This is a blocking function call. | [
"Wait",
"for",
"an",
"event",
"and",
"return",
"it",
".",
"This",
"is",
"a",
"blocking",
"function",
"call",
"."
] | 288510b9734e30e7966ec2f22b87c5f8e67345e3 | https://github.com/nsf/termbox-go/blob/288510b9734e30e7966ec2f22b87c5f8e67345e3/api.go#L314-L386 |
31,411 | nsf/termbox-go | api.go | Clear | func Clear(fg, bg Attribute) error {
foreground, background = fg, bg
err := update_size_maybe()
back_buffer.clear()
return err
} | go | func Clear(fg, bg Attribute) error {
foreground, background = fg, bg
err := update_size_maybe()
back_buffer.clear()
return err
} | [
"func",
"Clear",
"(",
"fg",
",",
"bg",
"Attribute",
")",
"error",
"{",
"foreground",
",",
"background",
"=",
"fg",
",",
"bg",
"\n",
"err",
":=",
"update_size_maybe",
"(",
")",
"\n",
"back_buffer",
".",
"clear",
"(",
")",
"\n",
"return",
"err",
"\n",
... | // Clears the internal back buffer. | [
"Clears",
"the",
"internal",
"back",
"buffer",
"."
] | 288510b9734e30e7966ec2f22b87c5f8e67345e3 | https://github.com/nsf/termbox-go/blob/288510b9734e30e7966ec2f22b87c5f8e67345e3/api.go#L397-L402 |
31,412 | nsf/termbox-go | api.go | Sync | func Sync() error {
front_buffer.clear()
err := send_clear()
if err != nil {
return err
}
return Flush()
} | go | func Sync() error {
front_buffer.clear()
err := send_clear()
if err != nil {
return err
}
return Flush()
} | [
"func",
"Sync",
"(",
")",
"error",
"{",
"front_buffer",
".",
"clear",
"(",
")",
"\n",
"err",
":=",
"send_clear",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"Flush",
"(",
")",
"\n",
"}"
] | // Sync comes handy when something causes desync between termbox's understanding
// of a terminal buffer and the reality. Such as a third party process. Sync
// forces a complete resync between the termbox and a terminal, it may not be
// visually pretty though. | [
"Sync",
"comes",
"handy",
"when",
"something",
"causes",
"desync",
"between",
"termbox",
"s",
"understanding",
"of",
"a",
"terminal",
"buffer",
"and",
"the",
"reality",
".",
"Such",
"as",
"a",
"third",
"party",
"process",
".",
"Sync",
"forces",
"a",
"complet... | 288510b9734e30e7966ec2f22b87c5f8e67345e3 | https://github.com/nsf/termbox-go/blob/288510b9734e30e7966ec2f22b87c5f8e67345e3/api.go#L489-L497 |
31,413 | tus/tusd | metrics.go | incRequestsTotal | func (m Metrics) incRequestsTotal(method string) {
if ptr, ok := m.RequestsTotal[method]; ok {
atomic.AddUint64(ptr, 1)
}
} | go | func (m Metrics) incRequestsTotal(method string) {
if ptr, ok := m.RequestsTotal[method]; ok {
atomic.AddUint64(ptr, 1)
}
} | [
"func",
"(",
"m",
"Metrics",
")",
"incRequestsTotal",
"(",
"method",
"string",
")",
"{",
"if",
"ptr",
",",
"ok",
":=",
"m",
".",
"RequestsTotal",
"[",
"method",
"]",
";",
"ok",
"{",
"atomic",
".",
"AddUint64",
"(",
"ptr",
",",
"1",
")",
"\n",
"}",
... | // incRequestsTotal increases the counter for this request method atomically by
// one. The method must be one of GET, HEAD, POST, PATCH, DELETE. | [
"incRequestsTotal",
"increases",
"the",
"counter",
"for",
"this",
"request",
"method",
"atomically",
"by",
"one",
".",
"The",
"method",
"must",
"be",
"one",
"of",
"GET",
"HEAD",
"POST",
"PATCH",
"DELETE",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/metrics.go#L27-L31 |
31,414 | tus/tusd | metrics.go | incErrorsTotal | func (m Metrics) incErrorsTotal(err HTTPError) {
ptr := m.ErrorsTotal.retrievePointerFor(err)
atomic.AddUint64(ptr, 1)
} | go | func (m Metrics) incErrorsTotal(err HTTPError) {
ptr := m.ErrorsTotal.retrievePointerFor(err)
atomic.AddUint64(ptr, 1)
} | [
"func",
"(",
"m",
"Metrics",
")",
"incErrorsTotal",
"(",
"err",
"HTTPError",
")",
"{",
"ptr",
":=",
"m",
".",
"ErrorsTotal",
".",
"retrievePointerFor",
"(",
"err",
")",
"\n",
"atomic",
".",
"AddUint64",
"(",
"ptr",
",",
"1",
")",
"\n",
"}"
] | // incErrorsTotal increases the counter for this error atomically by one. | [
"incErrorsTotal",
"increases",
"the",
"counter",
"for",
"this",
"error",
"atomically",
"by",
"one",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/metrics.go#L34-L37 |
31,415 | tus/tusd | metrics.go | incBytesReceived | func (m Metrics) incBytesReceived(delta uint64) {
atomic.AddUint64(m.BytesReceived, delta)
} | go | func (m Metrics) incBytesReceived(delta uint64) {
atomic.AddUint64(m.BytesReceived, delta)
} | [
"func",
"(",
"m",
"Metrics",
")",
"incBytesReceived",
"(",
"delta",
"uint64",
")",
"{",
"atomic",
".",
"AddUint64",
"(",
"m",
".",
"BytesReceived",
",",
"delta",
")",
"\n",
"}"
] | // incBytesReceived increases the number of received bytes atomically be the
// specified number. | [
"incBytesReceived",
"increases",
"the",
"number",
"of",
"received",
"bytes",
"atomically",
"be",
"the",
"specified",
"number",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/metrics.go#L41-L43 |
31,416 | tus/tusd | metrics.go | Load | func (e *ErrorsTotalMap) Load() map[HTTPError]*uint64 {
m := make(map[HTTPError]*uint64, len(e.counter))
e.lock.RLock()
for err, ptr := range e.counter {
httpErr := NewHTTPError(errors.New(err.Message), err.StatusCode)
m[httpErr] = ptr
}
e.lock.RUnlock()
return m
} | go | func (e *ErrorsTotalMap) Load() map[HTTPError]*uint64 {
m := make(map[HTTPError]*uint64, len(e.counter))
e.lock.RLock()
for err, ptr := range e.counter {
httpErr := NewHTTPError(errors.New(err.Message), err.StatusCode)
m[httpErr] = ptr
}
e.lock.RUnlock()
return m
} | [
"func",
"(",
"e",
"*",
"ErrorsTotalMap",
")",
"Load",
"(",
")",
"map",
"[",
"HTTPError",
"]",
"*",
"uint64",
"{",
"m",
":=",
"make",
"(",
"map",
"[",
"HTTPError",
"]",
"*",
"uint64",
",",
"len",
"(",
"e",
".",
"counter",
")",
")",
"\n",
"e",
".... | // Load retrieves the map of the counter pointers atomically | [
"Load",
"retrieves",
"the",
"map",
"of",
"the",
"counter",
"pointers",
"atomically"
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/metrics.go#L127-L137 |
31,417 | tus/tusd | etcd3locker/locker_options.go | Prefix | func (l *LockerOptions) Prefix() string {
prefix := l.prefix
if !strings.HasPrefix(prefix, "/") {
prefix = "/" + prefix
}
if prefix == "" {
return DefaultPrefix
} else {
return prefix
}
} | go | func (l *LockerOptions) Prefix() string {
prefix := l.prefix
if !strings.HasPrefix(prefix, "/") {
prefix = "/" + prefix
}
if prefix == "" {
return DefaultPrefix
} else {
return prefix
}
} | [
"func",
"(",
"l",
"*",
"LockerOptions",
")",
"Prefix",
"(",
")",
"string",
"{",
"prefix",
":=",
"l",
".",
"prefix",
"\n",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"prefix",
",",
"\"",
"\"",
")",
"{",
"prefix",
"=",
"\"",
"\"",
"+",
"prefix",
... | // Returns the string prefix used to store keys in etcd3 | [
"Returns",
"the",
"string",
"prefix",
"used",
"to",
"store",
"keys",
"in",
"etcd3"
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/etcd3locker/locker_options.go#L45-L56 |
31,418 | tus/tusd | limitedstore/limitedstore.go | New | func New(storeSize int64, dataStore tusd.DataStore, terminater tusd.TerminaterDataStore) *LimitedStore {
return &LimitedStore{
StoreSize: storeSize,
DataStore: dataStore,
terminater: terminater,
uploads: make(map[string]int64),
mutex: new(sync.Mutex),
}
} | go | func New(storeSize int64, dataStore tusd.DataStore, terminater tusd.TerminaterDataStore) *LimitedStore {
return &LimitedStore{
StoreSize: storeSize,
DataStore: dataStore,
terminater: terminater,
uploads: make(map[string]int64),
mutex: new(sync.Mutex),
}
} | [
"func",
"New",
"(",
"storeSize",
"int64",
",",
"dataStore",
"tusd",
".",
"DataStore",
",",
"terminater",
"tusd",
".",
"TerminaterDataStore",
")",
"*",
"LimitedStore",
"{",
"return",
"&",
"LimitedStore",
"{",
"StoreSize",
":",
"storeSize",
",",
"DataStore",
":"... | // New creates a new limited store with the given size as the maximum storage
// size. The wrapped data store needs to implement the TerminaterDataStore
// interface, in order to provide the required Terminate method. | [
"New",
"creates",
"a",
"new",
"limited",
"store",
"with",
"the",
"given",
"size",
"as",
"the",
"maximum",
"storage",
"size",
".",
"The",
"wrapped",
"data",
"store",
"needs",
"to",
"implement",
"the",
"TerminaterDataStore",
"interface",
"in",
"order",
"to",
"... | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/limitedstore/limitedstore.go#L52-L60 |
31,419 | tus/tusd | limitedstore/limitedstore.go | ensureSpace | func (store *LimitedStore) ensureSpace(size int64) error {
if (store.usedSize + size) <= store.StoreSize {
// Enough space is available to store the new upload
return nil
}
sortedUploads := make(pairlist, len(store.uploads))
i := 0
for u, h := range store.uploads {
sortedUploads[i] = pair{u, h}
i++
}
so... | go | func (store *LimitedStore) ensureSpace(size int64) error {
if (store.usedSize + size) <= store.StoreSize {
// Enough space is available to store the new upload
return nil
}
sortedUploads := make(pairlist, len(store.uploads))
i := 0
for u, h := range store.uploads {
sortedUploads[i] = pair{u, h}
i++
}
so... | [
"func",
"(",
"store",
"*",
"LimitedStore",
")",
"ensureSpace",
"(",
"size",
"int64",
")",
"error",
"{",
"if",
"(",
"store",
".",
"usedSize",
"+",
"size",
")",
"<=",
"store",
".",
"StoreSize",
"{",
"// Enough space is available to store the new upload",
"return",... | // Ensure enough space is available to store an upload of the specified size.
// It will terminate uploads until enough space is freed. | [
"Ensure",
"enough",
"space",
"is",
"available",
"to",
"store",
"an",
"upload",
"of",
"the",
"specified",
"size",
".",
"It",
"will",
"terminate",
"uploads",
"until",
"enough",
"space",
"is",
"freed",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/limitedstore/limitedstore.go#L111-L140 |
31,420 | tus/tusd | filestore/filestore.go | newLock | func (store FileStore) newLock(id string) (lockfile.Lockfile, error) {
path, err := filepath.Abs(filepath.Join(store.Path, id+".lock"))
if err != nil {
return lockfile.Lockfile(""), err
}
// We use Lockfile directly instead of lockfile.New to bypass the unnecessary
// check whether the provided path is absolute... | go | func (store FileStore) newLock(id string) (lockfile.Lockfile, error) {
path, err := filepath.Abs(filepath.Join(store.Path, id+".lock"))
if err != nil {
return lockfile.Lockfile(""), err
}
// We use Lockfile directly instead of lockfile.New to bypass the unnecessary
// check whether the provided path is absolute... | [
"func",
"(",
"store",
"FileStore",
")",
"newLock",
"(",
"id",
"string",
")",
"(",
"lockfile",
".",
"Lockfile",
",",
"error",
")",
"{",
"path",
",",
"err",
":=",
"filepath",
".",
"Abs",
"(",
"filepath",
".",
"Join",
"(",
"store",
".",
"Path",
",",
"... | // newLock contructs a new Lockfile instance. | [
"newLock",
"contructs",
"a",
"new",
"Lockfile",
"instance",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/filestore/filestore.go#L189-L199 |
31,421 | tus/tusd | filestore/filestore.go | binPath | func (store FileStore) binPath(id string) string {
return filepath.Join(store.Path, id+".bin")
} | go | func (store FileStore) binPath(id string) string {
return filepath.Join(store.Path, id+".bin")
} | [
"func",
"(",
"store",
"FileStore",
")",
"binPath",
"(",
"id",
"string",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"store",
".",
"Path",
",",
"id",
"+",
"\"",
"\"",
")",
"\n",
"}"
] | // binPath returns the path to the .bin storing the binary data. | [
"binPath",
"returns",
"the",
"path",
"to",
"the",
".",
"bin",
"storing",
"the",
"binary",
"data",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/filestore/filestore.go#L202-L204 |
31,422 | tus/tusd | filestore/filestore.go | infoPath | func (store FileStore) infoPath(id string) string {
return filepath.Join(store.Path, id+".info")
} | go | func (store FileStore) infoPath(id string) string {
return filepath.Join(store.Path, id+".info")
} | [
"func",
"(",
"store",
"FileStore",
")",
"infoPath",
"(",
"id",
"string",
")",
"string",
"{",
"return",
"filepath",
".",
"Join",
"(",
"store",
".",
"Path",
",",
"id",
"+",
"\"",
"\"",
")",
"\n",
"}"
] | // infoPath returns the path to the .info file storing the file's info. | [
"infoPath",
"returns",
"the",
"path",
"to",
"the",
".",
"info",
"file",
"storing",
"the",
"file",
"s",
"info",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/filestore/filestore.go#L207-L209 |
31,423 | tus/tusd | filestore/filestore.go | writeInfo | func (store FileStore) writeInfo(id string, info tusd.FileInfo) error {
data, err := json.Marshal(info)
if err != nil {
return err
}
return ioutil.WriteFile(store.infoPath(id), data, defaultFilePerm)
} | go | func (store FileStore) writeInfo(id string, info tusd.FileInfo) error {
data, err := json.Marshal(info)
if err != nil {
return err
}
return ioutil.WriteFile(store.infoPath(id), data, defaultFilePerm)
} | [
"func",
"(",
"store",
"FileStore",
")",
"writeInfo",
"(",
"id",
"string",
",",
"info",
"tusd",
".",
"FileInfo",
")",
"error",
"{",
"data",
",",
"err",
":=",
"json",
".",
"Marshal",
"(",
"info",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"e... | // writeInfo updates the entire information. Everything will be overwritten. | [
"writeInfo",
"updates",
"the",
"entire",
"information",
".",
"Everything",
"will",
"be",
"overwritten",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/filestore/filestore.go#L212-L218 |
31,424 | tus/tusd | consullocker/consullocker.go | New | func New(client *consul.Client) *ConsulLocker {
return &ConsulLocker{
Client: client,
locks: make(map[string]*consul.Lock),
mutex: new(sync.RWMutex),
}
} | go | func New(client *consul.Client) *ConsulLocker {
return &ConsulLocker{
Client: client,
locks: make(map[string]*consul.Lock),
mutex: new(sync.RWMutex),
}
} | [
"func",
"New",
"(",
"client",
"*",
"consul",
".",
"Client",
")",
"*",
"ConsulLocker",
"{",
"return",
"&",
"ConsulLocker",
"{",
"Client",
":",
"client",
",",
"locks",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"*",
"consul",
".",
"Lock",
")",
",",
... | // New constructs a new locker using the provided client. | [
"New",
"constructs",
"a",
"new",
"locker",
"using",
"the",
"provided",
"client",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/consullocker/consullocker.go#L40-L46 |
31,425 | tus/tusd | unrouted_handler.go | Middleware | func (handler *UnroutedHandler) Middleware(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Allow overriding the HTTP method. The reason for this is
// that some libraries/environments to not support PATCH and
// DELETE requests, e.g. Flash in a browser and... | go | func (handler *UnroutedHandler) Middleware(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Allow overriding the HTTP method. The reason for this is
// that some libraries/environments to not support PATCH and
// DELETE requests, e.g. Flash in a browser and... | [
"func",
"(",
"handler",
"*",
"UnroutedHandler",
")",
"Middleware",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".... | // Middleware checks various aspects of the request and ensures that it
// conforms with the spec. Also handles method overriding for clients which
// cannot make PATCH AND DELETE requests. If you are using the tusd handlers
// directly you will need to wrap at least the POST and PATCH endpoints in
// this middleware. | [
"Middleware",
"checks",
"various",
"aspects",
"of",
"the",
"request",
"and",
"ensures",
"that",
"it",
"conforms",
"with",
"the",
"spec",
".",
"Also",
"handles",
"method",
"overriding",
"for",
"clients",
"which",
"cannot",
"make",
"PATCH",
"AND",
"DELETE",
"req... | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/unrouted_handler.go#L161-L229 |
31,426 | tus/tusd | unrouted_handler.go | HeadFile | func (handler *UnroutedHandler) HeadFile(w http.ResponseWriter, r *http.Request) {
id, err := extractIDFromPath(r.URL.Path)
if err != nil {
handler.sendError(w, r, err)
return
}
if handler.composer.UsesLocker {
locker := handler.composer.Locker
if err := locker.LockUpload(id); err != nil {
handler.send... | go | func (handler *UnroutedHandler) HeadFile(w http.ResponseWriter, r *http.Request) {
id, err := extractIDFromPath(r.URL.Path)
if err != nil {
handler.sendError(w, r, err)
return
}
if handler.composer.UsesLocker {
locker := handler.composer.Locker
if err := locker.LockUpload(id); err != nil {
handler.send... | [
"func",
"(",
"handler",
"*",
"UnroutedHandler",
")",
"HeadFile",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"id",
",",
"err",
":=",
"extractIDFromPath",
"(",
"r",
".",
"URL",
".",
"Path",
")",
"\n",
"if"... | // HeadFile returns the length and offset for the HEAD request | [
"HeadFile",
"returns",
"the",
"length",
"and",
"offset",
"for",
"the",
"HEAD",
"request"
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/unrouted_handler.go#L356-L409 |
31,427 | tus/tusd | unrouted_handler.go | writeChunk | func (handler *UnroutedHandler) writeChunk(id string, info FileInfo, w http.ResponseWriter, r *http.Request) error {
// Get Content-Length if possible
length := r.ContentLength
offset := info.Offset
// Test if this upload fits into the file's size
if !info.SizeIsDeferred && offset+length > info.Size {
return Er... | go | func (handler *UnroutedHandler) writeChunk(id string, info FileInfo, w http.ResponseWriter, r *http.Request) error {
// Get Content-Length if possible
length := r.ContentLength
offset := info.Offset
// Test if this upload fits into the file's size
if !info.SizeIsDeferred && offset+length > info.Size {
return Er... | [
"func",
"(",
"handler",
"*",
"UnroutedHandler",
")",
"writeChunk",
"(",
"id",
"string",
",",
"info",
"FileInfo",
",",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"error",
"{",
"// Get Content-Length if possible",
"length",
... | // writeChunk reads the body from the requests r and appends it to the upload
// with the corresponding id. Afterwards, it will set the necessary response
// headers but will not send the response. | [
"writeChunk",
"reads",
"the",
"body",
"from",
"the",
"requests",
"r",
"and",
"appends",
"it",
"to",
"the",
"upload",
"with",
"the",
"corresponding",
"id",
".",
"Afterwards",
"it",
"will",
"set",
"the",
"necessary",
"response",
"headers",
"but",
"will",
"not"... | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/unrouted_handler.go#L502-L560 |
31,428 | tus/tusd | unrouted_handler.go | GetFile | func (handler *UnroutedHandler) GetFile(w http.ResponseWriter, r *http.Request) {
if !handler.composer.UsesGetReader {
handler.sendError(w, r, ErrNotImplemented)
return
}
id, err := extractIDFromPath(r.URL.Path)
if err != nil {
handler.sendError(w, r, err)
return
}
if handler.composer.UsesLocker {
loc... | go | func (handler *UnroutedHandler) GetFile(w http.ResponseWriter, r *http.Request) {
if !handler.composer.UsesGetReader {
handler.sendError(w, r, ErrNotImplemented)
return
}
id, err := extractIDFromPath(r.URL.Path)
if err != nil {
handler.sendError(w, r, err)
return
}
if handler.composer.UsesLocker {
loc... | [
"func",
"(",
"handler",
"*",
"UnroutedHandler",
")",
"GetFile",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"if",
"!",
"handler",
".",
"composer",
".",
"UsesGetReader",
"{",
"handler",
".",
"sendError",
"(",
... | // GetFile handles requests to download a file using a GET request. This is not
// part of the specification. | [
"GetFile",
"handles",
"requests",
"to",
"download",
"a",
"file",
"using",
"a",
"GET",
"request",
".",
"This",
"is",
"not",
"part",
"of",
"the",
"specification",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/unrouted_handler.go#L588-L642 |
31,429 | tus/tusd | unrouted_handler.go | DelFile | func (handler *UnroutedHandler) DelFile(w http.ResponseWriter, r *http.Request) {
// Abort the request handling if the required interface is not implemented
if !handler.composer.UsesTerminater {
handler.sendError(w, r, ErrNotImplemented)
return
}
id, err := extractIDFromPath(r.URL.Path)
if err != nil {
hand... | go | func (handler *UnroutedHandler) DelFile(w http.ResponseWriter, r *http.Request) {
// Abort the request handling if the required interface is not implemented
if !handler.composer.UsesTerminater {
handler.sendError(w, r, ErrNotImplemented)
return
}
id, err := extractIDFromPath(r.URL.Path)
if err != nil {
hand... | [
"func",
"(",
"handler",
"*",
"UnroutedHandler",
")",
"DelFile",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
")",
"{",
"// Abort the request handling if the required interface is not implemented",
"if",
"!",
"handler",
".",
"compos... | // DelFile terminates an upload permanently. | [
"DelFile",
"terminates",
"an",
"upload",
"permanently",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/unrouted_handler.go#L706-L751 |
31,430 | tus/tusd | unrouted_handler.go | sendError | func (handler *UnroutedHandler) sendError(w http.ResponseWriter, r *http.Request, err error) {
// Interpret os.ErrNotExist as 404 Not Found
if os.IsNotExist(err) {
err = ErrNotFound
}
// Errors for read timeouts contain too much information which is not
// necessary for us and makes grouping for the metrics har... | go | func (handler *UnroutedHandler) sendError(w http.ResponseWriter, r *http.Request, err error) {
// Interpret os.ErrNotExist as 404 Not Found
if os.IsNotExist(err) {
err = ErrNotFound
}
// Errors for read timeouts contain too much information which is not
// necessary for us and makes grouping for the metrics har... | [
"func",
"(",
"handler",
"*",
"UnroutedHandler",
")",
"sendError",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"err",
"error",
")",
"{",
"// Interpret os.ErrNotExist as 404 Not Found",
"if",
"os",
".",
"IsNotExist",
"(",... | // Send the error in the response body. The status code will be looked up in
// ErrStatusCodes. If none is found 500 Internal Error will be used. | [
"Send",
"the",
"error",
"in",
"the",
"response",
"body",
".",
"The",
"status",
"code",
"will",
"be",
"looked",
"up",
"in",
"ErrStatusCodes",
".",
"If",
"none",
"is",
"found",
"500",
"Internal",
"Error",
"will",
"be",
"used",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/unrouted_handler.go#L755-L787 |
31,431 | tus/tusd | unrouted_handler.go | sendResp | func (handler *UnroutedHandler) sendResp(w http.ResponseWriter, r *http.Request, status int) {
w.WriteHeader(status)
handler.log("ResponseOutgoing", "status", strconv.Itoa(status), "method", r.Method, "path", r.URL.Path)
} | go | func (handler *UnroutedHandler) sendResp(w http.ResponseWriter, r *http.Request, status int) {
w.WriteHeader(status)
handler.log("ResponseOutgoing", "status", strconv.Itoa(status), "method", r.Method, "path", r.URL.Path)
} | [
"func",
"(",
"handler",
"*",
"UnroutedHandler",
")",
"sendResp",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",
".",
"Request",
",",
"status",
"int",
")",
"{",
"w",
".",
"WriteHeader",
"(",
"status",
")",
"\n\n",
"handler",
".",
"log",... | // sendResp writes the header to w with the specified status code. | [
"sendResp",
"writes",
"the",
"header",
"to",
"w",
"with",
"the",
"specified",
"status",
"code",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/unrouted_handler.go#L790-L794 |
31,432 | tus/tusd | unrouted_handler.go | absFileURL | func (handler *UnroutedHandler) absFileURL(r *http.Request, id string) string {
if handler.isBasePathAbs {
return handler.basePath + id
}
// Read origin and protocol from request
host, proto := getHostAndProtocol(r, handler.config.RespectForwardedHeaders)
url := proto + "://" + host + handler.basePath + id
r... | go | func (handler *UnroutedHandler) absFileURL(r *http.Request, id string) string {
if handler.isBasePathAbs {
return handler.basePath + id
}
// Read origin and protocol from request
host, proto := getHostAndProtocol(r, handler.config.RespectForwardedHeaders)
url := proto + "://" + host + handler.basePath + id
r... | [
"func",
"(",
"handler",
"*",
"UnroutedHandler",
")",
"absFileURL",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"id",
"string",
")",
"string",
"{",
"if",
"handler",
".",
"isBasePathAbs",
"{",
"return",
"handler",
".",
"basePath",
"+",
"id",
"\n",
"}",
"... | // Make an absolute URLs to the given upload id. If the base path is absolute
// it will be prepended else the host and protocol from the request is used. | [
"Make",
"an",
"absolute",
"URLs",
"to",
"the",
"given",
"upload",
"id",
".",
"If",
"the",
"base",
"path",
"is",
"absolute",
"it",
"will",
"be",
"prepended",
"else",
"the",
"host",
"and",
"protocol",
"from",
"the",
"request",
"is",
"used",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/unrouted_handler.go#L798-L809 |
31,433 | tus/tusd | unrouted_handler.go | sendProgressMessages | func (handler *UnroutedHandler) sendProgressMessages(info FileInfo, reader io.Reader) (io.Reader, chan<- struct{}) {
progress := &progressWriter{
Offset: info.Offset,
}
stop := make(chan struct{}, 1)
reader = io.TeeReader(reader, progress)
go func() {
for {
select {
case <-stop:
info.Offset = atomic... | go | func (handler *UnroutedHandler) sendProgressMessages(info FileInfo, reader io.Reader) (io.Reader, chan<- struct{}) {
progress := &progressWriter{
Offset: info.Offset,
}
stop := make(chan struct{}, 1)
reader = io.TeeReader(reader, progress)
go func() {
for {
select {
case <-stop:
info.Offset = atomic... | [
"func",
"(",
"handler",
"*",
"UnroutedHandler",
")",
"sendProgressMessages",
"(",
"info",
"FileInfo",
",",
"reader",
"io",
".",
"Reader",
")",
"(",
"io",
".",
"Reader",
",",
"chan",
"<-",
"struct",
"{",
"}",
")",
"{",
"progress",
":=",
"&",
"progressWrit... | // sendProgressMessage will send a notification over the UploadProgress channel
// every second, indicating how much data has been transfered to the server.
// It will stop sending these instances once the returned channel has been
// closed. The returned reader should be used to read the request body. | [
"sendProgressMessage",
"will",
"send",
"a",
"notification",
"over",
"the",
"UploadProgress",
"channel",
"every",
"second",
"indicating",
"how",
"much",
"data",
"has",
"been",
"transfered",
"to",
"the",
"server",
".",
"It",
"will",
"stop",
"sending",
"these",
"in... | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/unrouted_handler.go#L824-L846 |
31,434 | tus/tusd | unrouted_handler.go | sizeOfUploads | func (handler *UnroutedHandler) sizeOfUploads(ids []string) (size int64, err error) {
for _, id := range ids {
info, err := handler.composer.Core.GetInfo(id)
if err != nil {
return size, err
}
if info.SizeIsDeferred || info.Offset != info.Size {
err = ErrUploadNotFinished
return size, err
}
size... | go | func (handler *UnroutedHandler) sizeOfUploads(ids []string) (size int64, err error) {
for _, id := range ids {
info, err := handler.composer.Core.GetInfo(id)
if err != nil {
return size, err
}
if info.SizeIsDeferred || info.Offset != info.Size {
err = ErrUploadNotFinished
return size, err
}
size... | [
"func",
"(",
"handler",
"*",
"UnroutedHandler",
")",
"sizeOfUploads",
"(",
"ids",
"[",
"]",
"string",
")",
"(",
"size",
"int64",
",",
"err",
"error",
")",
"{",
"for",
"_",
",",
"id",
":=",
"range",
"ids",
"{",
"info",
",",
"err",
":=",
"handler",
"... | // The get sum of all sizes for a list of upload ids while checking whether
// all of these uploads are finished yet. This is used to calculate the size
// of a final resource. | [
"The",
"get",
"sum",
"of",
"all",
"sizes",
"for",
"a",
"list",
"of",
"upload",
"ids",
"while",
"checking",
"whether",
"all",
"of",
"these",
"uploads",
"are",
"finished",
"yet",
".",
"This",
"is",
"used",
"to",
"calculate",
"the",
"size",
"of",
"a",
"fi... | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/unrouted_handler.go#L889-L905 |
31,435 | tus/tusd | unrouted_handler.go | validateNewUploadLengthHeaders | func (handler *UnroutedHandler) validateNewUploadLengthHeaders(uploadLengthHeader string, uploadDeferLengthHeader string) (uploadLength int64, uploadLengthDeferred bool, err error) {
haveBothLengthHeaders := uploadLengthHeader != "" && uploadDeferLengthHeader != ""
haveInvalidDeferHeader := uploadDeferLengthHeader !=... | go | func (handler *UnroutedHandler) validateNewUploadLengthHeaders(uploadLengthHeader string, uploadDeferLengthHeader string) (uploadLength int64, uploadLengthDeferred bool, err error) {
haveBothLengthHeaders := uploadLengthHeader != "" && uploadDeferLengthHeader != ""
haveInvalidDeferHeader := uploadDeferLengthHeader !=... | [
"func",
"(",
"handler",
"*",
"UnroutedHandler",
")",
"validateNewUploadLengthHeaders",
"(",
"uploadLengthHeader",
"string",
",",
"uploadDeferLengthHeader",
"string",
")",
"(",
"uploadLength",
"int64",
",",
"uploadLengthDeferred",
"bool",
",",
"err",
"error",
")",
"{",... | // Verify that the Upload-Length and Upload-Defer-Length headers are acceptable for creating a
// new upload | [
"Verify",
"that",
"the",
"Upload",
"-",
"Length",
"and",
"Upload",
"-",
"Defer",
"-",
"Length",
"headers",
"are",
"acceptable",
"for",
"creating",
"a",
"new",
"upload"
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/unrouted_handler.go#L909-L930 |
31,436 | tus/tusd | unrouted_handler.go | extractIDFromPath | func extractIDFromPath(url string) (string, error) {
result := reExtractFileID.FindStringSubmatch(url)
if len(result) != 2 {
return "", ErrNotFound
}
return result[1], nil
} | go | func extractIDFromPath(url string) (string, error) {
result := reExtractFileID.FindStringSubmatch(url)
if len(result) != 2 {
return "", ErrNotFound
}
return result[1], nil
} | [
"func",
"extractIDFromPath",
"(",
"url",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"result",
":=",
"reExtractFileID",
".",
"FindStringSubmatch",
"(",
"url",
")",
"\n",
"if",
"len",
"(",
"result",
")",
"!=",
"2",
"{",
"return",
"\"",
"\"",
"... | // extractIDFromPath pulls the last segment from the url provided | [
"extractIDFromPath",
"pulls",
"the",
"last",
"segment",
"from",
"the",
"url",
"provided"
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/unrouted_handler.go#L1023-L1029 |
31,437 | tus/tusd | gcsstore/gcsservice.go | NewGCSService | func NewGCSService(filename string) (*GCSService, error) {
ctx := context.Background()
client, err := storage.NewClient(ctx, option.WithServiceAccountFile(filename))
if err != nil {
return nil, err
}
service := &GCSService{
Client: client,
}
return service, nil
} | go | func NewGCSService(filename string) (*GCSService, error) {
ctx := context.Background()
client, err := storage.NewClient(ctx, option.WithServiceAccountFile(filename))
if err != nil {
return nil, err
}
service := &GCSService{
Client: client,
}
return service, nil
} | [
"func",
"NewGCSService",
"(",
"filename",
"string",
")",
"(",
"*",
"GCSService",
",",
"error",
")",
"{",
"ctx",
":=",
"context",
".",
"Background",
"(",
")",
"\n",
"client",
",",
"err",
":=",
"storage",
".",
"NewClient",
"(",
"ctx",
",",
"option",
".",... | // NewGCSService returns a GCSSerivce object given a GCloud service account file path. | [
"NewGCSService",
"returns",
"a",
"GCSSerivce",
"object",
"given",
"a",
"GCloud",
"service",
"account",
"file",
"path",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/gcsstore/gcsservice.go#L82-L94 |
31,438 | tus/tusd | gcsstore/gcsservice.go | GetObjectSize | func (service *GCSService) GetObjectSize(ctx context.Context, params GCSObjectParams) (int64, error) {
attrs, err := service.GetObjectAttrs(ctx, params)
if err != nil {
return 0, err
}
return attrs.Size, nil
} | go | func (service *GCSService) GetObjectSize(ctx context.Context, params GCSObjectParams) (int64, error) {
attrs, err := service.GetObjectAttrs(ctx, params)
if err != nil {
return 0, err
}
return attrs.Size, nil
} | [
"func",
"(",
"service",
"*",
"GCSService",
")",
"GetObjectSize",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"GCSObjectParams",
")",
"(",
"int64",
",",
"error",
")",
"{",
"attrs",
",",
"err",
":=",
"service",
".",
"GetObjectAttrs",
"(",
"ctx",
... | // GetObjectSize returns the byte length of the specified GCS object. | [
"GetObjectSize",
"returns",
"the",
"byte",
"length",
"of",
"the",
"specified",
"GCS",
"object",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/gcsstore/gcsservice.go#L97-L104 |
31,439 | tus/tusd | gcsstore/gcsservice.go | DeleteObjectsWithFilter | func (service *GCSService) DeleteObjectsWithFilter(ctx context.Context, params GCSFilterParams) error {
names, err := service.FilterObjects(ctx, params)
if err != nil {
return err
}
var objectParams GCSObjectParams
for _, name := range names {
objectParams = GCSObjectParams{
Bucket: params.Bucket,
ID: ... | go | func (service *GCSService) DeleteObjectsWithFilter(ctx context.Context, params GCSFilterParams) error {
names, err := service.FilterObjects(ctx, params)
if err != nil {
return err
}
var objectParams GCSObjectParams
for _, name := range names {
objectParams = GCSObjectParams{
Bucket: params.Bucket,
ID: ... | [
"func",
"(",
"service",
"*",
"GCSService",
")",
"DeleteObjectsWithFilter",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"GCSFilterParams",
")",
"error",
"{",
"names",
",",
"err",
":=",
"service",
".",
"FilterObjects",
"(",
"ctx",
",",
"params",
")",... | // DeleteObjectWithPrefix will delete objects who match the provided filter parameters. | [
"DeleteObjectWithPrefix",
"will",
"delete",
"objects",
"who",
"match",
"the",
"provided",
"filter",
"parameters",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/gcsstore/gcsservice.go#L107-L127 |
31,440 | tus/tusd | gcsstore/gcsservice.go | compose | func (service *GCSService) compose(ctx context.Context, bucket string, srcs []string, dst string) error {
dstParams := GCSObjectParams{
Bucket: bucket,
ID: dst,
}
objSrcs := make([]*storage.ObjectHandle, len(srcs))
var crc uint32
for i := 0; i < len(srcs); i++ {
objSrcs[i] = service.Client.Bucket(bucket)... | go | func (service *GCSService) compose(ctx context.Context, bucket string, srcs []string, dst string) error {
dstParams := GCSObjectParams{
Bucket: bucket,
ID: dst,
}
objSrcs := make([]*storage.ObjectHandle, len(srcs))
var crc uint32
for i := 0; i < len(srcs); i++ {
objSrcs[i] = service.Client.Bucket(bucket)... | [
"func",
"(",
"service",
"*",
"GCSService",
")",
"compose",
"(",
"ctx",
"context",
".",
"Context",
",",
"bucket",
"string",
",",
"srcs",
"[",
"]",
"string",
",",
"dst",
"string",
")",
"error",
"{",
"dstParams",
":=",
"GCSObjectParams",
"{",
"Bucket",
":",... | // Compose takes a bucket name, a list of initial source names, and a destination string to compose multiple GCS objects together | [
"Compose",
"takes",
"a",
"bucket",
"name",
"a",
"list",
"of",
"initial",
"source",
"names",
"and",
"a",
"destination",
"string",
"to",
"compose",
"multiple",
"GCS",
"objects",
"together"
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/gcsstore/gcsservice.go#L132-L186 |
31,441 | tus/tusd | gcsstore/gcsservice.go | ComposeObjects | func (service *GCSService) ComposeObjects(ctx context.Context, params GCSComposeParams) error {
err := service.recursiveCompose(ctx, params.Sources, params, 0)
if err != nil {
return err
}
return nil
} | go | func (service *GCSService) ComposeObjects(ctx context.Context, params GCSComposeParams) error {
err := service.recursiveCompose(ctx, params.Sources, params, 0)
if err != nil {
return err
}
return nil
} | [
"func",
"(",
"service",
"*",
"GCSService",
")",
"ComposeObjects",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"GCSComposeParams",
")",
"error",
"{",
"err",
":=",
"service",
".",
"recursiveCompose",
"(",
"ctx",
",",
"params",
".",
"Sources",
",",
... | // ComposeObjects composes multiple GCS objects in to a single object.
// Since GCS limits composition to a max of 32 objects, additional logic
// has been added to chunk objects in to groups of 32 and then recursively
// compose those objects together. | [
"ComposeObjects",
"composes",
"multiple",
"GCS",
"objects",
"in",
"to",
"a",
"single",
"object",
".",
"Since",
"GCS",
"limits",
"composition",
"to",
"a",
"max",
"of",
"32",
"objects",
"additional",
"logic",
"has",
"been",
"added",
"to",
"chunk",
"objects",
"... | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/gcsstore/gcsservice.go#L240-L248 |
31,442 | tus/tusd | gcsstore/gcsservice.go | ReadObject | func (service *GCSService) ReadObject(ctx context.Context, params GCSObjectParams) (GCSReader, error) {
r, err := service.Client.Bucket(params.Bucket).Object(params.ID).NewReader(ctx)
if err != nil {
return nil, err
}
return r, nil
} | go | func (service *GCSService) ReadObject(ctx context.Context, params GCSObjectParams) (GCSReader, error) {
r, err := service.Client.Bucket(params.Bucket).Object(params.ID).NewReader(ctx)
if err != nil {
return nil, err
}
return r, nil
} | [
"func",
"(",
"service",
"*",
"GCSService",
")",
"ReadObject",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"GCSObjectParams",
")",
"(",
"GCSReader",
",",
"error",
")",
"{",
"r",
",",
"err",
":=",
"service",
".",
"Client",
".",
"Bucket",
"(",
"... | // ReadObject reads a GCSObjectParams, returning a GCSReader object if successful, and an error otherwise | [
"ReadObject",
"reads",
"a",
"GCSObjectParams",
"returning",
"a",
"GCSReader",
"object",
"if",
"successful",
"and",
"an",
"error",
"otherwise"
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/gcsstore/gcsservice.go#L264-L271 |
31,443 | tus/tusd | gcsstore/gcsservice.go | SetObjectMetadata | func (service *GCSService) SetObjectMetadata(ctx context.Context, params GCSObjectParams, metadata map[string]string) error {
attrs := storage.ObjectAttrsToUpdate{
Metadata: metadata,
}
_, err := service.Client.Bucket(params.Bucket).Object(params.ID).Update(ctx, attrs)
return err
} | go | func (service *GCSService) SetObjectMetadata(ctx context.Context, params GCSObjectParams, metadata map[string]string) error {
attrs := storage.ObjectAttrsToUpdate{
Metadata: metadata,
}
_, err := service.Client.Bucket(params.Bucket).Object(params.ID).Update(ctx, attrs)
return err
} | [
"func",
"(",
"service",
"*",
"GCSService",
")",
"SetObjectMetadata",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"GCSObjectParams",
",",
"metadata",
"map",
"[",
"string",
"]",
"string",
")",
"error",
"{",
"attrs",
":=",
"storage",
".",
"ObjectAttrs... | // SetObjectMetadata reads a GCSObjectParams and a map of metedata, returning a nil on sucess and an error otherwise | [
"SetObjectMetadata",
"reads",
"a",
"GCSObjectParams",
"and",
"a",
"map",
"of",
"metedata",
"returning",
"a",
"nil",
"on",
"sucess",
"and",
"an",
"error",
"otherwise"
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/gcsstore/gcsservice.go#L274-L281 |
31,444 | tus/tusd | gcsstore/gcsservice.go | DeleteObject | func (service *GCSService) DeleteObject(ctx context.Context, params GCSObjectParams) error {
return service.Client.Bucket(params.Bucket).Object(params.ID).Delete(ctx)
} | go | func (service *GCSService) DeleteObject(ctx context.Context, params GCSObjectParams) error {
return service.Client.Bucket(params.Bucket).Object(params.ID).Delete(ctx)
} | [
"func",
"(",
"service",
"*",
"GCSService",
")",
"DeleteObject",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"GCSObjectParams",
")",
"error",
"{",
"return",
"service",
".",
"Client",
".",
"Bucket",
"(",
"params",
".",
"Bucket",
")",
".",
"Object",... | // DeleteObject deletes the object defined by GCSObjectParams | [
"DeleteObject",
"deletes",
"the",
"object",
"defined",
"by",
"GCSObjectParams"
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/gcsstore/gcsservice.go#L284-L286 |
31,445 | tus/tusd | gcsstore/gcsservice.go | WriteObject | func (service *GCSService) WriteObject(ctx context.Context, params GCSObjectParams, r io.Reader) (int64, error) {
obj := service.Client.Bucket(params.Bucket).Object(params.ID)
w := obj.NewWriter(ctx)
n, err := io.Copy(w, r)
if err != nil {
return 0, err
}
err = w.Close()
if err != nil {
if gErr, ok := err... | go | func (service *GCSService) WriteObject(ctx context.Context, params GCSObjectParams, r io.Reader) (int64, error) {
obj := service.Client.Bucket(params.Bucket).Object(params.ID)
w := obj.NewWriter(ctx)
n, err := io.Copy(w, r)
if err != nil {
return 0, err
}
err = w.Close()
if err != nil {
if gErr, ok := err... | [
"func",
"(",
"service",
"*",
"GCSService",
")",
"WriteObject",
"(",
"ctx",
"context",
".",
"Context",
",",
"params",
"GCSObjectParams",
",",
"r",
"io",
".",
"Reader",
")",
"(",
"int64",
",",
"error",
")",
"{",
"obj",
":=",
"service",
".",
"Client",
"."... | // Write object writes the file set out by the GCSObjectParams | [
"Write",
"object",
"writes",
"the",
"file",
"set",
"out",
"by",
"the",
"GCSObjectParams"
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/gcsstore/gcsservice.go#L289-L308 |
31,446 | tus/tusd | gcsstore/gcsservice.go | ComposeFrom | func (service *GCSService) ComposeFrom(ctx context.Context, objSrcs []*storage.ObjectHandle, dstParams GCSObjectParams, contentType string) (uint32, error) {
dstObj := service.Client.Bucket(dstParams.Bucket).Object(dstParams.ID)
c := dstObj.ComposerFrom(objSrcs...)
c.ContentType = contentType
_, err := c.Run(ctx)
... | go | func (service *GCSService) ComposeFrom(ctx context.Context, objSrcs []*storage.ObjectHandle, dstParams GCSObjectParams, contentType string) (uint32, error) {
dstObj := service.Client.Bucket(dstParams.Bucket).Object(dstParams.ID)
c := dstObj.ComposerFrom(objSrcs...)
c.ContentType = contentType
_, err := c.Run(ctx)
... | [
"func",
"(",
"service",
"*",
"GCSService",
")",
"ComposeFrom",
"(",
"ctx",
"context",
".",
"Context",
",",
"objSrcs",
"[",
"]",
"*",
"storage",
".",
"ObjectHandle",
",",
"dstParams",
"GCSObjectParams",
",",
"contentType",
"string",
")",
"(",
"uint32",
",",
... | // ComposeFrom composes multiple object types together, | [
"ComposeFrom",
"composes",
"multiple",
"object",
"types",
"together"
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/gcsstore/gcsservice.go#L311-L326 |
31,447 | tus/tusd | memorylocker/memorylocker.go | UnlockUpload | func (locker *MemoryLocker) UnlockUpload(id string) error {
locker.mutex.Lock()
// Deleting a non-existing key does not end in unexpected errors or panic
// since this operation results in a no-op
delete(locker.locks, id)
locker.mutex.Unlock()
return nil
} | go | func (locker *MemoryLocker) UnlockUpload(id string) error {
locker.mutex.Lock()
// Deleting a non-existing key does not end in unexpected errors or panic
// since this operation results in a no-op
delete(locker.locks, id)
locker.mutex.Unlock()
return nil
} | [
"func",
"(",
"locker",
"*",
"MemoryLocker",
")",
"UnlockUpload",
"(",
"id",
"string",
")",
"error",
"{",
"locker",
".",
"mutex",
".",
"Lock",
"(",
")",
"\n\n",
"// Deleting a non-existing key does not end in unexpected errors or panic",
"// since this operation results in... | // UnlockUpload releases a lock. If no such lock exists, no error will be returned. | [
"UnlockUpload",
"releases",
"a",
"lock",
".",
"If",
"no",
"such",
"lock",
"exists",
"no",
"error",
"will",
"be",
"returned",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/memorylocker/memorylocker.go#L62-L71 |
31,448 | tus/tusd | gcsstore/gcsstore.go | New | func New(bucket string, service GCSAPI) GCSStore {
return GCSStore{
Bucket: bucket,
Service: service,
}
} | go | func New(bucket string, service GCSAPI) GCSStore {
return GCSStore{
Bucket: bucket,
Service: service,
}
} | [
"func",
"New",
"(",
"bucket",
"string",
",",
"service",
"GCSAPI",
")",
"GCSStore",
"{",
"return",
"GCSStore",
"{",
"Bucket",
":",
"bucket",
",",
"Service",
":",
"service",
",",
"}",
"\n",
"}"
] | // New constructs a new GCS storage backend using the supplied GCS bucket name
// and service object. | [
"New",
"constructs",
"a",
"new",
"GCS",
"storage",
"backend",
"using",
"the",
"supplied",
"GCS",
"bucket",
"name",
"and",
"service",
"object",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/gcsstore/gcsstore.go#L42-L47 |
31,449 | tus/tusd | etcd3locker/locker.go | NewWithPrefix | func NewWithPrefix(client *etcd3.Client, prefix string) (*Etcd3Locker, error) {
lockerOptions := DefaultLockerOptions()
lockerOptions.SetPrefix(prefix)
return NewWithLockerOptions(client, lockerOptions)
} | go | func NewWithPrefix(client *etcd3.Client, prefix string) (*Etcd3Locker, error) {
lockerOptions := DefaultLockerOptions()
lockerOptions.SetPrefix(prefix)
return NewWithLockerOptions(client, lockerOptions)
} | [
"func",
"NewWithPrefix",
"(",
"client",
"*",
"etcd3",
".",
"Client",
",",
"prefix",
"string",
")",
"(",
"*",
"Etcd3Locker",
",",
"error",
")",
"{",
"lockerOptions",
":=",
"DefaultLockerOptions",
"(",
")",
"\n",
"lockerOptions",
".",
"SetPrefix",
"(",
"prefix... | // This method may be used if a different prefix is required for multi-tenant etcd clusters | [
"This",
"method",
"may",
"be",
"used",
"if",
"a",
"different",
"prefix",
"is",
"required",
"for",
"multi",
"-",
"tenant",
"etcd",
"clusters"
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/etcd3locker/locker.go#L79-L83 |
31,450 | tus/tusd | composer.go | newStoreComposerFromDataStore | func newStoreComposerFromDataStore(store DataStore) *StoreComposer {
composer := NewStoreComposer()
composer.UseCore(store)
if mod, ok := store.(TerminaterDataStore); ok {
composer.UseTerminater(mod)
}
if mod, ok := store.(FinisherDataStore); ok {
composer.UseFinisher(mod)
}
if mod, ok := store.(LockerDataS... | go | func newStoreComposerFromDataStore(store DataStore) *StoreComposer {
composer := NewStoreComposer()
composer.UseCore(store)
if mod, ok := store.(TerminaterDataStore); ok {
composer.UseTerminater(mod)
}
if mod, ok := store.(FinisherDataStore); ok {
composer.UseFinisher(mod)
}
if mod, ok := store.(LockerDataS... | [
"func",
"newStoreComposerFromDataStore",
"(",
"store",
"DataStore",
")",
"*",
"StoreComposer",
"{",
"composer",
":=",
"NewStoreComposer",
"(",
")",
"\n",
"composer",
".",
"UseCore",
"(",
"store",
")",
"\n\n",
"if",
"mod",
",",
"ok",
":=",
"store",
".",
"(",
... | // newStoreComposerFromDataStore creates a new store composer and attempts to
// extract the extensions for the provided store. This is intended to be used
// for transitioning from data stores to composers. | [
"newStoreComposerFromDataStore",
"creates",
"a",
"new",
"store",
"composer",
"and",
"attempts",
"to",
"extract",
"the",
"extensions",
"for",
"the",
"provided",
"store",
".",
"This",
"is",
"intended",
"to",
"be",
"used",
"for",
"transitioning",
"from",
"data",
"s... | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/composer.go#L31-L55 |
31,451 | tus/tusd | composer.go | Capabilities | func (store *StoreComposer) Capabilities() string {
str := "Core: "
if store.Core != nil {
str += "✓"
} else {
str += "✗"
}
str += ` Terminater: `
if store.UsesTerminater {
str += "✓"
} else {
str += "✗"
}
str += ` Finisher: `
if store.UsesFinisher {
str += "✓"
} else {
str += "✗"
}
str += ` ... | go | func (store *StoreComposer) Capabilities() string {
str := "Core: "
if store.Core != nil {
str += "✓"
} else {
str += "✗"
}
str += ` Terminater: `
if store.UsesTerminater {
str += "✓"
} else {
str += "✗"
}
str += ` Finisher: `
if store.UsesFinisher {
str += "✓"
} else {
str += "✗"
}
str += ` ... | [
"func",
"(",
"store",
"*",
"StoreComposer",
")",
"Capabilities",
"(",
")",
"string",
"{",
"str",
":=",
"\"",
"\"",
"\n\n",
"if",
"store",
".",
"Core",
"!=",
"nil",
"{",
"str",
"+=",
"\"",
"",
"\n",
"}",
"else",
"{",
"str",
"+=",
"\"",
"",
"\n",
... | // Capabilities returns a string representing the provided extensions in a
// human-readable format meant for debugging. | [
"Capabilities",
"returns",
"a",
"string",
"representing",
"the",
"provided",
"extensions",
"in",
"a",
"human",
"-",
"readable",
"format",
"meant",
"for",
"debugging",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/composer.go#L59-L106 |
31,452 | tus/tusd | s3store/s3store.go | New | func New(bucket string, service S3API) S3Store {
return S3Store{
Bucket: bucket,
Service: service,
MaxPartSize: 5 * 1024 * 1024 * 1024,
MinPartSize: 5 * 1024 * 1024,
MaxMultipartParts: 10000,
MaxObjectSize: 5 * 1024 * 1024 * 1024 * 1024,
}
} | go | func New(bucket string, service S3API) S3Store {
return S3Store{
Bucket: bucket,
Service: service,
MaxPartSize: 5 * 1024 * 1024 * 1024,
MinPartSize: 5 * 1024 * 1024,
MaxMultipartParts: 10000,
MaxObjectSize: 5 * 1024 * 1024 * 1024 * 1024,
}
} | [
"func",
"New",
"(",
"bucket",
"string",
",",
"service",
"S3API",
")",
"S3Store",
"{",
"return",
"S3Store",
"{",
"Bucket",
":",
"bucket",
",",
"Service",
":",
"service",
",",
"MaxPartSize",
":",
"5",
"*",
"1024",
"*",
"1024",
"*",
"1024",
",",
"MinPartS... | // New constructs a new storage using the supplied bucket and service object. | [
"New",
"constructs",
"a",
"new",
"storage",
"using",
"the",
"supplied",
"bucket",
"and",
"service",
"object",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/s3store/s3store.go#L147-L156 |
31,453 | tus/tusd | s3store/s3store.go | isAwsError | func isAwsError(err error, code string) bool {
if err, ok := err.(awserr.Error); ok && err.Code() == code {
return true
}
return false
} | go | func isAwsError(err error, code string) bool {
if err, ok := err.(awserr.Error); ok && err.Code() == code {
return true
}
return false
} | [
"func",
"isAwsError",
"(",
"err",
"error",
",",
"code",
"string",
")",
"bool",
"{",
"if",
"err",
",",
"ok",
":=",
"err",
".",
"(",
"awserr",
".",
"Error",
")",
";",
"ok",
"&&",
"err",
".",
"Code",
"(",
")",
"==",
"code",
"{",
"return",
"true",
... | // isAwsError tests whether an error object is an instance of the AWS error
// specified by its code. | [
"isAwsError",
"tests",
"whether",
"an",
"error",
"object",
"is",
"an",
"instance",
"of",
"the",
"AWS",
"error",
"specified",
"by",
"its",
"code",
"."
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/s3store/s3store.go#L676-L681 |
31,454 | tus/tusd | etcd3locker/lock.go | Acquire | func (lock *etcd3Lock) Acquire() error {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
// this is a blocking call; if we receive DeadlineExceeded
// the lock is most likely already taken
if err := lock.Mutex.Lock(ctx); err != nil {
if err == context.DeadlineExceeded {
... | go | func (lock *etcd3Lock) Acquire() error {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
// this is a blocking call; if we receive DeadlineExceeded
// the lock is most likely already taken
if err := lock.Mutex.Lock(ctx); err != nil {
if err == context.DeadlineExceeded {
... | [
"func",
"(",
"lock",
"*",
"etcd3Lock",
")",
"Acquire",
"(",
")",
"error",
"{",
"ctx",
",",
"cancel",
":=",
"context",
".",
"WithTimeout",
"(",
"context",
".",
"Background",
"(",
")",
",",
"5",
"*",
"time",
".",
"Second",
")",
"\n",
"defer",
"cancel",... | // Acquires a lock from etcd3 | [
"Acquires",
"a",
"lock",
"from",
"etcd3"
] | 12f102abf6cbd174b4dc9323672f59c6357b561c | https://github.com/tus/tusd/blob/12f102abf6cbd174b4dc9323672f59c6357b561c/etcd3locker/lock.go#L27-L41 |
31,455 | mitchellh/mapstructure | decode_hooks.go | DecodeHookExec | func DecodeHookExec(
raw DecodeHookFunc,
from reflect.Type, to reflect.Type,
data interface{}) (interface{}, error) {
switch f := typedDecodeHook(raw).(type) {
case DecodeHookFuncType:
return f(from, to, data)
case DecodeHookFuncKind:
return f(from.Kind(), to.Kind(), data)
default:
return nil, errors.New("... | go | func DecodeHookExec(
raw DecodeHookFunc,
from reflect.Type, to reflect.Type,
data interface{}) (interface{}, error) {
switch f := typedDecodeHook(raw).(type) {
case DecodeHookFuncType:
return f(from, to, data)
case DecodeHookFuncKind:
return f(from.Kind(), to.Kind(), data)
default:
return nil, errors.New("... | [
"func",
"DecodeHookExec",
"(",
"raw",
"DecodeHookFunc",
",",
"from",
"reflect",
".",
"Type",
",",
"to",
"reflect",
".",
"Type",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"switch",
"f",
":=",
"typedDeco... | // DecodeHookExec executes the given decode hook. This should be used
// since it'll naturally degrade to the older backwards compatible DecodeHookFunc
// that took reflect.Kind instead of reflect.Type. | [
"DecodeHookExec",
"executes",
"the",
"given",
"decode",
"hook",
".",
"This",
"should",
"be",
"used",
"since",
"it",
"ll",
"naturally",
"degrade",
"to",
"the",
"older",
"backwards",
"compatible",
"DecodeHookFunc",
"that",
"took",
"reflect",
".",
"Kind",
"instead"... | 3536a929edddb9a5b34bd6861dc4a9647cb459fe | https://github.com/mitchellh/mapstructure/blob/3536a929edddb9a5b34bd6861dc4a9647cb459fe/decode_hooks.go#L39-L51 |
31,456 | mitchellh/mapstructure | decode_hooks.go | ComposeDecodeHookFunc | func ComposeDecodeHookFunc(fs ...DecodeHookFunc) DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
var err error
for _, f1 := range fs {
data, err = DecodeHookExec(f1, f, t, data)
if err != nil {
return nil, err
}
// Modify the from kind t... | go | func ComposeDecodeHookFunc(fs ...DecodeHookFunc) DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
var err error
for _, f1 := range fs {
data, err = DecodeHookExec(f1, f, t, data)
if err != nil {
return nil, err
}
// Modify the from kind t... | [
"func",
"ComposeDecodeHookFunc",
"(",
"fs",
"...",
"DecodeHookFunc",
")",
"DecodeHookFunc",
"{",
"return",
"func",
"(",
"f",
"reflect",
".",
"Type",
",",
"t",
"reflect",
".",
"Type",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",... | // ComposeDecodeHookFunc creates a single DecodeHookFunc that
// automatically composes multiple DecodeHookFuncs.
//
// The composed funcs are called in order, with the result of the
// previous transformation. | [
"ComposeDecodeHookFunc",
"creates",
"a",
"single",
"DecodeHookFunc",
"that",
"automatically",
"composes",
"multiple",
"DecodeHookFuncs",
".",
"The",
"composed",
"funcs",
"are",
"called",
"in",
"order",
"with",
"the",
"result",
"of",
"the",
"previous",
"transformation"... | 3536a929edddb9a5b34bd6861dc4a9647cb459fe | https://github.com/mitchellh/mapstructure/blob/3536a929edddb9a5b34bd6861dc4a9647cb459fe/decode_hooks.go#L58-L79 |
31,457 | mitchellh/mapstructure | decode_hooks.go | StringToTimeDurationHookFunc | func StringToTimeDurationHookFunc() DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
if f.Kind() != reflect.String {
return data, nil
}
if t != reflect.TypeOf(time.Duration(5)) {
return data, nil
}
// Convert it by parsing
return time.Parse... | go | func StringToTimeDurationHookFunc() DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
if f.Kind() != reflect.String {
return data, nil
}
if t != reflect.TypeOf(time.Duration(5)) {
return data, nil
}
// Convert it by parsing
return time.Parse... | [
"func",
"StringToTimeDurationHookFunc",
"(",
")",
"DecodeHookFunc",
"{",
"return",
"func",
"(",
"f",
"reflect",
".",
"Type",
",",
"t",
"reflect",
".",
"Type",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
... | // StringToTimeDurationHookFunc returns a DecodeHookFunc that converts
// strings to time.Duration. | [
"StringToTimeDurationHookFunc",
"returns",
"a",
"DecodeHookFunc",
"that",
"converts",
"strings",
"to",
"time",
".",
"Duration",
"."
] | 3536a929edddb9a5b34bd6861dc4a9647cb459fe | https://github.com/mitchellh/mapstructure/blob/3536a929edddb9a5b34bd6861dc4a9647cb459fe/decode_hooks.go#L103-L118 |
31,458 | mitchellh/mapstructure | decode_hooks.go | StringToIPHookFunc | func StringToIPHookFunc() DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
if f.Kind() != reflect.String {
return data, nil
}
if t != reflect.TypeOf(net.IP{}) {
return data, nil
}
// Convert it by parsing
ip := net.ParseIP(data.(string))
... | go | func StringToIPHookFunc() DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
if f.Kind() != reflect.String {
return data, nil
}
if t != reflect.TypeOf(net.IP{}) {
return data, nil
}
// Convert it by parsing
ip := net.ParseIP(data.(string))
... | [
"func",
"StringToIPHookFunc",
"(",
")",
"DecodeHookFunc",
"{",
"return",
"func",
"(",
"f",
"reflect",
".",
"Type",
",",
"t",
"reflect",
".",
"Type",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
"f... | // StringToIPHookFunc returns a DecodeHookFunc that converts
// strings to net.IP | [
"StringToIPHookFunc",
"returns",
"a",
"DecodeHookFunc",
"that",
"converts",
"strings",
"to",
"net",
".",
"IP"
] | 3536a929edddb9a5b34bd6861dc4a9647cb459fe | https://github.com/mitchellh/mapstructure/blob/3536a929edddb9a5b34bd6861dc4a9647cb459fe/decode_hooks.go#L122-L142 |
31,459 | mitchellh/mapstructure | decode_hooks.go | StringToIPNetHookFunc | func StringToIPNetHookFunc() DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
if f.Kind() != reflect.String {
return data, nil
}
if t != reflect.TypeOf(net.IPNet{}) {
return data, nil
}
// Convert it by parsing
_, net, err := net.ParseCIDR(... | go | func StringToIPNetHookFunc() DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
if f.Kind() != reflect.String {
return data, nil
}
if t != reflect.TypeOf(net.IPNet{}) {
return data, nil
}
// Convert it by parsing
_, net, err := net.ParseCIDR(... | [
"func",
"StringToIPNetHookFunc",
"(",
")",
"DecodeHookFunc",
"{",
"return",
"func",
"(",
"f",
"reflect",
".",
"Type",
",",
"t",
"reflect",
".",
"Type",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"if",
... | // StringToIPNetHookFunc returns a DecodeHookFunc that converts
// strings to net.IPNet | [
"StringToIPNetHookFunc",
"returns",
"a",
"DecodeHookFunc",
"that",
"converts",
"strings",
"to",
"net",
".",
"IPNet"
] | 3536a929edddb9a5b34bd6861dc4a9647cb459fe | https://github.com/mitchellh/mapstructure/blob/3536a929edddb9a5b34bd6861dc4a9647cb459fe/decode_hooks.go#L146-L162 |
31,460 | mitchellh/mapstructure | decode_hooks.go | StringToTimeHookFunc | func StringToTimeHookFunc(layout string) DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
if f.Kind() != reflect.String {
return data, nil
}
if t != reflect.TypeOf(time.Time{}) {
return data, nil
}
// Convert it by parsing
return time.Parse... | go | func StringToTimeHookFunc(layout string) DecodeHookFunc {
return func(
f reflect.Type,
t reflect.Type,
data interface{}) (interface{}, error) {
if f.Kind() != reflect.String {
return data, nil
}
if t != reflect.TypeOf(time.Time{}) {
return data, nil
}
// Convert it by parsing
return time.Parse... | [
"func",
"StringToTimeHookFunc",
"(",
"layout",
"string",
")",
"DecodeHookFunc",
"{",
"return",
"func",
"(",
"f",
"reflect",
".",
"Type",
",",
"t",
"reflect",
".",
"Type",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
... | // StringToTimeHookFunc returns a DecodeHookFunc that converts
// strings to time.Time. | [
"StringToTimeHookFunc",
"returns",
"a",
"DecodeHookFunc",
"that",
"converts",
"strings",
"to",
"time",
".",
"Time",
"."
] | 3536a929edddb9a5b34bd6861dc4a9647cb459fe | https://github.com/mitchellh/mapstructure/blob/3536a929edddb9a5b34bd6861dc4a9647cb459fe/decode_hooks.go#L166-L181 |
31,461 | mitchellh/mapstructure | decode_hooks.go | WeaklyTypedHook | func WeaklyTypedHook(
f reflect.Kind,
t reflect.Kind,
data interface{}) (interface{}, error) {
dataVal := reflect.ValueOf(data)
switch t {
case reflect.String:
switch f {
case reflect.Bool:
if dataVal.Bool() {
return "1", nil
}
return "0", nil
case reflect.Float32:
return strconv.FormatFloat... | go | func WeaklyTypedHook(
f reflect.Kind,
t reflect.Kind,
data interface{}) (interface{}, error) {
dataVal := reflect.ValueOf(data)
switch t {
case reflect.String:
switch f {
case reflect.Bool:
if dataVal.Bool() {
return "1", nil
}
return "0", nil
case reflect.Float32:
return strconv.FormatFloat... | [
"func",
"WeaklyTypedHook",
"(",
"f",
"reflect",
".",
"Kind",
",",
"t",
"reflect",
".",
"Kind",
",",
"data",
"interface",
"{",
"}",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
"{",
"dataVal",
":=",
"reflect",
".",
"ValueOf",
"(",
"data",
")",
... | // WeaklyTypedHook is a DecodeHookFunc which adds support for weak typing to
// the decoder.
//
// Note that this is significantly different from the WeaklyTypedInput option
// of the DecoderConfig. | [
"WeaklyTypedHook",
"is",
"a",
"DecodeHookFunc",
"which",
"adds",
"support",
"for",
"weak",
"typing",
"to",
"the",
"decoder",
".",
"Note",
"that",
"this",
"is",
"significantly",
"different",
"from",
"the",
"WeaklyTypedInput",
"option",
"of",
"the",
"DecoderConfig",... | 3536a929edddb9a5b34bd6861dc4a9647cb459fe | https://github.com/mitchellh/mapstructure/blob/3536a929edddb9a5b34bd6861dc4a9647cb459fe/decode_hooks.go#L188-L217 |
31,462 | mitchellh/mapstructure | mapstructure.go | Decode | func Decode(input interface{}, output interface{}) error {
config := &DecoderConfig{
Metadata: nil,
Result: output,
}
decoder, err := NewDecoder(config)
if err != nil {
return err
}
return decoder.Decode(input)
} | go | func Decode(input interface{}, output interface{}) error {
config := &DecoderConfig{
Metadata: nil,
Result: output,
}
decoder, err := NewDecoder(config)
if err != nil {
return err
}
return decoder.Decode(input)
} | [
"func",
"Decode",
"(",
"input",
"interface",
"{",
"}",
",",
"output",
"interface",
"{",
"}",
")",
"error",
"{",
"config",
":=",
"&",
"DecoderConfig",
"{",
"Metadata",
":",
"nil",
",",
"Result",
":",
"output",
",",
"}",
"\n\n",
"decoder",
",",
"err",
... | // Decode takes an input structure and uses reflection to translate it to
// the output structure. output must be a pointer to a map or struct. | [
"Decode",
"takes",
"an",
"input",
"structure",
"and",
"uses",
"reflection",
"to",
"translate",
"it",
"to",
"the",
"output",
"structure",
".",
"output",
"must",
"be",
"a",
"pointer",
"to",
"a",
"map",
"or",
"struct",
"."
] | 3536a929edddb9a5b34bd6861dc4a9647cb459fe | https://github.com/mitchellh/mapstructure/blob/3536a929edddb9a5b34bd6861dc4a9647cb459fe/mapstructure.go#L119-L131 |
31,463 | mitchellh/mapstructure | mapstructure.go | NewDecoder | func NewDecoder(config *DecoderConfig) (*Decoder, error) {
val := reflect.ValueOf(config.Result)
if val.Kind() != reflect.Ptr {
return nil, errors.New("result must be a pointer")
}
val = val.Elem()
if !val.CanAddr() {
return nil, errors.New("result must be addressable (a pointer)")
}
if config.Metadata != ... | go | func NewDecoder(config *DecoderConfig) (*Decoder, error) {
val := reflect.ValueOf(config.Result)
if val.Kind() != reflect.Ptr {
return nil, errors.New("result must be a pointer")
}
val = val.Elem()
if !val.CanAddr() {
return nil, errors.New("result must be addressable (a pointer)")
}
if config.Metadata != ... | [
"func",
"NewDecoder",
"(",
"config",
"*",
"DecoderConfig",
")",
"(",
"*",
"Decoder",
",",
"error",
")",
"{",
"val",
":=",
"reflect",
".",
"ValueOf",
"(",
"config",
".",
"Result",
")",
"\n",
"if",
"val",
".",
"Kind",
"(",
")",
"!=",
"reflect",
".",
... | // NewDecoder returns a new decoder for the given configuration. Once
// a decoder has been returned, the same configuration must not be used
// again. | [
"NewDecoder",
"returns",
"a",
"new",
"decoder",
"for",
"the",
"given",
"configuration",
".",
"Once",
"a",
"decoder",
"has",
"been",
"returned",
"the",
"same",
"configuration",
"must",
"not",
"be",
"used",
"again",
"."
] | 3536a929edddb9a5b34bd6861dc4a9647cb459fe | https://github.com/mitchellh/mapstructure/blob/3536a929edddb9a5b34bd6861dc4a9647cb459fe/mapstructure.go#L187-L217 |
31,464 | mitchellh/mapstructure | error.go | WrappedErrors | func (e *Error) WrappedErrors() []error {
if e == nil {
return nil
}
result := make([]error, len(e.Errors))
for i, e := range e.Errors {
result[i] = errors.New(e)
}
return result
} | go | func (e *Error) WrappedErrors() []error {
if e == nil {
return nil
}
result := make([]error, len(e.Errors))
for i, e := range e.Errors {
result[i] = errors.New(e)
}
return result
} | [
"func",
"(",
"e",
"*",
"Error",
")",
"WrappedErrors",
"(",
")",
"[",
"]",
"error",
"{",
"if",
"e",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"result",
":=",
"make",
"(",
"[",
"]",
"error",
",",
"len",
"(",
"e",
".",
"Errors",
")",
... | // WrappedErrors implements the errwrap.Wrapper interface to make this
// return value more useful with the errwrap and go-multierror libraries. | [
"WrappedErrors",
"implements",
"the",
"errwrap",
".",
"Wrapper",
"interface",
"to",
"make",
"this",
"return",
"value",
"more",
"useful",
"with",
"the",
"errwrap",
"and",
"go",
"-",
"multierror",
"libraries",
"."
] | 3536a929edddb9a5b34bd6861dc4a9647cb459fe | https://github.com/mitchellh/mapstructure/blob/3536a929edddb9a5b34bd6861dc4a9647cb459fe/error.go#L30-L41 |
31,465 | perkeep/perkeep | pkg/gpgchallenge/gpg.go | rateLimit | func (cs *Server) rateLimit(keyID, claimedIP string) (isSpammer bool) {
cs.whiteListMu.Lock()
if _, ok := cs.whiteList[keyID+"-"+claimedIP]; ok {
cs.whiteListMu.Unlock()
return false
}
cs.whiteListMu.Unlock()
// If they haven't successfully challenged us before, they look suspicious.
cs.keyIDSeenMu.Lock()
la... | go | func (cs *Server) rateLimit(keyID, claimedIP string) (isSpammer bool) {
cs.whiteListMu.Lock()
if _, ok := cs.whiteList[keyID+"-"+claimedIP]; ok {
cs.whiteListMu.Unlock()
return false
}
cs.whiteListMu.Unlock()
// If they haven't successfully challenged us before, they look suspicious.
cs.keyIDSeenMu.Lock()
la... | [
"func",
"(",
"cs",
"*",
"Server",
")",
"rateLimit",
"(",
"keyID",
",",
"claimedIP",
"string",
")",
"(",
"isSpammer",
"bool",
")",
"{",
"cs",
".",
"whiteListMu",
".",
"Lock",
"(",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
"cs",
".",
"whiteList",
"[",
... | // rateLimit uses the cs.limiter to make sure that any client that hasn't
// previously successfully challenged us is rate limited. It also keeps track of
// clients that haven't successfully challenged, and it returns true if such a
// client should be considered a spammer. | [
"rateLimit",
"uses",
"the",
"cs",
".",
"limiter",
"to",
"make",
"sure",
"that",
"any",
"client",
"that",
"hasn",
"t",
"previously",
"successfully",
"challenged",
"us",
"is",
"rate",
"limited",
".",
"It",
"also",
"keeps",
"track",
"of",
"clients",
"that",
"... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/gpgchallenge/gpg.go#L343-L390 |
31,466 | perkeep/perkeep | pkg/gpgchallenge/gpg.go | NewClient | func NewClient(keyRing, keyId, challengeIP string) (*Client, error) {
signer, err := secretKeyEntity(keyRing, keyId)
if err != nil {
return nil, fmt.Errorf("could not get signer %v from keyRing %v: %v", keyId, keyRing, err)
}
cl := &Client{
keyRing: keyRing,
keyId: keyId,
signer: signer,
ch... | go | func NewClient(keyRing, keyId, challengeIP string) (*Client, error) {
signer, err := secretKeyEntity(keyRing, keyId)
if err != nil {
return nil, fmt.Errorf("could not get signer %v from keyRing %v: %v", keyId, keyRing, err)
}
cl := &Client{
keyRing: keyRing,
keyId: keyId,
signer: signer,
ch... | [
"func",
"NewClient",
"(",
"keyRing",
",",
"keyId",
",",
"challengeIP",
"string",
")",
"(",
"*",
"Client",
",",
"error",
")",
"{",
"signer",
",",
"err",
":=",
"secretKeyEntity",
"(",
"keyRing",
",",
"keyId",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"... | // NewClient returns a Client. keyRing and keyId are the GPG key ring and key ID
// used to fulfill the challenge. challengeIP is the address that client proves
// that it owns, by answering the challenge the server sends at this address. | [
"NewClient",
"returns",
"a",
"Client",
".",
"keyRing",
"and",
"keyId",
"are",
"the",
"GPG",
"key",
"ring",
"and",
"key",
"ID",
"used",
"to",
"fulfill",
"the",
"challenge",
".",
"challengeIP",
"is",
"the",
"address",
"that",
"client",
"proves",
"that",
"it"... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/gpgchallenge/gpg.go#L515-L532 |
31,467 | perkeep/perkeep | pkg/gpgchallenge/gpg.go | Handler | func (cl *Client) Handler() (prefix string, h http.Handler) {
return clientHandlerPrefix, cl.handler
} | go | func (cl *Client) Handler() (prefix string, h http.Handler) {
return clientHandlerPrefix, cl.handler
} | [
"func",
"(",
"cl",
"*",
"Client",
")",
"Handler",
"(",
")",
"(",
"prefix",
"string",
",",
"h",
"http",
".",
"Handler",
")",
"{",
"return",
"clientHandlerPrefix",
",",
"cl",
".",
"handler",
"\n",
"}"
] | // Handler returns the client's handler, that should be registered with an HTTPS
// server for the returned prefix, for the client to be able to receive the
// challenge. | [
"Handler",
"returns",
"the",
"client",
"s",
"handler",
"that",
"should",
"be",
"registered",
"with",
"an",
"HTTPS",
"server",
"for",
"the",
"returned",
"prefix",
"for",
"the",
"client",
"to",
"be",
"able",
"to",
"receive",
"the",
"challenge",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/gpgchallenge/gpg.go#L537-L539 |
31,468 | perkeep/perkeep | pkg/gpgchallenge/gpg.go | listenSelfCheck | func (cl *Client) listenSelfCheck(serverAddr string) error {
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
ServerName: cl.challengeIP + SNISuffix,
},
}
httpClient := &http.Client{
Transport: tr,
}
errc := make(chan error, 1)
respc := make(chan *http.Response, 1... | go | func (cl *Client) listenSelfCheck(serverAddr string) error {
tr := &http.Transport{
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
ServerName: cl.challengeIP + SNISuffix,
},
}
httpClient := &http.Client{
Transport: tr,
}
errc := make(chan error, 1)
respc := make(chan *http.Response, 1... | [
"func",
"(",
"cl",
"*",
"Client",
")",
"listenSelfCheck",
"(",
"serverAddr",
"string",
")",
"error",
"{",
"tr",
":=",
"&",
"http",
".",
"Transport",
"{",
"TLSClientConfig",
":",
"&",
"tls",
".",
"Config",
"{",
"InsecureSkipVerify",
":",
"true",
",",
"Ser... | // listenSelfCheck tests whether the client is ready to receive a challenge,
// i.e. that the caller has registered the client's handler with a server. | [
"listenSelfCheck",
"tests",
"whether",
"the",
"client",
"is",
"ready",
"to",
"receive",
"a",
"challenge",
"i",
".",
"e",
".",
"that",
"the",
"caller",
"has",
"registered",
"the",
"client",
"s",
"handler",
"with",
"a",
"server",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/gpgchallenge/gpg.go#L576-L612 |
31,469 | perkeep/perkeep | pkg/blobserver/proxycache/proxycache.go | New | func New(maxBytes int64, cache, origin blobserver.Storage) *Storage {
sto := &Storage{
origin: origin,
cache: cache,
lru: lru.NewUnlocked(0),
maxCacheBytes: maxBytes,
}
return sto
} | go | func New(maxBytes int64, cache, origin blobserver.Storage) *Storage {
sto := &Storage{
origin: origin,
cache: cache,
lru: lru.NewUnlocked(0),
maxCacheBytes: maxBytes,
}
return sto
} | [
"func",
"New",
"(",
"maxBytes",
"int64",
",",
"cache",
",",
"origin",
"blobserver",
".",
"Storage",
")",
"*",
"Storage",
"{",
"sto",
":=",
"&",
"Storage",
"{",
"origin",
":",
"origin",
",",
"cache",
":",
"cache",
",",
"lru",
":",
"lru",
".",
"NewUnlo... | // New returns a proxycache blob storage that reads from cache,
// then origin, populating cache as needed, up to a total of maxBytes. | [
"New",
"returns",
"a",
"proxycache",
"blob",
"storage",
"that",
"reads",
"from",
"cache",
"then",
"origin",
"populating",
"cache",
"as",
"needed",
"up",
"to",
"a",
"total",
"of",
"maxBytes",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/proxycache/proxycache.go#L77-L85 |
31,470 | perkeep/perkeep | pkg/blobserver/proxycache/proxycache.go | removeOldest | func (sto *Storage) removeOldest() bool {
ctx := context.TODO()
k, v := sto.lru.RemoveOldest()
if v == nil {
return false
}
sb := v.(blob.SizedRef)
// TODO: run these without sto.mu held in background
// goroutine? at least pass a context?
err := sto.cache.RemoveBlobs(ctx, []blob.Ref{sb.Ref})
if err != nil {... | go | func (sto *Storage) removeOldest() bool {
ctx := context.TODO()
k, v := sto.lru.RemoveOldest()
if v == nil {
return false
}
sb := v.(blob.SizedRef)
// TODO: run these without sto.mu held in background
// goroutine? at least pass a context?
err := sto.cache.RemoveBlobs(ctx, []blob.Ref{sb.Ref})
if err != nil {... | [
"func",
"(",
"sto",
"*",
"Storage",
")",
"removeOldest",
"(",
")",
"bool",
"{",
"ctx",
":=",
"context",
".",
"TODO",
"(",
")",
"\n",
"k",
",",
"v",
":=",
"sto",
".",
"lru",
".",
"RemoveOldest",
"(",
")",
"\n",
"if",
"v",
"==",
"nil",
"{",
"retu... | // must hold sto.mu.
// Reports whether an item was removed. | [
"must",
"hold",
"sto",
".",
"mu",
".",
"Reports",
"whether",
"an",
"item",
"was",
"removed",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/proxycache/proxycache.go#L113-L133 |
31,471 | perkeep/perkeep | server/perkeepd/ui/goui/dirchildren/dirchildren.go | New | func New(authToken, parentDir string, limit int,
updadeSearchSession func(string), triggerRender func()) *js.Object {
parentDirbr, ok := blob.Parse(parentDir)
if !ok {
dom.GetWindow().Alert(fmt.Sprintf("invalid parentDir blobRef: %q", parentDir))
return nil
}
return js.MakeWrapper(&Query{
ParentDir: ... | go | func New(authToken, parentDir string, limit int,
updadeSearchSession func(string), triggerRender func()) *js.Object {
parentDirbr, ok := blob.Parse(parentDir)
if !ok {
dom.GetWindow().Alert(fmt.Sprintf("invalid parentDir blobRef: %q", parentDir))
return nil
}
return js.MakeWrapper(&Query{
ParentDir: ... | [
"func",
"New",
"(",
"authToken",
",",
"parentDir",
"string",
",",
"limit",
"int",
",",
"updadeSearchSession",
"func",
"(",
"string",
")",
",",
"triggerRender",
"func",
"(",
")",
")",
"*",
"js",
".",
"Object",
"{",
"parentDirbr",
",",
"ok",
":=",
"blob",
... | // New returns a new Query as a javascript object, of nil if parentDir is not a
// valid blobRef. | [
"New",
"returns",
"a",
"new",
"Query",
"as",
"a",
"javascript",
"object",
"of",
"nil",
"if",
"parentDir",
"is",
"not",
"a",
"valid",
"blobRef",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/dirchildren/dirchildren.go#L72-L86 |
31,472 | perkeep/perkeep | server/perkeepd/ui/goui/dirchildren/dirchildren.go | Get | func (q *Query) Get() {
if q.isComplete {
return
}
if q.pending {
return
}
q.pending = true
go func() {
if err := q.get(); err != nil {
dom.GetWindow().Alert(fmt.Sprintf("%v", err))
return
}
q.TriggerRender()
}()
} | go | func (q *Query) Get() {
if q.isComplete {
return
}
if q.pending {
return
}
q.pending = true
go func() {
if err := q.get(); err != nil {
dom.GetWindow().Alert(fmt.Sprintf("%v", err))
return
}
q.TriggerRender()
}()
} | [
"func",
"(",
"q",
"*",
"Query",
")",
"Get",
"(",
")",
"{",
"if",
"q",
".",
"isComplete",
"{",
"return",
"\n",
"}",
"\n",
"if",
"q",
".",
"pending",
"{",
"return",
"\n",
"}",
"\n",
"q",
".",
"pending",
"=",
"true",
"\n",
"go",
"func",
"(",
")"... | // Get asynchronously sends the query, if one is not already in flight, or being
// processed. It runs q.UpdateSearchSession once the results have been received and
// merged with q.Blobs and q.Meta. It runs q.TriggerRender to refresh the DOM with
// the new results in the search session. | [
"Get",
"asynchronously",
"sends",
"the",
"query",
"if",
"one",
"is",
"not",
"already",
"in",
"flight",
"or",
"being",
"processed",
".",
"It",
"runs",
"q",
".",
"UpdateSearchSession",
"once",
"the",
"results",
"have",
"been",
"received",
"and",
"merged",
"wit... | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/server/perkeepd/ui/goui/dirchildren/dirchildren.go#L114-L129 |
31,473 | perkeep/perkeep | pkg/sorted/mysql/mysqlkv.go | newKVDB | func newKVDB(cfg jsonconfig.Obj) (sorted.KeyValue, error) {
var (
user = cfg.RequiredString("user")
database = cfg.RequiredString("database")
host = cfg.OptionalString("host", "")
password = cfg.OptionalString("password", "")
)
if err := cfg.Validate(); err != nil {
return nil, err
}
if !validDat... | go | func newKVDB(cfg jsonconfig.Obj) (sorted.KeyValue, error) {
var (
user = cfg.RequiredString("user")
database = cfg.RequiredString("database")
host = cfg.OptionalString("host", "")
password = cfg.OptionalString("password", "")
)
if err := cfg.Validate(); err != nil {
return nil, err
}
if !validDat... | [
"func",
"newKVDB",
"(",
"cfg",
"jsonconfig",
".",
"Obj",
")",
"(",
"sorted",
".",
"KeyValue",
",",
"error",
")",
"{",
"var",
"(",
"user",
"=",
"cfg",
".",
"RequiredString",
"(",
"\"",
"\"",
")",
"\n",
"database",
"=",
"cfg",
".",
"RequiredString",
"(... | // newKVDB returns an unusable KeyValue, with a database, but no tables yet. It
// should be followed by Wipe or finalize. | [
"newKVDB",
"returns",
"an",
"unusable",
"KeyValue",
"with",
"a",
"database",
"but",
"no",
"tables",
"yet",
".",
"It",
"should",
"be",
"followed",
"by",
"Wipe",
"or",
"finalize",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/mysql/mysqlkv.go#L45-L94 |
31,474 | perkeep/perkeep | pkg/sorted/mysql/mysqlkv.go | Wipe | func (kv *keyValue) Wipe() error {
if _, err := kv.db.Exec("DROP TABLE IF EXISTS " + kv.database + ".rows"); err != nil {
return err
}
if _, err := kv.db.Exec("DROP TABLE IF EXISTS " + kv.database + ".meta"); err != nil {
return err
}
return kv.finalize()
} | go | func (kv *keyValue) Wipe() error {
if _, err := kv.db.Exec("DROP TABLE IF EXISTS " + kv.database + ".rows"); err != nil {
return err
}
if _, err := kv.db.Exec("DROP TABLE IF EXISTS " + kv.database + ".meta"); err != nil {
return err
}
return kv.finalize()
} | [
"func",
"(",
"kv",
"*",
"keyValue",
")",
"Wipe",
"(",
")",
"error",
"{",
"if",
"_",
",",
"err",
":=",
"kv",
".",
"db",
".",
"Exec",
"(",
"\"",
"\"",
"+",
"kv",
".",
"database",
"+",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"... | // Wipe resets the KeyValue by dropping and recreating the database tables. | [
"Wipe",
"resets",
"the",
"KeyValue",
"by",
"dropping",
"and",
"recreating",
"the",
"database",
"tables",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/mysql/mysqlkv.go#L97-L105 |
31,475 | perkeep/perkeep | pkg/sorted/mysql/mysqlkv.go | finalize | func (kv *keyValue) finalize() error {
if err := createTables(kv.db, kv.database); err != nil {
return err
}
if err := kv.ping(); err != nil {
return fmt.Errorf("MySQL db unreachable: %v", err)
}
version, err := kv.SchemaVersion()
if err != nil {
return fmt.Errorf("error getting current database schema ve... | go | func (kv *keyValue) finalize() error {
if err := createTables(kv.db, kv.database); err != nil {
return err
}
if err := kv.ping(); err != nil {
return fmt.Errorf("MySQL db unreachable: %v", err)
}
version, err := kv.SchemaVersion()
if err != nil {
return fmt.Errorf("error getting current database schema ve... | [
"func",
"(",
"kv",
"*",
"keyValue",
")",
"finalize",
"(",
")",
"error",
"{",
"if",
"err",
":=",
"createTables",
"(",
"kv",
".",
"db",
",",
"kv",
".",
"database",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"err",
... | // finalize should be called on a keyValue initialized with newKVDB. | [
"finalize",
"should",
"be",
"called",
"on",
"a",
"keyValue",
"initialized",
"with",
"newKVDB",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/mysql/mysqlkv.go#L108-L146 |
31,476 | perkeep/perkeep | pkg/sorted/mysql/mysqlkv.go | CreateDB | func CreateDB(db *sql.DB, dbname string) error {
if dbname == "" {
return errors.New("can not create database: database name is missing")
}
if _, err := db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", dbname)); err != nil {
return fmt.Errorf("error creating database %v: %v", dbname, err)
}
return nil
} | go | func CreateDB(db *sql.DB, dbname string) error {
if dbname == "" {
return errors.New("can not create database: database name is missing")
}
if _, err := db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", dbname)); err != nil {
return fmt.Errorf("error creating database %v: %v", dbname, err)
}
return nil
} | [
"func",
"CreateDB",
"(",
"db",
"*",
"sql",
".",
"DB",
",",
"dbname",
"string",
")",
"error",
"{",
"if",
"dbname",
"==",
"\"",
"\"",
"{",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"db",
... | // CreateDB creates the named database if it does not already exist. | [
"CreateDB",
"creates",
"the",
"named",
"database",
"if",
"it",
"does",
"not",
"already",
"exist",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/mysql/mysqlkv.go#L164-L172 |
31,477 | perkeep/perkeep | pkg/sorted/mysql/mysqlkv.go | Close | func (kv *keyValue) Close() error {
dbsmu.Lock()
defer dbsmu.Unlock()
delete(dbs, kv.dsn)
return kv.DB.Close()
} | go | func (kv *keyValue) Close() error {
dbsmu.Lock()
defer dbsmu.Unlock()
delete(dbs, kv.dsn)
return kv.DB.Close()
} | [
"func",
"(",
"kv",
"*",
"keyValue",
")",
"Close",
"(",
")",
"error",
"{",
"dbsmu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"dbsmu",
".",
"Unlock",
"(",
")",
"\n",
"delete",
"(",
"dbs",
",",
"kv",
".",
"dsn",
")",
"\n",
"return",
"kv",
".",
"DB",
... | // Close overrides KeyValue.Close because we need to remove the DB from the pool
// when closing. | [
"Close",
"overrides",
"KeyValue",
".",
"Close",
"because",
"we",
"need",
"to",
"remove",
"the",
"DB",
"from",
"the",
"pool",
"when",
"closing",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/sorted/mysql/mysqlkv.go#L223-L228 |
31,478 | perkeep/perkeep | website/pk-web/email.go | emailOnTimeout | func emailOnTimeout(fnName string, d time.Duration, fn func() error) error {
c := make(chan error, 1)
go func() {
c <- fn()
}()
select {
case <-time.After(d):
log.Printf("timeout for %s, sending e-mail about it", fnName)
m := mailGun.NewMessage(
"noreply@perkeep.org",
"timeout for docker on pk-web",
... | go | func emailOnTimeout(fnName string, d time.Duration, fn func() error) error {
c := make(chan error, 1)
go func() {
c <- fn()
}()
select {
case <-time.After(d):
log.Printf("timeout for %s, sending e-mail about it", fnName)
m := mailGun.NewMessage(
"noreply@perkeep.org",
"timeout for docker on pk-web",
... | [
"func",
"emailOnTimeout",
"(",
"fnName",
"string",
",",
"d",
"time",
".",
"Duration",
",",
"fn",
"func",
"(",
")",
"error",
")",
"error",
"{",
"c",
":=",
"make",
"(",
"chan",
"error",
",",
"1",
")",
"\n",
"go",
"func",
"(",
")",
"{",
"c",
"<-",
... | // emailOnTimeout runs fn in a goroutine. If fn is not done after d,
// a message about fnName is logged, and an e-mail about it is sent. | [
"emailOnTimeout",
"runs",
"fn",
"in",
"a",
"goroutine",
".",
"If",
"fn",
"is",
"not",
"done",
"after",
"d",
"a",
"message",
"about",
"fnName",
"is",
"logged",
"and",
"an",
"e",
"-",
"mail",
"about",
"it",
"is",
"sent",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/website/pk-web/email.go#L207-L228 |
31,479 | perkeep/perkeep | pkg/blobserver/files/files.go | u32 | func u32(n int64) uint32 {
if n < 0 || n > math.MaxUint32 {
panic("bad size " + fmt.Sprint(n))
}
return uint32(n)
} | go | func u32(n int64) uint32 {
if n < 0 || n > math.MaxUint32 {
panic("bad size " + fmt.Sprint(n))
}
return uint32(n)
} | [
"func",
"u32",
"(",
"n",
"int64",
")",
"uint32",
"{",
"if",
"n",
"<",
"0",
"||",
"n",
">",
"math",
".",
"MaxUint32",
"{",
"panic",
"(",
"\"",
"\"",
"+",
"fmt",
".",
"Sprint",
"(",
"n",
")",
")",
"\n",
"}",
"\n",
"return",
"uint32",
"(",
"n",
... | // u32 converts n to an uint32, or panics if n is out of range | [
"u32",
"converts",
"n",
"to",
"an",
"uint32",
"or",
"panics",
"if",
"n",
"is",
"out",
"of",
"range"
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/files/files.go#L131-L136 |
31,480 | perkeep/perkeep | pkg/blobserver/files/files.go | fetch | func (ds *Storage) fetch(ctx context.Context, br blob.Ref, offset, length int64) (rc io.ReadCloser, size uint32, err error) {
// TODO: use ctx, if the os package ever supports that.
fileName := ds.blobPath(br)
stat, err := ds.fs.Stat(fileName)
if os.IsNotExist(err) {
return nil, 0, os.ErrNotExist
}
size = u32(s... | go | func (ds *Storage) fetch(ctx context.Context, br blob.Ref, offset, length int64) (rc io.ReadCloser, size uint32, err error) {
// TODO: use ctx, if the os package ever supports that.
fileName := ds.blobPath(br)
stat, err := ds.fs.Stat(fileName)
if os.IsNotExist(err) {
return nil, 0, os.ErrNotExist
}
size = u32(s... | [
"func",
"(",
"ds",
"*",
"Storage",
")",
"fetch",
"(",
"ctx",
"context",
".",
"Context",
",",
"br",
"blob",
".",
"Ref",
",",
"offset",
",",
"length",
"int64",
")",
"(",
"rc",
"io",
".",
"ReadCloser",
",",
"size",
"uint32",
",",
"err",
"error",
")",
... | // length -1 means entire file | [
"length",
"-",
"1",
"means",
"entire",
"file"
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/blobserver/files/files.go#L139-L178 |
31,481 | perkeep/perkeep | pkg/client/config.go | AddFlags | func AddFlags() {
defaultPath := "/x/y/z/we're/in-a-test"
if !buildinfo.TestingLinked() {
defaultPath = osutil.UserClientConfigPath()
}
flag.StringVar(&flagServer, "server", "", "Perkeep server prefix. If blank, the default from the \"server\" field of "+defaultPath+" is used. Acceptable forms: https://you.exampl... | go | func AddFlags() {
defaultPath := "/x/y/z/we're/in-a-test"
if !buildinfo.TestingLinked() {
defaultPath = osutil.UserClientConfigPath()
}
flag.StringVar(&flagServer, "server", "", "Perkeep server prefix. If blank, the default from the \"server\" field of "+defaultPath+" is used. Acceptable forms: https://you.exampl... | [
"func",
"AddFlags",
"(",
")",
"{",
"defaultPath",
":=",
"\"",
"\"",
"\n",
"if",
"!",
"buildinfo",
".",
"TestingLinked",
"(",
")",
"{",
"defaultPath",
"=",
"osutil",
".",
"UserClientConfigPath",
"(",
")",
"\n",
"}",
"\n",
"flag",
".",
"StringVar",
"(",
... | // AddFlags registers the "server" and "secret-keyring" string flags. | [
"AddFlags",
"registers",
"the",
"server",
"and",
"secret",
"-",
"keyring",
"string",
"flags",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L52-L59 |
31,482 | perkeep/perkeep | pkg/client/config.go | parseConfig | func (c *Client) parseConfig() {
if android.OnAndroid() {
panic("parseConfig should never have been called on Android")
}
if configDisabled {
panic("parseConfig should never have been called with CAMLI_DISABLE_CLIENT_CONFIG_FILE set")
}
configPath := osutil.UserClientConfigPath()
if _, err := wkfs.Stat(config... | go | func (c *Client) parseConfig() {
if android.OnAndroid() {
panic("parseConfig should never have been called on Android")
}
if configDisabled {
panic("parseConfig should never have been called with CAMLI_DISABLE_CLIENT_CONFIG_FILE set")
}
configPath := osutil.UserClientConfigPath()
if _, err := wkfs.Stat(config... | [
"func",
"(",
"c",
"*",
"Client",
")",
"parseConfig",
"(",
")",
"{",
"if",
"android",
".",
"OnAndroid",
"(",
")",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"configDisabled",
"{",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"... | // lazy config parsing when there's a known client already.
// The client c may be nil. | [
"lazy",
"config",
"parsing",
"when",
"there",
"s",
"a",
"known",
"client",
"already",
".",
"The",
"client",
"c",
"may",
"be",
"nil",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L84-L162 |
31,483 | perkeep/perkeep | pkg/client/config.go | convertToMultiServers | func convertToMultiServers(conf jsonconfig.Obj) (jsonconfig.Obj, error) {
server := conf.OptionalString("server", "")
if server == "" {
return nil, errors.New("could not convert config to multi-servers style: no \"server\" key found")
}
newConf := jsonconfig.Obj{
"servers": map[string]interface{}{
"server": ... | go | func convertToMultiServers(conf jsonconfig.Obj) (jsonconfig.Obj, error) {
server := conf.OptionalString("server", "")
if server == "" {
return nil, errors.New("could not convert config to multi-servers style: no \"server\" key found")
}
newConf := jsonconfig.Obj{
"servers": map[string]interface{}{
"server": ... | [
"func",
"convertToMultiServers",
"(",
"conf",
"jsonconfig",
".",
"Obj",
")",
"(",
"jsonconfig",
".",
"Obj",
",",
"error",
")",
"{",
"server",
":=",
"conf",
".",
"OptionalString",
"(",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"if",
"server",
"==",
"\"",
... | // convertToMultiServers takes an old style single-server client configuration and maps it to new a multi-servers configuration that is returned. | [
"convertToMultiServers",
"takes",
"an",
"old",
"style",
"single",
"-",
"server",
"client",
"configuration",
"and",
"maps",
"it",
"to",
"new",
"a",
"multi",
"-",
"servers",
"configuration",
"that",
"is",
"returned",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L172-L196 |
31,484 | perkeep/perkeep | pkg/client/config.go | printConfigChangeHelp | func printConfigChangeHelp(conf jsonconfig.Obj) {
// rename maps from old key names to the new ones.
// If there is no new one, the value is the empty string.
rename := map[string]string{
"keyId": "identity",
"publicKeyBlobref": "",
"selfPubKeyDir": "",
"secretRing": "identitySecretRing",... | go | func printConfigChangeHelp(conf jsonconfig.Obj) {
// rename maps from old key names to the new ones.
// If there is no new one, the value is the empty string.
rename := map[string]string{
"keyId": "identity",
"publicKeyBlobref": "",
"selfPubKeyDir": "",
"secretRing": "identitySecretRing",... | [
"func",
"printConfigChangeHelp",
"(",
"conf",
"jsonconfig",
".",
"Obj",
")",
"{",
"// rename maps from old key names to the new ones.",
"// If there is no new one, the value is the empty string.",
"rename",
":=",
"map",
"[",
"string",
"]",
"string",
"{",
"\"",
"\"",
":",
... | // printConfigChangeHelp checks if conf contains obsolete keys,
// and prints additional help in this case. | [
"printConfigChangeHelp",
"checks",
"if",
"conf",
"contains",
"obsolete",
"keys",
"and",
"prints",
"additional",
"help",
"in",
"this",
"case",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L200-L226 |
31,485 | perkeep/perkeep | pkg/client/config.go | getServer | func getServer() (string, error) {
if s := os.Getenv("CAMLI_SERVER"); s != "" {
return cleanServer(s)
}
if flagServer != "" {
if !isURLOrHostPort(flagServer) {
configOnce.Do(parseConfig)
serverConf, ok := config.Servers[flagServer]
if ok {
return serverConf.Server, nil
}
log.Printf("%q looks l... | go | func getServer() (string, error) {
if s := os.Getenv("CAMLI_SERVER"); s != "" {
return cleanServer(s)
}
if flagServer != "" {
if !isURLOrHostPort(flagServer) {
configOnce.Do(parseConfig)
serverConf, ok := config.Servers[flagServer]
if ok {
return serverConf.Server, nil
}
log.Printf("%q looks l... | [
"func",
"getServer",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"if",
"s",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
";",
"s",
"!=",
"\"",
"\"",
"{",
"return",
"cleanServer",
"(",
"s",
")",
"\n",
"}",
"\n",
"if",
"flagServer",
"!="... | // getServer returns the server's URL found either as a command-line flag,
// or as the default server in the config file. | [
"getServer",
"returns",
"the",
"server",
"s",
"URL",
"found",
"either",
"as",
"a",
"command",
"-",
"line",
"flag",
"or",
"as",
"the",
"default",
"server",
"in",
"the",
"config",
"file",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L269-L293 |
31,486 | perkeep/perkeep | pkg/client/config.go | SetupAuth | func (c *Client) SetupAuth() error {
if c.noExtConfig {
if c.authMode != nil {
if _, ok := c.authMode.(*auth.None); !ok {
return nil
}
}
return errors.New("client: noExtConfig set; auth should not be configured from config or env vars")
}
// env var takes precedence, but only if we're in dev mode or ... | go | func (c *Client) SetupAuth() error {
if c.noExtConfig {
if c.authMode != nil {
if _, ok := c.authMode.(*auth.None); !ok {
return nil
}
}
return errors.New("client: noExtConfig set; auth should not be configured from config or env vars")
}
// env var takes precedence, but only if we're in dev mode or ... | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetupAuth",
"(",
")",
"error",
"{",
"if",
"c",
".",
"noExtConfig",
"{",
"if",
"c",
".",
"authMode",
"!=",
"nil",
"{",
"if",
"_",
",",
"ok",
":=",
"c",
".",
"authMode",
".",
"(",
"*",
"auth",
".",
"None",
... | // SetupAuth sets the client's authMode. It tries from the environment first if we're on android or in dev mode, and then from the client configuration. | [
"SetupAuth",
"sets",
"the",
"client",
"s",
"authMode",
".",
"It",
"tries",
"from",
"the",
"environment",
"first",
"if",
"we",
"re",
"on",
"android",
"or",
"in",
"dev",
"mode",
"and",
"then",
"from",
"the",
"client",
"configuration",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L311-L346 |
31,487 | perkeep/perkeep | pkg/client/config.go | serverAuth | func serverAuth(server string) string {
configOnce.Do(parseConfig)
alias := config.Alias(server)
if alias == "" {
return ""
}
return config.Servers[alias].Auth
} | go | func serverAuth(server string) string {
configOnce.Do(parseConfig)
alias := config.Alias(server)
if alias == "" {
return ""
}
return config.Servers[alias].Auth
} | [
"func",
"serverAuth",
"(",
"server",
"string",
")",
"string",
"{",
"configOnce",
".",
"Do",
"(",
"parseConfig",
")",
"\n",
"alias",
":=",
"config",
".",
"Alias",
"(",
"server",
")",
"\n",
"if",
"alias",
"==",
"\"",
"\"",
"{",
"return",
"\"",
"\"",
"\... | // serverAuth returns the auth scheme for server from the config, or the empty string if the server was not found in the config. | [
"serverAuth",
"returns",
"the",
"auth",
"scheme",
"for",
"server",
"from",
"the",
"config",
"or",
"the",
"empty",
"string",
"if",
"the",
"server",
"was",
"not",
"found",
"in",
"the",
"config",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L349-L356 |
31,488 | perkeep/perkeep | pkg/client/config.go | SetupAuthFromString | func (c *Client) SetupAuthFromString(a string) error {
// TODO(mpl): review the one using that (pkg/blobserver/remote/remote.go)
var err error
c.authMode, err = auth.FromConfig(a)
return err
} | go | func (c *Client) SetupAuthFromString(a string) error {
// TODO(mpl): review the one using that (pkg/blobserver/remote/remote.go)
var err error
c.authMode, err = auth.FromConfig(a)
return err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SetupAuthFromString",
"(",
"a",
"string",
")",
"error",
"{",
"// TODO(mpl): review the one using that (pkg/blobserver/remote/remote.go)",
"var",
"err",
"error",
"\n",
"c",
".",
"authMode",
",",
"err",
"=",
"auth",
".",
"FromC... | // SetupAuthFromString configures the clients authentication mode from
// an explicit auth string. | [
"SetupAuthFromString",
"configures",
"the",
"clients",
"authentication",
"mode",
"from",
"an",
"explicit",
"auth",
"string",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L360-L365 |
31,489 | perkeep/perkeep | pkg/client/config.go | serverTrustedCerts | func (c *Client) serverTrustedCerts(server string) []string {
configOnce.Do(c.parseConfig)
if config == nil {
return nil
}
alias := config.Alias(server)
if alias == "" {
return nil
}
return config.Servers[alias].TrustedCerts
} | go | func (c *Client) serverTrustedCerts(server string) []string {
configOnce.Do(c.parseConfig)
if config == nil {
return nil
}
alias := config.Alias(server)
if alias == "" {
return nil
}
return config.Servers[alias].TrustedCerts
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"serverTrustedCerts",
"(",
"server",
"string",
")",
"[",
"]",
"string",
"{",
"configOnce",
".",
"Do",
"(",
"c",
".",
"parseConfig",
")",
"\n",
"if",
"config",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
... | // serverTrustedCerts returns the trusted certs for server from the config. | [
"serverTrustedCerts",
"returns",
"the",
"trusted",
"certs",
"for",
"server",
"from",
"the",
"config",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L463-L473 |
31,490 | perkeep/perkeep | pkg/client/config.go | newIgnoreChecker | func newIgnoreChecker(ignoredFiles []string) func(path string) (shouldIgnore bool) {
var fns []func(string) bool
// copy of ignoredFiles for us to mutate
ignFiles := append([]string(nil), ignoredFiles...)
for k, v := range ignFiles {
if strings.HasPrefix(v, filepath.FromSlash("~/")) {
ignFiles[k] = filepath.J... | go | func newIgnoreChecker(ignoredFiles []string) func(path string) (shouldIgnore bool) {
var fns []func(string) bool
// copy of ignoredFiles for us to mutate
ignFiles := append([]string(nil), ignoredFiles...)
for k, v := range ignFiles {
if strings.HasPrefix(v, filepath.FromSlash("~/")) {
ignFiles[k] = filepath.J... | [
"func",
"newIgnoreChecker",
"(",
"ignoredFiles",
"[",
"]",
"string",
")",
"func",
"(",
"path",
"string",
")",
"(",
"shouldIgnore",
"bool",
")",
"{",
"var",
"fns",
"[",
"]",
"func",
"(",
"string",
")",
"bool",
"\n\n",
"// copy of ignoredFiles for us to mutate",... | // newIgnoreChecker uses ignoredFiles to build and return a func that returns whether the file path argument should be ignored. See IsIgnoredFile for the ignore rules. | [
"newIgnoreChecker",
"uses",
"ignoredFiles",
"to",
"build",
"and",
"return",
"a",
"func",
"that",
"returns",
"whether",
"the",
"file",
"path",
"argument",
"should",
"be",
"ignored",
".",
"See",
"IsIgnoredFile",
"for",
"the",
"ignore",
"rules",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L502-L540 |
31,491 | perkeep/perkeep | pkg/client/config.go | hasDirPrefix | func hasDirPrefix(dirPrefix, fullpath string) bool {
if !strings.HasPrefix(fullpath, dirPrefix) {
return false
}
if len(fullpath) == len(dirPrefix) {
return true
}
if fullpath[len(dirPrefix)] == filepath.Separator {
return true
}
return false
} | go | func hasDirPrefix(dirPrefix, fullpath string) bool {
if !strings.HasPrefix(fullpath, dirPrefix) {
return false
}
if len(fullpath) == len(dirPrefix) {
return true
}
if fullpath[len(dirPrefix)] == filepath.Separator {
return true
}
return false
} | [
"func",
"hasDirPrefix",
"(",
"dirPrefix",
",",
"fullpath",
"string",
")",
"bool",
"{",
"if",
"!",
"strings",
".",
"HasPrefix",
"(",
"fullpath",
",",
"dirPrefix",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"if",
"len",
"(",
"fullpath",
")",
"==",
"le... | // hasDirPrefix reports whether the path has the provided directory prefix.
// Both should be absolute paths. | [
"hasDirPrefix",
"reports",
"whether",
"the",
"path",
"has",
"the",
"provided",
"directory",
"prefix",
".",
"Both",
"should",
"be",
"absolute",
"paths",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L561-L572 |
31,492 | perkeep/perkeep | pkg/client/config.go | hasComponent | func hasComponent(component, fullpath string) bool {
// trim Windows volume name
fullpath = strings.TrimPrefix(fullpath, filepath.VolumeName(fullpath))
for {
i := strings.Index(fullpath, component)
if i == -1 {
return false
}
if i != 0 && fullpath[i-1] == filepath.Separator {
componentEnd := i + len(co... | go | func hasComponent(component, fullpath string) bool {
// trim Windows volume name
fullpath = strings.TrimPrefix(fullpath, filepath.VolumeName(fullpath))
for {
i := strings.Index(fullpath, component)
if i == -1 {
return false
}
if i != 0 && fullpath[i-1] == filepath.Separator {
componentEnd := i + len(co... | [
"func",
"hasComponent",
"(",
"component",
",",
"fullpath",
"string",
")",
"bool",
"{",
"// trim Windows volume name",
"fullpath",
"=",
"strings",
".",
"TrimPrefix",
"(",
"fullpath",
",",
"filepath",
".",
"VolumeName",
"(",
"fullpath",
")",
")",
"\n",
"for",
"{... | // hasComponent returns whether the pathComponent is a path component of
// fullpath. i.e it is a part of fullpath that fits exactly between two path
// separators. | [
"hasComponent",
"returns",
"whether",
"the",
"pathComponent",
"is",
"a",
"path",
"component",
"of",
"fullpath",
".",
"i",
".",
"e",
"it",
"is",
"a",
"part",
"of",
"fullpath",
"that",
"fits",
"exactly",
"between",
"two",
"path",
"separators",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/pkg/client/config.go#L577-L597 |
31,493 | perkeep/perkeep | misc/release/make-release.go | genAll | func genAll() ([]string, error) {
zipSource()
for _, platform := range []string{"linux", "darwin", "windows"} {
genBinaries(platform)
packBinaries(platform)
}
getVersions()
return []string{
"perkeep-darwin.tar.gz",
"perkeep-linux.tar.gz",
"perkeep-src.zip",
"perkeep-windows.zip",
}, nil
} | go | func genAll() ([]string, error) {
zipSource()
for _, platform := range []string{"linux", "darwin", "windows"} {
genBinaries(platform)
packBinaries(platform)
}
getVersions()
return []string{
"perkeep-darwin.tar.gz",
"perkeep-linux.tar.gz",
"perkeep-src.zip",
"perkeep-windows.zip",
}, nil
} | [
"func",
"genAll",
"(",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"zipSource",
"(",
")",
"\n",
"for",
"_",
",",
"platform",
":=",
"range",
"[",
"]",
"string",
"{",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
"}",
"{",
"genBinaries"... | // genAll creates all the zips and tarballs, and returns their filenames. | [
"genAll",
"creates",
"all",
"the",
"zips",
"and",
"tarballs",
"and",
"returns",
"their",
"filenames",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/misc/release/make-release.go#L196-L209 |
31,494 | perkeep/perkeep | misc/release/make-release.go | getVersions | func getVersions() {
pkBin := filepath.Join(workDir, runtime.GOOS, "bin", "perkeepd")
cmd := exec.Command(pkBin, "-version")
var buf bytes.Buffer
cmd.Stderr = &buf
if err := cmd.Run(); err != nil {
log.Fatalf("Error getting version from perkeepd: %v, %v", err, buf.String())
}
sc := bufio.NewScanner(&buf)
for ... | go | func getVersions() {
pkBin := filepath.Join(workDir, runtime.GOOS, "bin", "perkeepd")
cmd := exec.Command(pkBin, "-version")
var buf bytes.Buffer
cmd.Stderr = &buf
if err := cmd.Run(); err != nil {
log.Fatalf("Error getting version from perkeepd: %v, %v", err, buf.String())
}
sc := bufio.NewScanner(&buf)
for ... | [
"func",
"getVersions",
"(",
")",
"{",
"pkBin",
":=",
"filepath",
".",
"Join",
"(",
"workDir",
",",
"runtime",
".",
"GOOS",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"pkBin",
",",
"\"",
"\"",
")",
"\n",... | // getVersions uses the freshly built perkeepd binary to get the Perkeep and Go
// versions used to build the release. | [
"getVersions",
"uses",
"the",
"freshly",
"built",
"perkeepd",
"binary",
"to",
"get",
"the",
"Perkeep",
"and",
"Go",
"versions",
"used",
"to",
"build",
"the",
"release",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/misc/release/make-release.go#L213-L241 |
31,495 | perkeep/perkeep | misc/release/make-release.go | zipSource | func zipSource() string {
cwd := filepath.Join(workDir, "src")
check(os.MkdirAll(cwd, 0755))
image := goDockerImage
args := []string{
"run",
"--rm",
"--volume=" + cwd + ":/OUT",
"--volume=" + path.Join(releaseDir, "zip-source.go") + ":" + zipSourceProgram + ":ro",
}
if isWIP() {
args = append(args, "--v... | go | func zipSource() string {
cwd := filepath.Join(workDir, "src")
check(os.MkdirAll(cwd, 0755))
image := goDockerImage
args := []string{
"run",
"--rm",
"--volume=" + cwd + ":/OUT",
"--volume=" + path.Join(releaseDir, "zip-source.go") + ":" + zipSourceProgram + ":ro",
}
if isWIP() {
args = append(args, "--v... | [
"func",
"zipSource",
"(",
")",
"string",
"{",
"cwd",
":=",
"filepath",
".",
"Join",
"(",
"workDir",
",",
"\"",
"\"",
")",
"\n",
"check",
"(",
"os",
".",
"MkdirAll",
"(",
"cwd",
",",
"0755",
")",
")",
"\n",
"image",
":=",
"goDockerImage",
"\n",
"arg... | // zipSource builds the zip archive that contains the source code of Perkeep. | [
"zipSource",
"builds",
"the",
"zip",
"archive",
"that",
"contains",
"the",
"source",
"code",
"of",
"Perkeep",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/misc/release/make-release.go#L378-L410 |
31,496 | perkeep/perkeep | misc/release/make-release.go | committers | func committers() (map[string]string, error) {
cmd := exec.Command("git", "shortlog", "-n", "-e", "-s", *flagStatsFrom+".."+revOrHEAD())
out, err := cmd.CombinedOutput()
if err != nil {
return nil, fmt.Errorf("%v; %v", err, string(out))
}
rxp := regexp.MustCompile(`^\s+(\d+)\s+(.*)<(.*)>.*$`)
sc := bufio.NewSca... | go | func committers() (map[string]string, error) {
cmd := exec.Command("git", "shortlog", "-n", "-e", "-s", *flagStatsFrom+".."+revOrHEAD())
out, err := cmd.CombinedOutput()
if err != nil {
return nil, fmt.Errorf("%v; %v", err, string(out))
}
rxp := regexp.MustCompile(`^\s+(\d+)\s+(.*)<(.*)>.*$`)
sc := bufio.NewSca... | [
"func",
"committers",
"(",
")",
"(",
"map",
"[",
"string",
"]",
"string",
",",
"error",
")",
"{",
"cmd",
":=",
"exec",
".",
"Command",
"(",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"\"",
"\"",
",",
"*",
"flagStatsFrom... | // returns commiters names mapped by e-mail, uniqued first by e-mail, then by name.
// When uniquing, higher count of commits wins. | [
"returns",
"commiters",
"names",
"mapped",
"by",
"e",
"-",
"mail",
"uniqued",
"first",
"by",
"e",
"-",
"mail",
"then",
"by",
"name",
".",
"When",
"uniquing",
"higher",
"count",
"of",
"commits",
"wins",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/misc/release/make-release.go#L690-L739 |
31,497 | perkeep/perkeep | misc/release/make-release.go | ProjectTokenSource | func ProjectTokenSource(proj string, scopes ...string) (oauth2.TokenSource, error) {
// TODO(bradfitz): try different strategies too, like
// three-legged flow if the service account doesn't exist, and
// then cache the token file on disk somewhere. Or maybe that should be an
// option, for environments without std... | go | func ProjectTokenSource(proj string, scopes ...string) (oauth2.TokenSource, error) {
// TODO(bradfitz): try different strategies too, like
// three-legged flow if the service account doesn't exist, and
// then cache the token file on disk somewhere. Or maybe that should be an
// option, for environments without std... | [
"func",
"ProjectTokenSource",
"(",
"proj",
"string",
",",
"scopes",
"...",
"string",
")",
"(",
"oauth2",
".",
"TokenSource",
",",
"error",
")",
"{",
"// TODO(bradfitz): try different strategies too, like",
"// three-legged flow if the service account doesn't exist, and",
"// ... | // ProjectTokenSource returns an OAuth2 TokenSource for the given Google Project ID. | [
"ProjectTokenSource",
"returns",
"an",
"OAuth2",
"TokenSource",
"for",
"the",
"given",
"Google",
"Project",
"ID",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/misc/release/make-release.go#L907-L926 |
31,498 | perkeep/perkeep | internal/hashutil/hashutil.go | SHA256Prefix | func SHA256Prefix(data []byte) string {
h := sha256.New()
h.Write(data)
return fmt.Sprintf("%x", h.Sum(nil))[:20]
} | go | func SHA256Prefix(data []byte) string {
h := sha256.New()
h.Write(data)
return fmt.Sprintf("%x", h.Sum(nil))[:20]
} | [
"func",
"SHA256Prefix",
"(",
"data",
"[",
"]",
"byte",
")",
"string",
"{",
"h",
":=",
"sha256",
".",
"New",
"(",
")",
"\n",
"h",
".",
"Write",
"(",
"data",
")",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"h",
".",
"Sum",
"(",
... | // SHA256Prefix computes the SHA-256 digest of data and returns
// its first twenty lowercase hex digits. | [
"SHA256Prefix",
"computes",
"the",
"SHA",
"-",
"256",
"digest",
"of",
"data",
"and",
"returns",
"its",
"first",
"twenty",
"lowercase",
"hex",
"digits",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/hashutil/hashutil.go#L32-L36 |
31,499 | perkeep/perkeep | internal/hashutil/hashutil.go | SHA1Prefix | func SHA1Prefix(data []byte) string {
h := sha1.New()
h.Write(data)
return fmt.Sprintf("%x", h.Sum(nil))[:20]
} | go | func SHA1Prefix(data []byte) string {
h := sha1.New()
h.Write(data)
return fmt.Sprintf("%x", h.Sum(nil))[:20]
} | [
"func",
"SHA1Prefix",
"(",
"data",
"[",
"]",
"byte",
")",
"string",
"{",
"h",
":=",
"sha1",
".",
"New",
"(",
")",
"\n",
"h",
".",
"Write",
"(",
"data",
")",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"h",
".",
"Sum",
"(",
"n... | // SHA1Prefix computes the SHA-1 digest of data and returns
// its first twenty lowercase hex digits. | [
"SHA1Prefix",
"computes",
"the",
"SHA",
"-",
"1",
"digest",
"of",
"data",
"and",
"returns",
"its",
"first",
"twenty",
"lowercase",
"hex",
"digits",
"."
] | e28bbbd1588d64df8ab7a82393afd39d64c061f7 | https://github.com/perkeep/perkeep/blob/e28bbbd1588d64df8ab7a82393afd39d64c061f7/internal/hashutil/hashutil.go#L40-L44 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.