_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q171000 | GetServiceService | validation | func (w *Widget) GetServiceService() string {
if w == nil || w.ServiceService == nil {
return ""
}
return *w.ServiceService
} | go | {
"resource": ""
} |
q171001 | GetServiceServiceOk | validation | func (w *Widget) GetServiceServiceOk() (string, bool) {
if w == nil || w.ServiceService == nil {
return "", false
}
return *w.ServiceService, true
} | go | {
"resource": ""
} |
q171002 | HasServiceService | validation | func (w *Widget) HasServiceService() bool {
if w != nil && w.ServiceService != nil {
return true
}
return false
} | go | {
"resource": ""
} |
q171003 | GetSizeVersion | validation | func (w *Widget) GetSizeVersion() string {
if w == nil || w.SizeVersion == nil {
return ""
}
return *w.SizeVersion
} | go | {
"resource": ""
} |
q171004 | GetSizeVersionOk | validation | func (w *Widget) GetSizeVersionOk() (string, bool) {
if w == nil || w.SizeVersion == nil {
return "", false
}
return *w.SizeVersion, true
} | go | {
"resource": ""
} |
q171005 | HasSizeVersion | validation | func (w *Widget) HasSizeVersion() bool {
if w != nil && w.SizeVersion != nil {
return true
}
return false
} | go | {
"resource": ""
} |
q171006 | GetTextSize | validation | func (w *Widget) GetTextSize() string {
if w == nil || w.TextSize == nil {
return ""
}
return *w.TextSize
} | go | {
"resource": ""
} |
q171007 | GetTextSizeOk | validation | func (w *Widget) GetTextSizeOk() (string, bool) {
if w == nil || w.TextSize == nil {
return "", false
}
return *w.TextSize, true
} | go | {
"resource": ""
} |
q171008 | HasTextSize | validation | func (w *Widget) HasTextSize() bool {
if w != nil && w.TextSize != nil {
return true
}
return false
} | go | {
"resource": ""
} |
q171009 | GetTick | validation | func (w *Widget) GetTick() bool {
if w == nil || w.Tick == nil {
return false
}
return *w.Tick
} | go | {
"resource": ""
} |
q171010 | GetTickOk | validation | func (w *Widget) GetTickOk() (bool, bool) {
if w == nil || w.Tick == nil {
return false, false
}
return *w.Tick, true
} | go | {
"resource": ""
} |
q171011 | HasTick | validation | func (w *Widget) HasTick() bool {
if w != nil && w.Tick != nil {
return true
}
return false
} | go | {
"resource": ""
} |
q171012 | GetTileDef | validation | func (w *Widget) GetTileDef() TileDef {
if w == nil || w.TileDef == nil {
return TileDef{}
}
return *w.TileDef
} | go | {
"resource": ""
} |
q171013 | GetTileDefOk | validation | func (w *Widget) GetTileDefOk() (TileDef, bool) {
if w == nil || w.TileDef == nil {
return TileDef{}, false
}
return *w.TileDef, true
} | go | {
"resource": ""
} |
q171014 | HasTileDef | validation | func (w *Widget) HasTileDef() bool {
if w != nil && w.TileDef != nil {
return true
}
return false
} | go | {
"resource": ""
} |
q171015 | GetTitleText | validation | func (w *Widget) GetTitleText() string {
if w == nil || w.TitleText == nil {
return ""
}
return *w.TitleText
} | go | {
"resource": ""
} |
q171016 | GetTitleTextOk | validation | func (w *Widget) GetTitleTextOk() (string, bool) {
if w == nil || w.TitleText == nil {
return "", false
}
return *w.TitleText, true
} | go | {
"resource": ""
} |
q171017 | HasTitleText | validation | func (w *Widget) HasTitleText() bool {
if w != nil && w.TitleText != nil {
return true
}
return false
} | go | {
"resource": ""
} |
q171018 | GetURL | validation | func (w *Widget) GetURL() string {
if w == nil || w.URL == nil {
return ""
}
return *w.URL
} | go | {
"resource": ""
} |
q171019 | GetURLOk | validation | func (w *Widget) GetURLOk() (string, bool) {
if w == nil || w.URL == nil {
return "", false
}
return *w.URL, true
} | go | {
"resource": ""
} |
q171020 | HasURL | validation | func (w *Widget) HasURL() bool {
if w != nil && w.URL != nil {
return true
}
return false
} | go | {
"resource": ""
} |
q171021 | GetCompute | validation | func (w *WidgetApmOrLogQuery) GetCompute() ApmOrLogQueryCompute {
if w == nil || w.Compute == nil {
return ApmOrLogQueryCompute{}
}
return *w.Compute
} | go | {
"resource": ""
} |
q171022 | GetComputeOk | validation | func (w *WidgetApmOrLogQuery) GetComputeOk() (ApmOrLogQueryCompute, bool) {
if w == nil || w.Compute == nil {
return ApmOrLogQueryCompute{}, false
}
return *w.Compute, true
} | go | {
"resource": ""
} |
q171023 | HasCompute | validation | func (w *WidgetApmOrLogQuery) HasCompute() bool {
if w != nil && w.Compute != nil {
return true
}
return false
} | go | {
"resource": ""
} |
q171024 | GetIndex | validation | func (w *WidgetApmOrLogQuery) GetIndex() string {
if w == nil || w.Index == nil {
return ""
}
return *w.Index
} | go | {
"resource": ""
} |
q171025 | GetIndexOk | validation | func (w *WidgetApmOrLogQuery) GetIndexOk() (string, bool) {
if w == nil || w.Index == nil {
return "", false
}
return *w.Index, true
} | go | {
"resource": ""
} |
q171026 | HasIndex | validation | func (w *WidgetApmOrLogQuery) HasIndex() bool {
if w != nil && w.Index != nil {
return true
}
return false
} | go | {
"resource": ""
} |
q171027 | GetSearch | validation | func (w *WidgetApmOrLogQuery) GetSearch() ApmOrLogQuerySearch {
if w == nil || w.Search == nil {
return ApmOrLogQuerySearch{}
}
return *w.Search
} | go | {
"resource": ""
} |
q171028 | GetSearchOk | validation | func (w *WidgetApmOrLogQuery) GetSearchOk() (ApmOrLogQuerySearch, bool) {
if w == nil || w.Search == nil {
return ApmOrLogQuerySearch{}, false
}
return *w.Search, true
} | go | {
"resource": ""
} |
q171029 | HasSearch | validation | func (w *WidgetApmOrLogQuery) HasSearch() bool {
if w != nil && w.Search != nil {
return true
}
return false
} | go | {
"resource": ""
} |
q171030 | GetHideValue | validation | func (w *WidgetConditionalFormat) GetHideValue() bool {
if w == nil || w.HideValue == nil {
return false
}
return *w.HideValue
} | go | {
"resource": ""
} |
q171031 | GetHideValueOk | validation | func (w *WidgetConditionalFormat) GetHideValueOk() (bool, bool) {
if w == nil || w.HideValue == nil {
return false, false
}
return *w.HideValue, true
} | go | {
"resource": ""
} |
q171032 | HasHideValue | validation | func (w *WidgetConditionalFormat) HasHideValue() bool {
if w != nil && w.HideValue != nil {
return true
}
return false
} | go | {
"resource": ""
} |
q171033 | GetImageUrl | validation | func (w *WidgetConditionalFormat) GetImageUrl() string {
if w == nil || w.ImageUrl == nil {
return ""
}
return *w.ImageUrl
} | go | {
"resource": ""
} |
q171034 | GetImageUrlOk | validation | func (w *WidgetConditionalFormat) GetImageUrlOk() (string, bool) {
if w == nil || w.ImageUrl == nil {
return "", false
}
return *w.ImageUrl, true
} | go | {
"resource": ""
} |
q171035 | HasImageUrl | validation | func (w *WidgetConditionalFormat) HasImageUrl() bool {
if w != nil && w.ImageUrl != nil {
return true
}
return false
} | go | {
"resource": ""
} |
q171036 | GetAliasName | validation | func (w *WidgetMetadata) GetAliasName() string {
if w == nil || w.AliasName == nil {
return ""
}
return *w.AliasName
} | go | {
"resource": ""
} |
q171037 | GetAliasNameOk | validation | func (w *WidgetMetadata) GetAliasNameOk() (string, bool) {
if w == nil || w.AliasName == nil {
return "", false
}
return *w.AliasName, true
} | go | {
"resource": ""
} |
q171038 | HasAliasName | validation | func (w *WidgetMetadata) HasAliasName() bool {
if w != nil && w.AliasName != nil {
return true
}
return false
} | go | {
"resource": ""
} |
q171039 | GetSearchBy | validation | func (w *WidgetProcessQuery) GetSearchBy() string {
if w == nil || w.SearchBy == nil {
return ""
}
return *w.SearchBy
} | go | {
"resource": ""
} |
q171040 | GetSearchByOk | validation | func (w *WidgetProcessQuery) GetSearchByOk() (string, bool) {
if w == nil || w.SearchBy == nil {
return "", false
}
return *w.SearchBy, true
} | go | {
"resource": ""
} |
q171041 | HasSearchBy | validation | func (w *WidgetProcessQuery) HasSearchBy() bool {
if w != nil && w.SearchBy != nil {
return true
}
return false
} | go | {
"resource": ""
} |
q171042 | GetIncludeUnits | validation | func (y *Yaxis) GetIncludeUnits() bool {
if y == nil || y.IncludeUnits == nil {
return false
}
return *y.IncludeUnits
} | go | {
"resource": ""
} |
q171043 | GetIncludeUnitsOk | validation | func (y *Yaxis) GetIncludeUnitsOk() (bool, bool) {
if y == nil || y.IncludeUnits == nil {
return false, false
}
return *y.IncludeUnits, true
} | go | {
"resource": ""
} |
q171044 | HasIncludeUnits | validation | func (y *Yaxis) HasIncludeUnits() bool {
if y != nil && y.IncludeUnits != nil {
return true
}
return false
} | go | {
"resource": ""
} |
q171045 | dump | validation | func (t *templateData) dump() error {
if len(t.Accessors) == 0 {
logf("No accessors for %v; skipping.", t.Filename)
return nil
}
// Sort accessors by ReceiverType.FieldName
sort.Sort(byName(t.Accessors))
var buf bytes.Buffer
if err := sourceTmpl.Execute(&buf, t); err != nil {
return err
}
clean, err := ... | go | {
"resource": ""
} |
q171046 | newAccessor | validation | func newAccessor(receiverType, fieldName, fieldType, zeroValue string) *accessor {
return &accessor{
sortVal: strings.ToLower(receiverType) + "." + strings.ToLower(fieldName),
ReceiverVar: strings.ToLower(receiverType[:1]),
ReceiverType: receiverType,
FieldName: fieldName,
FieldType: fieldType,
... | go | {
"resource": ""
} |
q171047 | addIdent | validation | func (t *templateData) addIdent(x *ast.Ident, receiverType, fieldName string) {
var zeroValue string
switch x.String() {
case "int":
zeroValue = "0"
case "string":
zeroValue = `""`
case "bool":
zeroValue = "false"
case "float64":
zeroValue = "0"
case "Status":
zeroValue = "0"
case "PrecisionT":
zero... | go | {
"resource": ""
} |
q171048 | addSelectorExpr | validation | func (t *templateData) addSelectorExpr(x *ast.SelectorExpr, receiverType, fieldName string) {
if strings.ToLower(fieldName[:1]) == fieldName[:1] { // non-exported field
return
}
var xX string
if xx, ok := x.X.(*ast.Ident); ok {
xX = xx.String()
}
switch xX {
case "time", "json":
if xX == "json" {
t.Im... | go | {
"resource": ""
} |
q171049 | addMapType | validation | func (t *templateData) addMapType(x *ast.MapType, receiverType, fieldName string) {
// TODO: should we make this dynamic? Could handle more cases than string only
var keyType string
switch key := x.Key.(type) {
case *ast.Ident:
keyType = key.String()
default:
logf("addMapType: type %q, field %q: unknown key ty... | go | {
"resource": ""
} |
q171050 | addArrayType | validation | func (t *templateData) addArrayType(x *ast.ArrayType, receiverType, fieldName string) {
// TODO: should we make this dynamic? Could handle more cases than string only
var eltType string
switch elt := x.Elt.(type) {
case *ast.Ident:
eltType = elt.String()
default:
logf("addArrayType: type %q, field %q: unknown ... | go | {
"resource": ""
} |
q171051 | CreateDowntime | validation | func (client *Client) CreateDowntime(downtime *Downtime) (*Downtime, error) {
var out Downtime
if err := client.doJsonRequest("POST", "/v1/downtime", downtime, &out); err != nil {
return nil, err
}
return &out, nil
} | go | {
"resource": ""
} |
q171052 | UpdateDowntime | validation | func (client *Client) UpdateDowntime(downtime *Downtime) error {
return client.doJsonRequest("PUT", fmt.Sprintf("/v1/downtime/%d", *downtime.Id),
downtime, nil)
} | go | {
"resource": ""
} |
q171053 | GetDowntime | validation | func (client *Client) GetDowntime(id int) (*Downtime, error) {
var out Downtime
if err := client.doJsonRequest("GET", fmt.Sprintf("/v1/downtime/%d", id), nil, &out); err != nil {
return nil, err
}
return &out, nil
} | go | {
"resource": ""
} |
q171054 | GetDowntimes | validation | func (client *Client) GetDowntimes() ([]Downtime, error) {
var out reqDowntimes
if err := client.doJsonRequest("GET", "/v1/downtime", nil, &out.Downtimes); err != nil {
return nil, err
}
return out.Downtimes, nil
} | go | {
"resource": ""
} |
q171055 | MarshalJSON | validation | func (k APIKey) MarshalJSON() ([]byte, error) {
// Approach for custom (un)marshalling borrowed from http://choly.ca/post/go-json-marshalling/
type Alias APIKey
return json.Marshal(&struct {
Created *string `json:"created,omitempty"`
*Alias
}{
Created: String(k.Created.Format(createdTimeLayout)),
Alias: (... | go | {
"resource": ""
} |
q171056 | UnmarshalJSON | validation | func (k *APIKey) UnmarshalJSON(data []byte) error {
type Alias APIKey
aux := &struct {
Created *string `json:"created,omitempty"`
*Alias
}{
Alias: (*Alias)(k),
}
if err := json.Unmarshal(data, &aux); err != nil {
return err
}
if created, err := time.Parse(createdTimeLayout, *aux.Created); err != nil {
... | go | {
"resource": ""
} |
q171057 | GetAPIKeys | validation | func (client *Client) GetAPIKeys() ([]APIKey, error) {
var out reqAPIKeys
if err := client.doJsonRequest("GET", "/v1/api_key", nil, &out); err != nil {
return nil, err
}
return out.APIKeys, nil
} | go | {
"resource": ""
} |
q171058 | GetAPIKey | validation | func (client *Client) GetAPIKey(key string) (*APIKey, error) {
var out reqAPIKey
if err := client.doJsonRequest("GET", fmt.Sprintf("/v1/api_key/%s", key), nil, &out); err != nil {
return nil, err
}
return out.APIKey, nil
} | go | {
"resource": ""
} |
q171059 | CreateAPIKey | validation | func (client *Client) CreateAPIKey(name string) (*APIKey, error) {
toPost := struct {
Name *string `json:"name,omitempty"`
}{
&name,
}
var out reqAPIKey
if err := client.doJsonRequest("POST", "/v1/api_key", toPost, &out); err != nil {
return nil, err
}
return out.APIKey, nil
} | go | {
"resource": ""
} |
q171060 | DeleteAPIKey | validation | func (client *Client) DeleteAPIKey(key string) error {
return client.doJsonRequest("DELETE", fmt.Sprintf("/v1/api_key/%s", key), nil, nil)
} | go | {
"resource": ""
} |
q171061 | PostMetrics | validation | func (client *Client) PostMetrics(series []Metric) error {
return client.doJsonRequest("POST", "/v1/series",
reqPostSeries{Series: series}, nil)
} | go | {
"resource": ""
} |
q171062 | GetScreenboard | validation | func (client *Client) GetScreenboard(id interface{}) (*Screenboard, error) {
stringId, err := GetStringId(id)
if err != nil {
return nil, err
}
out := &Screenboard{}
if err := client.doJsonRequest("GET", fmt.Sprintf("/v1/screen/%s", stringId), nil, out); err != nil {
return nil, err
}
return out, nil
} | go | {
"resource": ""
} |
q171063 | GetScreenboards | validation | func (client *Client) GetScreenboards() ([]*ScreenboardLite, error) {
var out reqGetScreenboards
if err := client.doJsonRequest("GET", "/v1/screen", nil, &out); err != nil {
return nil, err
}
return out.Screenboards, nil
} | go | {
"resource": ""
} |
q171064 | CreateScreenboard | validation | func (client *Client) CreateScreenboard(board *Screenboard) (*Screenboard, error) {
out := &Screenboard{}
if err := client.doJsonRequest("POST", "/v1/screen", board, out); err != nil {
return nil, err
}
return out, nil
} | go | {
"resource": ""
} |
q171065 | UpdateScreenboard | validation | func (client *Client) UpdateScreenboard(board *Screenboard) error {
return client.doJsonRequest("PUT", fmt.Sprintf("/v1/screen/%d", *board.Id), board, nil)
} | go | {
"resource": ""
} |
q171066 | ShareScreenboard | validation | func (client *Client) ShareScreenboard(id int, response *ScreenShareResponse) error {
return client.doJsonRequest("POST", fmt.Sprintf("/v1/screen/share/%d", id), nil, response)
} | go | {
"resource": ""
} |
q171067 | RevokeScreenboard | validation | func (client *Client) RevokeScreenboard(id int) error {
return client.doJsonRequest("DELETE", fmt.Sprintf("/v1/screen/share/%d", id), nil, nil)
} | go | {
"resource": ""
} |
q171068 | GetTags | validation | func (client *Client) GetTags(source string) (TagMap, error) {
var out reqGetTags
uri := "/v1/tags/hosts"
if source != "" {
uri += "?source=" + source
}
if err := client.doJsonRequest("GET", uri, nil, &out); err != nil {
return nil, err
}
return *out.Tags, nil
} | go | {
"resource": ""
} |
q171069 | GetHostTags | validation | func (client *Client) GetHostTags(host, source string) ([]string, error) {
var out reqGetHostTags
uri := "/v1/tags/hosts/" + host
if source != "" {
uri += "?source=" + source
}
if err := client.doJsonRequest("GET", uri, nil, &out); err != nil {
return nil, err
}
return out.Tags, nil
} | go | {
"resource": ""
} |
q171070 | AddTagsToHost | validation | func (client *Client) AddTagsToHost(host, source string, tags []string) error {
uri := "/v1/tags/hosts/" + host
if source != "" {
uri += "?source=" + source
}
return client.doJsonRequest("POST", uri, reqGetHostTags{Tags: tags}, nil)
} | go | {
"resource": ""
} |
q171071 | RemoveHostTags | validation | func (client *Client) RemoveHostTags(host, source string) error {
uri := "/v1/tags/hosts/" + host
if source != "" {
uri += "?source=" + source
}
return client.doJsonRequest("DELETE", uri, nil, nil)
} | go | {
"resource": ""
} |
q171072 | redactError | validation | func (client *Client) redactError(err error) error {
if err == nil {
return nil
}
errString := err.Error()
if len(client.apiKey) > 0 {
errString = strings.Replace(errString, client.apiKey, "redacted", -1)
}
if len(client.appKey) > 0 {
errString = strings.Replace(errString, client.appKey, "redacted", -1)
}... | go | {
"resource": ""
} |
q171073 | doRequestWithRetries | validation | func (client *Client) doRequestWithRetries(req *http.Request, maxTime time.Duration) (*http.Response, error) {
var (
err error
resp *http.Response
bo = backoff.NewExponentialBackOff()
body []byte
)
bo.MaxElapsedTime = maxTime
// Save the body for retries
if req.Body != nil {
body, err = ioutil.ReadA... | go | {
"resource": ""
} |
q171074 | PostEvent | validation | func (client *Client) PostEvent(event *Event) (*Event, error) {
var out reqGetEvent
if err := client.doJsonRequest("POST", "/v1/events", event, &out); err != nil {
return nil, err
}
return out.Event, nil
} | go | {
"resource": ""
} |
q171075 | GetEvent | validation | func (client *Client) GetEvent(id int) (*Event, error) {
var out reqGetEvent
if err := client.doJsonRequest("GET", fmt.Sprintf("/v1/events/%d", id), nil, &out); err != nil {
return nil, err
}
return out.Event, nil
} | go | {
"resource": ""
} |
q171076 | GetEvents | validation | func (client *Client) GetEvents(start, end int,
priority, sources, tags string) ([]Event, error) {
// Since this is a GET request, we need to build a query string.
vals := url.Values{}
vals.Add("start", strconv.Itoa(start))
vals.Add("end", strconv.Itoa(end))
if priority != "" {
vals.Add("priority", priority)
}... | go | {
"resource": ""
} |
q171077 | ViewMetricMetadata | validation | func (client *Client) ViewMetricMetadata(mn string) (*MetricMetadata, error) {
var out MetricMetadata
if err := client.doJsonRequest("GET", fmt.Sprintf("/v1/metrics/%s", mn), nil, &out); err != nil {
return nil, err
}
return &out, nil
} | go | {
"resource": ""
} |
q171078 | PostCheck | validation | func (client *Client) PostCheck(check Check) error {
return client.doJsonRequest("POST", "/v1/check_run",
check, nil)
} | go | {
"resource": ""
} |
q171079 | WriteObject | validation | func (t *bufferedObjectStream) WriteObject(obj interface{}) error {
t.mu.Lock()
defer t.mu.Unlock()
if err := t.codec.WriteObject(t.w, obj); err != nil {
return err
}
return t.w.Flush()
} | go | {
"resource": ""
} |
q171080 | ReadObject | validation | func (t *bufferedObjectStream) ReadObject(v interface{}) error {
return t.codec.ReadObject(t.r, v)
} | go | {
"resource": ""
} |
q171081 | SetParams | validation | func (r *Request) SetParams(v interface{}) error {
b, err := json.Marshal(v)
if err != nil {
return err
}
r.Params = (*json.RawMessage)(&b)
return nil
} | go | {
"resource": ""
} |
q171082 | SetMeta | validation | func (r *Request) SetMeta(v interface{}) error {
b, err := json.Marshal(v)
if err != nil {
return err
}
r.Meta = (*json.RawMessage)(&b)
return nil
} | go | {
"resource": ""
} |
q171083 | SetResult | validation | func (r *Response) SetResult(v interface{}) error {
b, err := json.Marshal(v)
if err != nil {
return err
}
r.Result = (*json.RawMessage)(&b)
return nil
} | go | {
"resource": ""
} |
q171084 | SetError | validation | func (e *Error) SetError(v interface{}) {
b, err := json.Marshal(v)
if err != nil {
panic("Error.SetData: " + err.Error())
}
e.Data = (*json.RawMessage)(&b)
} | go | {
"resource": ""
} |
q171085 | Close | validation | func (c *Conn) Close() error {
c.mu.Lock()
if c.shutdown || c.closing {
c.mu.Unlock()
return ErrClosed
}
c.closing = true
c.mu.Unlock()
return c.stream.Close()
} | go | {
"resource": ""
} |
q171086 | Reply | validation | func (c *Conn) Reply(ctx context.Context, id ID, result interface{}) error {
resp := &Response{ID: id}
if err := resp.SetResult(result); err != nil {
return err
}
_, err := c.send(ctx, &anyMessage{response: resp}, false)
return err
} | go | {
"resource": ""
} |
q171087 | ReplyWithError | validation | func (c *Conn) ReplyWithError(ctx context.Context, id ID, respErr *Error) error {
_, err := c.send(ctx, &anyMessage{response: &Response{ID: id, Error: respErr}}, false)
return err
} | go | {
"resource": ""
} |
q171088 | LogMessages | validation | func LogMessages(log Logger) ConnOpt {
return func(c *Conn) {
// Remember reqs we have received so we can helpfully show the
// request method in OnSend for responses.
var (
mu sync.Mutex
reqMethods = map[ID]string{}
)
OnRecv(func(req *Request, resp *Response) {
switch {
case req != nil ... | go | {
"resource": ""
} |
q171089 | HandlerWithError | validation | func HandlerWithError(handleFunc func(context.Context, *Conn, *Request) (result interface{}, err error)) *HandlerWithErrorConfigurer {
return &HandlerWithErrorConfigurer{handleFunc: handleFunc}
} | go | {
"resource": ""
} |
q171090 | Handle | validation | func (h *HandlerWithErrorConfigurer) Handle(ctx context.Context, conn *Conn, req *Request) {
result, err := h.handleFunc(ctx, conn, req)
if req.Notif {
if err != nil {
log.Printf("jsonrpc2 handler: notification %q handling error: %s", req.Method, err)
}
return
}
resp := &Response{ID: req.ID}
if err == ni... | go | {
"resource": ""
} |
q171091 | ReadObject | validation | func (t ObjectStream) ReadObject(v interface{}) error {
err := t.conn.ReadJSON(v)
if e, ok := err.(*websocket.CloseError); ok {
if e.Code == websocket.CloseAbnormalClosure && e.Text == io.ErrUnexpectedEOF.Error() {
// Suppress a noisy (but harmless) log message by
// unwrapping this error.
err = io.ErrUnex... | go | {
"resource": ""
} |
q171092 | PickID | validation | func PickID(id ID) CallOption {
return callOptionFunc(func(r *Request) error {
r.ID = id
return nil
})
} | go | {
"resource": ""
} |
q171093 | String | validation | func (me NodeAddr) String() string {
if me.Port == 0 {
return me.IP.String()
}
return net.JoinHostPort(me.IP.String(), strconv.FormatInt(int64(me.Port), 10))
} | go | {
"resource": ""
} |
q171094 | crcIP | validation | func crcIP(ip net.IP, rand uint8) uint32 {
if ip4 := ip.To4(); ip4 != nil {
ip = ip4
}
// Copy IP so we can make changes. Go sux at this.
ip = append(make(net.IP, 0, len(ip)), ip...)
mask := maskForIP(ip)
for i := range mask {
ip[i] &= mask[i]
}
r := rand & 7
ip[0] |= r << 5
return crc32.Checksum(ip[:len(... | go | {
"resource": ""
} |
q171095 | Stats | validation | func (s *Server) Stats() ServerStats {
s.mu.Lock()
defer s.mu.Unlock()
ss := s.stats
ss.GoodNodes = s.numGoodNodes()
ss.Nodes = s.numNodes()
ss.OutstandingTransactions = len(s.transactions)
return ss
} | go | {
"resource": ""
} |
q171096 | NewServer | validation | func NewServer(c *ServerConfig) (s *Server, err error) {
if c == nil {
c = &ServerConfig{
Conn: mustListen(":0"),
NoSecurity: true,
StartingNodes: GlobalBootstrapAddrs,
ConnectionTracking: conntrack.NewInstance(),
}
}
if c.Conn == nil {
return nil, errors.New("non-nil Con... | go | {
"resource": ""
} |
q171097 | SetIPBlockList | validation | func (s *Server) SetIPBlockList(list iplist.Ranger) {
s.mu.Lock()
defer s.mu.Unlock()
s.ipBlockList = list
} | go | {
"resource": ""
} |
q171098 | AddNode | validation | func (s *Server) AddNode(ni krpc.NodeInfo) error {
id := int160FromByteArray(ni.ID)
if id.IsZero() {
return s.Ping(ni.Addr.UDP(), nil)
}
_, err := s.getNode(NewAddr(ni.Addr.UDP()), int160FromByteArray(ni.ID), true)
return err
} | go | {
"resource": ""
} |
q171099 | getNode | validation | func (s *Server) getNode(addr Addr, id int160, tryAdd bool) (*node, error) {
if n := s.table.getNode(addr, id); n != nil {
return n, nil
}
n := &node{nodeKey: nodeKey{
id: id,
addr: addr,
}}
// Check that the node would be good to begin with. (It might have a bad
// ID or banned address, or we fucked up t... | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.