_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3 values | text stringlengths 52 85.5k | language stringclasses 1 value | meta_information dict |
|---|---|---|---|---|---|
q179600 | tmpl | test | func tmpl(w io.Writer, text string, data interface{}) {
t := template.New("top")
t.Funcs(template.FuncMap{
"trim": strings.TrimSpace,
"capitalize": capitalize,
})
template.Must(t.Parse(text))
ew := &errWriter{w: w}
err := t.Execute(ew, data)
if ew.err != nil {
// I/O error writing; ignore write on closed pipe
if strings.Contains(ew.err.Error(), "pipe") {
os.Exit(1)
}
fatalf("writing output: %v", ew.err)
}
if err != nil {
panic(err)
}
} | go | {
"resource": ""
} |
q179601 | printUsage | test | func printUsage(w io.Writer) {
bw := bufio.NewWriter(w)
tmpl(bw, usageTemplate, commands)
bw.Flush()
} | go | {
"resource": ""
} |
q179602 | FromRequest | test | func FromRequest(r *http.Request) string {
// Fetch header value
xRealIP := r.Header.Get("X-Real-Ip")
xForwardedFor := r.Header.Get("X-Forwarded-For")
// If both empty, return IP from remote address
if xRealIP == "" && xForwardedFor == "" {
var remoteIP string
// If there are colon in remote address, remove the port number
// otherwise, return remote address as is
if strings.ContainsRune(r.RemoteAddr, ':') {
remoteIP, _, _ = net.SplitHostPort(r.RemoteAddr)
} else {
remoteIP = r.RemoteAddr
}
return remoteIP
}
// Check list of IP in X-Forwarded-For and return the first global address
for _, address := range strings.Split(xForwardedFor, ",") {
address = strings.TrimSpace(address)
isPrivate, err := isPrivateAddress(address)
if !isPrivate && err == nil {
return address
}
}
// If nothing succeed, return X-Real-IP
return xRealIP
} | go | {
"resource": ""
} |
q179603 | Do | test | func (p *ClearParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandClear, p, nil)
} | go | {
"resource": ""
} |
q179604 | Do | test | func (p *DisableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDisable, nil, nil)
} | go | {
"resource": ""
} |
q179605 | Do | test | func (p *RemoveDOMStorageItemParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandRemoveDOMStorageItem, p, nil)
} | go | {
"resource": ""
} |
q179606 | Do | test | func (p *SetDOMStorageItemParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetDOMStorageItem, p, nil)
} | go | {
"resource": ""
} |
q179607 | Do | test | func (p *DeliverPushMessageParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDeliverPushMessage, p, nil)
} | go | {
"resource": ""
} |
q179608 | Do | test | func (p *DispatchSyncEventParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDispatchSyncEvent, p, nil)
} | go | {
"resource": ""
} |
q179609 | Do | test | func (p *InspectWorkerParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandInspectWorker, p, nil)
} | go | {
"resource": ""
} |
q179610 | Do | test | func (p *SetForceUpdateOnPageLoadParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetForceUpdateOnPageLoad, p, nil)
} | go | {
"resource": ""
} |
q179611 | Do | test | func (p *SkipWaitingParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSkipWaiting, p, nil)
} | go | {
"resource": ""
} |
q179612 | Do | test | func (p *StartWorkerParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStartWorker, p, nil)
} | go | {
"resource": ""
} |
q179613 | Do | test | func (p *StopAllWorkersParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStopAllWorkers, nil, nil)
} | go | {
"resource": ""
} |
q179614 | Do | test | func (p *StopWorkerParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStopWorker, p, nil)
} | go | {
"resource": ""
} |
q179615 | Do | test | func (p *UnregisterParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandUnregister, p, nil)
} | go | {
"resource": ""
} |
q179616 | Do | test | func (p *UpdateRegistrationParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandUpdateRegistration, p, nil)
} | go | {
"resource": ""
} |
q179617 | Do | test | func (p *BindParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandBind, p, nil)
} | go | {
"resource": ""
} |
q179618 | Do | test | func (p *UnbindParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandUnbind, p, nil)
} | go | {
"resource": ""
} |
q179619 | Error | test | func (e *ExceptionDetails) Error() string {
// TODO: watch script parsed events and match the ExceptionDetails.ScriptID
// to the name/location of the actual code and display here
return fmt.Sprintf("encountered exception '%s' (%d:%d)", e.Text, e.LineNumber, e.ColumnNumber)
} | go | {
"resource": ""
} |
q179620 | Do | test | func (p *ReleaseAnimationsParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandReleaseAnimations, p, nil)
} | go | {
"resource": ""
} |
q179621 | Do | test | func (p *SeekAnimationsParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSeekAnimations, p, nil)
} | go | {
"resource": ""
} |
q179622 | Do | test | func (p *SetPausedParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetPaused, p, nil)
} | go | {
"resource": ""
} |
q179623 | Do | test | func (p *SetPlaybackRateParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetPlaybackRate, p, nil)
} | go | {
"resource": ""
} |
q179624 | Do | test | func (p *SetTimingParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetTiming, p, nil)
} | go | {
"resource": ""
} |
q179625 | Do | test | func (p *PrepareForLeakDetectionParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandPrepareForLeakDetection, nil, nil)
} | go | {
"resource": ""
} |
q179626 | Do | test | func (p *ForciblyPurgeJavaScriptMemoryParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandForciblyPurgeJavaScriptMemory, nil, nil)
} | go | {
"resource": ""
} |
q179627 | Do | test | func (p *SetPressureNotificationsSuppressedParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetPressureNotificationsSuppressed, p, nil)
} | go | {
"resource": ""
} |
q179628 | Do | test | func (p *SimulatePressureNotificationParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSimulatePressureNotification, p, nil)
} | go | {
"resource": ""
} |
q179629 | WithSamplingInterval | test | func (p StartSamplingParams) WithSamplingInterval(samplingInterval int64) *StartSamplingParams {
p.SamplingInterval = samplingInterval
return &p
} | go | {
"resource": ""
} |
q179630 | WithSuppressRandomness | test | func (p StartSamplingParams) WithSuppressRandomness(suppressRandomness bool) *StartSamplingParams {
p.SuppressRandomness = suppressRandomness
return &p
} | go | {
"resource": ""
} |
q179631 | Do | test | func (p *StartSamplingParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStartSampling, p, nil)
} | go | {
"resource": ""
} |
q179632 | Do | test | func (p *StopSamplingParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStopSampling, nil, nil)
} | go | {
"resource": ""
} |
q179633 | Do | test | func (p *ClearDeviceOrientationOverrideParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandClearDeviceOrientationOverride, nil, nil)
} | go | {
"resource": ""
} |
q179634 | Do | test | func (p *SetDeviceOrientationOverrideParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetDeviceOrientationOverride, p, nil)
} | go | {
"resource": ""
} |
q179635 | Do | test | func (p *StartViolationsReportParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStartViolationsReport, p, nil)
} | go | {
"resource": ""
} |
q179636 | Do | test | func (p *StopViolationsReportParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStopViolationsReport, nil, nil)
} | go | {
"resource": ""
} |
q179637 | String | test | func (t Modifier) String() string {
switch t {
case ModifierNone:
return "None"
case ModifierAlt:
return "Alt"
case ModifierCtrl:
return "Ctrl"
case ModifierMeta:
return "Meta"
case ModifierShift:
return "Shift"
}
return fmt.Sprintf("Modifier(%d)", t)
} | go | {
"resource": ""
} |
q179638 | WithNodeID | test | func (p GetPartialAXTreeParams) WithNodeID(nodeID cdp.NodeID) *GetPartialAXTreeParams {
p.NodeID = nodeID
return &p
} | go | {
"resource": ""
} |
q179639 | WithBackendNodeID | test | func (p GetPartialAXTreeParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *GetPartialAXTreeParams {
p.BackendNodeID = backendNodeID
return &p
} | go | {
"resource": ""
} |
q179640 | WithObjectID | test | func (p GetPartialAXTreeParams) WithObjectID(objectID runtime.RemoteObjectID) *GetPartialAXTreeParams {
p.ObjectID = objectID
return &p
} | go | {
"resource": ""
} |
q179641 | WithFetchRelatives | test | func (p GetPartialAXTreeParams) WithFetchRelatives(fetchRelatives bool) *GetPartialAXTreeParams {
p.FetchRelatives = fetchRelatives
return &p
} | go | {
"resource": ""
} |
q179642 | Do | test | func (p *SetTimeDomainParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetTimeDomain, p, nil)
} | go | {
"resource": ""
} |
q179643 | WithClipRect | test | func (p ProfileSnapshotParams) WithClipRect(clipRect *dom.Rect) *ProfileSnapshotParams {
p.ClipRect = clipRect
return &p
} | go | {
"resource": ""
} |
q179644 | Do | test | func (p *ReleaseSnapshotParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandReleaseSnapshot, p, nil)
} | go | {
"resource": ""
} |
q179645 | Do | test | func (p *ClearObjectStoreParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandClearObjectStore, p, nil)
} | go | {
"resource": ""
} |
q179646 | Do | test | func (p *DeleteDatabaseParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDeleteDatabase, p, nil)
} | go | {
"resource": ""
} |
q179647 | Do | test | func (p *DeleteObjectStoreEntriesParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDeleteObjectStoreEntries, p, nil)
} | go | {
"resource": ""
} |
q179648 | WithKeyRange | test | func (p RequestDataParams) WithKeyRange(keyRange *KeyRange) *RequestDataParams {
p.KeyRange = keyRange
return &p
} | go | {
"resource": ""
} |
q179649 | Do | test | func (p *SetSamplingIntervalParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetSamplingInterval, p, nil)
} | go | {
"resource": ""
} |
q179650 | Do | test | func (p *StartParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStart, nil, nil)
} | go | {
"resource": ""
} |
q179651 | WithCallCount | test | func (p StartPreciseCoverageParams) WithCallCount(callCount bool) *StartPreciseCoverageParams {
p.CallCount = callCount
return &p
} | go | {
"resource": ""
} |
q179652 | WithDetailed | test | func (p StartPreciseCoverageParams) WithDetailed(detailed bool) *StartPreciseCoverageParams {
p.Detailed = detailed
return &p
} | go | {
"resource": ""
} |
q179653 | Do | test | func (p *StartPreciseCoverageParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStartPreciseCoverage, p, nil)
} | go | {
"resource": ""
} |
q179654 | Do | test | func (p *StartTypeProfileParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStartTypeProfile, nil, nil)
} | go | {
"resource": ""
} |
q179655 | Do | test | func (p *StopPreciseCoverageParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStopPreciseCoverage, nil, nil)
} | go | {
"resource": ""
} |
q179656 | Do | test | func (p *StopTypeProfileParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStopTypeProfile, nil, nil)
} | go | {
"resource": ""
} |
q179657 | Do | test | func (p *SetIgnoreCertificateErrorsParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetIgnoreCertificateErrors, p, nil)
} | go | {
"resource": ""
} |
q179658 | Do | test | func (p *AddInspectedHeapObjectParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandAddInspectedHeapObject, p, nil)
} | go | {
"resource": ""
} |
q179659 | Do | test | func (p *CollectGarbageParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandCollectGarbage, nil, nil)
} | go | {
"resource": ""
} |
q179660 | WithSamplingInterval | test | func (p StartSamplingParams) WithSamplingInterval(samplingInterval float64) *StartSamplingParams {
p.SamplingInterval = samplingInterval
return &p
} | go | {
"resource": ""
} |
q179661 | Do | test | func (p *StartTrackingHeapObjectsParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStartTrackingHeapObjects, p, nil)
} | go | {
"resource": ""
} |
q179662 | WithReportProgress | test | func (p StopTrackingHeapObjectsParams) WithReportProgress(reportProgress bool) *StopTrackingHeapObjectsParams {
p.ReportProgress = reportProgress
return &p
} | go | {
"resource": ""
} |
q179663 | Do | test | func (p *StopTrackingHeapObjectsParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandStopTrackingHeapObjects, p, nil)
} | go | {
"resource": ""
} |
q179664 | WithReportProgress | test | func (p TakeHeapSnapshotParams) WithReportProgress(reportProgress bool) *TakeHeapSnapshotParams {
p.ReportProgress = reportProgress
return &p
} | go | {
"resource": ""
} |
q179665 | Do | test | func (p *TakeHeapSnapshotParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandTakeHeapSnapshot, p, nil)
} | go | {
"resource": ""
} |
q179666 | WithBrowserContextID | test | func (p GrantPermissionsParams) WithBrowserContextID(browserContextID target.BrowserContextID) *GrantPermissionsParams {
p.BrowserContextID = browserContextID
return &p
} | go | {
"resource": ""
} |
q179667 | Do | test | func (p *GrantPermissionsParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandGrantPermissions, p, nil)
} | go | {
"resource": ""
} |
q179668 | WithBrowserContextID | test | func (p ResetPermissionsParams) WithBrowserContextID(browserContextID target.BrowserContextID) *ResetPermissionsParams {
p.BrowserContextID = browserContextID
return &p
} | go | {
"resource": ""
} |
q179669 | Do | test | func (p *ResetPermissionsParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandResetPermissions, p, nil)
} | go | {
"resource": ""
} |
q179670 | Do | test | func (p *CrashParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandCrash, nil, nil)
} | go | {
"resource": ""
} |
q179671 | Do | test | func (p *CrashGpuProcessParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandCrashGpuProcess, nil, nil)
} | go | {
"resource": ""
} |
q179672 | WithQuery | test | func (p GetHistogramsParams) WithQuery(query string) *GetHistogramsParams {
p.Query = query
return &p
} | go | {
"resource": ""
} |
q179673 | WithTargetID | test | func (p GetWindowForTargetParams) WithTargetID(targetID target.ID) *GetWindowForTargetParams {
p.TargetID = targetID
return &p
} | go | {
"resource": ""
} |
q179674 | Do | test | func (p *SetWindowBoundsParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetWindowBounds, p, nil)
} | go | {
"resource": ""
} |
q179675 | WithImage | test | func (p SetDockTileParams) WithImage(image string) *SetDockTileParams {
p.Image = image
return &p
} | go | {
"resource": ""
} |
q179676 | Do | test | func (p *SetDockTileParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetDockTile, p, nil)
} | go | {
"resource": ""
} |
q179677 | Do | test | func (p *DeleteCacheParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDeleteCache, p, nil)
} | go | {
"resource": ""
} |
q179678 | Do | test | func (p *DeleteEntryParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDeleteEntry, p, nil)
} | go | {
"resource": ""
} |
q179679 | WithPathFilter | test | func (p RequestEntriesParams) WithPathFilter(pathFilter string) *RequestEntriesParams {
p.PathFilter = pathFilter
return &p
} | go | {
"resource": ""
} |
q179680 | Do | test | func (p *DiscardSearchResultsParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDiscardSearchResults, p, nil)
} | go | {
"resource": ""
} |
q179681 | Do | test | func (p *FocusParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandFocus, p, nil)
} | go | {
"resource": ""
} |
q179682 | Do | test | func (p *MarkUndoableStateParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandMarkUndoableState, nil, nil)
} | go | {
"resource": ""
} |
q179683 | WithIncludeUserAgentShadowDOM | test | func (p PerformSearchParams) WithIncludeUserAgentShadowDOM(includeUserAgentShadowDOM bool) *PerformSearchParams {
p.IncludeUserAgentShadowDOM = includeUserAgentShadowDOM
return &p
} | go | {
"resource": ""
} |
q179684 | Do | test | func (p *RedoParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandRedo, nil, nil)
} | go | {
"resource": ""
} |
q179685 | Do | test | func (p *RemoveAttributeParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandRemoveAttribute, p, nil)
} | go | {
"resource": ""
} |
q179686 | Do | test | func (p *RemoveNodeParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandRemoveNode, p, nil)
} | go | {
"resource": ""
} |
q179687 | Do | test | func (p *RequestChildNodesParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandRequestChildNodes, p, nil)
} | go | {
"resource": ""
} |
q179688 | WithNodeID | test | func (p ResolveNodeParams) WithNodeID(nodeID cdp.NodeID) *ResolveNodeParams {
p.NodeID = nodeID
return &p
} | go | {
"resource": ""
} |
q179689 | WithBackendNodeID | test | func (p ResolveNodeParams) WithBackendNodeID(backendNodeID cdp.BackendNodeID) *ResolveNodeParams {
p.BackendNodeID = backendNodeID
return &p
} | go | {
"resource": ""
} |
q179690 | WithExecutionContextID | test | func (p ResolveNodeParams) WithExecutionContextID(executionContextID runtime.ExecutionContextID) *ResolveNodeParams {
p.ExecutionContextID = executionContextID
return &p
} | go | {
"resource": ""
} |
q179691 | Do | test | func (p *SetAttributeValueParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetAttributeValue, p, nil)
} | go | {
"resource": ""
} |
q179692 | WithName | test | func (p SetAttributesAsTextParams) WithName(name string) *SetAttributesAsTextParams {
p.Name = name
return &p
} | go | {
"resource": ""
} |
q179693 | Do | test | func (p *SetAttributesAsTextParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetAttributesAsText, p, nil)
} | go | {
"resource": ""
} |
q179694 | Do | test | func (p *SetFileInputFilesParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetFileInputFiles, p, nil)
} | go | {
"resource": ""
} |
q179695 | Do | test | func (p *SetInspectedNodeParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetInspectedNode, p, nil)
} | go | {
"resource": ""
} |
q179696 | Do | test | func (p *SetNodeValueParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetNodeValue, p, nil)
} | go | {
"resource": ""
} |
q179697 | Do | test | func (p *SetOuterHTMLParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandSetOuterHTML, p, nil)
} | go | {
"resource": ""
} |
q179698 | Do | test | func (p *UndoParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandUndo, nil, nil)
} | go | {
"resource": ""
} |
q179699 | Do | test | func (p *ForcePseudoStateParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandForcePseudoState, p, nil)
} | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.