query
stringlengths
7
3.85k
document
stringlengths
11
430k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
QueryWithdrawQuotas returns the users cryptocurrency withdraw quotas
func (h *HUOBI) QueryWithdrawQuotas(ctx context.Context, cryptocurrency string) (WithdrawQuota, error) { resp := struct { WithdrawQuota WithdrawQuota `json:"data"` }{} vals := url.Values{} vals.Set("currency", cryptocurrency) err := h.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, huobiAccountWithdrawQuota, vals, nil, &resp, true) if err != nil { return WithdrawQuota{}, err } return resp.WithdrawQuota, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func QueryWithdraws(rpcAddr string) http.HandlerFunc {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\trequest := common.GetInterxRequest(r)\n\t\tresponse := common.GetResponseFormat(request, rpcAddr)\n\t\tstatusCode := http.StatusOK\n\n\t\tcommon.GetLogger().Info(\"[query-withdraws] Entering withdra...
[ "0.6501903", "0.62330467", "0.5987337", "0.5910363", "0.5897883", "0.5802158", "0.5735387", "0.5701625", "0.56914574", "0.56089395", "0.5605273", "0.559851", "0.5584993", "0.55758", "0.5575501", "0.55489874", "0.5545602", "0.5539576", "0.55338687", "0.5519495", "0.5516642", ...
0.8049243
0
SearchForExistedWithdrawsAndDeposits returns withdrawal and deposit data
func (h *HUOBI) SearchForExistedWithdrawsAndDeposits(ctx context.Context, c currency.Code, transferType, direction string, fromID, limit int64) (WithdrawalHistory, error) { var resp WithdrawalHistory vals := url.Values{} vals.Set("type", transferType) if !c.IsEmpty() { vals.Set("currency", c.Lower().String()) } if direction != "" { vals.Set("direction", direction) } if fromID > 0 { vals.Set("from", strconv.FormatInt(fromID, 10)) } if limit > 0 { vals.Set("size", strconv.FormatInt(limit, 10)) } return resp, h.SendAuthenticatedHTTPRequest(ctx, exchange.RestSpot, http.MethodGet, huobiWithdrawHistory, vals, nil, &resp, false) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *Service) GetWithdraw(c context.Context, dateVersion string, from, limit int) (count int, withdrawVos []*model.WithdrawVo, err error) {\n\tcount, upAccounts, err := s.UpWithdraw(c, dateVersion, from, limit)\n\tif err != nil {\n\t\tlog.Error(\"s.UpWithdraw error(%v)\", err)\n\t\treturn\n\t}\n\n\tmids := mak...
[ "0.63003683", "0.62463695", "0.58435166", "0.5834678", "0.5790308", "0.57658595", "0.5760613", "0.5757181", "0.5652355", "0.56248325", "0.5602636", "0.5565634", "0.5551058", "0.5546448", "0.5528693", "0.55241525", "0.55012304", "0.54893017", "0.5451733", "0.5433997", "0.54177...
0.7214689
0
SendHTTPRequest sends an unauthenticated HTTP request
func (h *HUOBI) SendHTTPRequest(ctx context.Context, ep exchange.URL, path string, result interface{}) error { endpoint, err := h.API.Endpoints.GetURL(ep) if err != nil { return err } var tempResp json.RawMessage item := &request.Item{ Method: http.MethodGet, Path: endpoint + path, Result: &tempResp, Verbose: h.Verbose, HTTPDebugging: h.HTTPDebugging, HTTPRecording: h.HTTPRecording, } err = h.SendPayload(ctx, request.Unset, func() (*request.Item, error) { return item, nil }, request.UnauthenticatedRequest) if err != nil { return err } var errCap errorCapture if err := json.Unmarshal(tempResp, &errCap); err == nil { if errCap.ErrMsgType1 != "" { return fmt.Errorf("error code: %v error message: %s", errCap.CodeType1, errors.New(errCap.ErrMsgType1)) } if errCap.ErrMsgType2 != "" { return fmt.Errorf("error code: %v error message: %s", errCap.CodeType2, errors.New(errCap.ErrMsgType2)) } } return json.Unmarshal(tempResp, result) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func SendHTTPRequest(method, url, token string, body []byte) ([]byte, *http.Response, error) {\n\treq, err := http.NewRequest(method, url, bytes.NewBuffer(body))\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Add(\"Authorization\", fmt.Sprintf(\"Bearer %s\", token))\n\n\tclient := &http.Cl...
[ "0.61772037", "0.60453176", "0.5982576", "0.5896887", "0.5788983", "0.57063794", "0.57053524", "0.56688964", "0.56660306", "0.5622297", "0.55792046", "0.5493512", "0.54784316", "0.54572445", "0.54503506", "0.5448253", "0.5438047", "0.5422755", "0.53780687", "0.5362405", "0.53...
0.53575665
21
SendAuthenticatedHTTPRequest sends authenticated requests to the HUOBI API
func (h *HUOBI) SendAuthenticatedHTTPRequest(ctx context.Context, ep exchange.URL, method, endpoint string, values url.Values, data, result interface{}, isVersion2API bool) error { var err error creds, err := h.GetCredentials(ctx) if err != nil { return err } ePoint, err := h.API.Endpoints.GetURL(ep) if err != nil { return err } if values == nil { values = url.Values{} } interim := json.RawMessage{} newRequest := func() (*request.Item, error) { values.Set("AccessKeyId", creds.Key) values.Set("SignatureMethod", "HmacSHA256") values.Set("SignatureVersion", "2") values.Set("Timestamp", time.Now().UTC().Format("2006-01-02T15:04:05")) if isVersion2API { endpoint = "/v" + huobiAPIVersion2 + endpoint } else { endpoint = "/v" + huobiAPIVersion + endpoint } payload := fmt.Sprintf("%s\napi.huobi.pro\n%s\n%s", method, endpoint, values.Encode()) headers := make(map[string]string) if method == http.MethodGet { headers["Content-Type"] = "application/x-www-form-urlencoded" } else { headers["Content-Type"] = "application/json" } var hmac []byte hmac, err = crypto.GetHMAC(crypto.HashSHA256, []byte(payload), []byte(creds.Secret)) if err != nil { return nil, err } values.Set("Signature", crypto.Base64Encode(hmac)) urlPath := ePoint + common.EncodeURLValues(endpoint, values) var body []byte if data != nil { body, err = json.Marshal(data) if err != nil { return nil, err } } return &request.Item{ Method: method, Path: urlPath, Headers: headers, Body: bytes.NewReader(body), Result: &interim, Verbose: h.Verbose, HTTPDebugging: h.HTTPDebugging, HTTPRecording: h.HTTPRecording, }, nil } err = h.SendPayload(ctx, request.Unset, newRequest, request.AuthenticatedRequest) if err != nil { return err } if isVersion2API { var errCap ResponseV2 if err = json.Unmarshal(interim, &errCap); err == nil { if errCap.Code != 200 && errCap.Message != "" { return fmt.Errorf("%w error code: %v error message: %s", request.ErrAuthRequestFailed, errCap.Code, errCap.Message) } } } else { var errCap Response if err = json.Unmarshal(interim, &errCap); err == nil { if errCap.Status == huobiStatusError && errCap.ErrorMessage != "" { return fmt.Errorf("%w error code: %v error message: %s", request.ErrAuthRequestFailed, errCap.ErrorCode, errCap.ErrorMessage) } } } err = json.Unmarshal(interim, result) if err != nil { return common.AppendError(err, request.ErrAuthRequestFailed) } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (h *HUOBIHADAX) SendAuthenticatedHTTPRequest(method, endpoint string, values url.Values, result interface{}) error {\n\tif !h.AuthenticatedAPISupport {\n\t\treturn fmt.Errorf(exchange.WarningAuthenticatedRequestWithoutCredentialsSet, h.Name)\n\t}\n\n\tvalues.Set(\"AccessKeyId\", h.APIKey)\n\tvalues.Set(\"Sign...
[ "0.7415173", "0.7090839", "0.68118095", "0.67946285", "0.64851695", "0.6237729", "0.6094957", "0.60039806", "0.5994013", "0.5942896", "0.56280935", "0.55854416", "0.556091", "0.5519506", "0.5493864", "0.5493858", "0.546087", "0.54589224", "0.54501", "0.5440818", "0.5440324", ...
0.76494217
0
GetFee returns an estimate of fee based on type of transaction
func (h *HUOBI) GetFee(feeBuilder *exchange.FeeBuilder) (float64, error) { var fee float64 if feeBuilder.FeeType == exchange.OfflineTradeFee || feeBuilder.FeeType == exchange.CryptocurrencyTradeFee { fee = calculateTradingFee(feeBuilder.Pair, feeBuilder.PurchasePrice, feeBuilder.Amount) } if fee < 0 { fee = 0 } return fee, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (h *HitBTC) GetFee(ctx context.Context, feeBuilder *exchange.FeeBuilder) (float64, error) {\n\tvar fee float64\n\tswitch feeBuilder.FeeType {\n\tcase exchange.CryptocurrencyTradeFee:\n\t\tfeeInfo, err := h.GetFeeInfo(ctx,\n\t\t\tfeeBuilder.Pair.Base.String()+\n\t\t\t\tfeeBuilder.Pair.Delimiter+\n\t\t\t\tfeeBu...
[ "0.7427633", "0.73902583", "0.72759", "0.72617024", "0.722174", "0.7202637", "0.7101204", "0.7060723", "0.7043434", "0.7031177", "0.702849", "0.7016284", "0.70002353", "0.6979829", "0.69199574", "0.69199574", "0.69199574", "0.69199574", "0.69199574", "0.69199574", "0.68892753...
0.6914461
20
SetGaugeMetric func(name string, help string, env string, envValue string, version string, versionValue string) (prometheusGauge Gauge)
func SetGaugeMetric(name string, help string, env string, envValue string, version string, versionValue string) (prometheusGauge prometheus.Gauge) { var ( gaugeMetric = prometheus.NewGauge(prometheus.GaugeOpts{ Name: name, Help: help, ConstLabels: prometheus.Labels{env: envValue, version: versionValue}, }) ) return gaugeMetric }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (cm *customMetrics) SetGauge(gauge string, value float64) {\n\n\tcm.gauges[gauge].Set(value)\n}", "func (r *Reporter) Gauge(name string, value float64, tags metrics.Tags) (err error) {\n\tdefer func() {\n\t\tif r := recover(); r != nil {\n\t\t\terr = ErrPrometheusPanic\n\t\t}\n\t}()\n\n\tgauge := r.metrics....
[ "0.6838521", "0.6675083", "0.66375196", "0.6615935", "0.65820676", "0.6513595", "0.65016466", "0.64129496", "0.63703287", "0.63678575", "0.6307274", "0.62895155", "0.6248275", "0.6245103", "0.623869", "0.6179788", "0.61300707", "0.6121112", "0.61141324", "0.60184526", "0.5996...
0.8258457
0
/ import "github.com/01edu/z01" / import ( "fmt" )
func AlphaCount(str string) int { counter := 0 list := []byte(str) for _, letter := range list { if letter >= 65 && letter <= 90 || letter <= 122 && letter >= 97 { counter++ } } return counter }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func main() {\n\t_ := \"gitlab.com/username/library19\"\n\tfmt.Println(\"import \\\"gitlab.com/username/library20\\\"\")\n\tfmt.Println(\"import gitlab.com/username/library20)\n\n}", "func Imports() {\n\tfmt.Printf(\"Now you have %g problems.\\n\", math.Sqrt(7))\n}", "func main() {\n\tc, _ := d.BuildDigDepende...
[ "0.62175906", "0.6216425", "0.58148956", "0.5741799", "0.565565", "0.5636288", "0.5596986", "0.55647355", "0.5549735", "0.55264395", "0.550503", "0.549206", "0.545041", "0.54121274", "0.54022735", "0.53764904", "0.5369192", "0.53366244", "0.53361833", "0.53281826", "0.5312524...
0.0
-1
Sending information into channel. If we create large group the program will close before all information is sent. Using just 10 sends
func foo(c chan<- int) { // high := 100 // for i := 0; i < high; i++ { // c <- i // } c <- 10 }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func sendAll(count int, c chan int64) {\n\tfor i :=0; i < count; i++ {\n\t\tc <- 1\n\t}\n}", "func send(c chan int) {\n\tc <- 100\n\tfmt.Println(\"Sending data completed\")\n}", "func (c *connection) sendLoop() {\n\tc.group.Add(1)\n\tvar id int\n\tfor msg := range c.out {\n\t\ttime.Sleep(0)\n\t\tid = int(msg[0...
[ "0.6796055", "0.6710032", "0.6474751", "0.64737123", "0.6444497", "0.6394851", "0.6377518", "0.6331639", "0.6326792", "0.62756455", "0.621305", "0.61896396", "0.61523896", "0.6148293", "0.614084", "0.613628", "0.6135475", "0.6125786", "0.61161226", "0.6088589", "0.6087523", ...
0.0
-1
PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. freq: the time to wait between intervals in absence of a RetryAfter header. Allowed minimum is one second. A good starting value is 30 seconds. Note that some resources might benefit from a different value.
func (l AdaptiveNetworkHardeningsEnforcePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (AdaptiveNetworkHardeningsEnforceResponse, error) { respType := AdaptiveNetworkHardeningsEnforceResponse{} resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) if err != nil { return respType, err } respType.RawResponse = resp return respType, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (l WatchersClientGetTroubleshootingPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WatchersClientGetTroubleshootingResponse, error) {\n\trespType := WatchersClientGetTroubleshootingResponse{}\n\tresp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.TroubleshootingResult)\n\tif er...
[ "0.6259292", "0.6195853", "0.61802083", "0.6166713", "0.61609143", "0.61609143", "0.6154409", "0.6075394", "0.60710424", "0.60707647", "0.60615396", "0.6043415", "0.60430884", "0.60313463", "0.6021775", "0.6007862", "0.5998663", "0.59888476", "0.5980255", "0.595896", "0.59563...
0.0
-1
Resume rehydrates a AdaptiveNetworkHardeningsEnforcePollerResponse from the provided client and resume token.
func (l *AdaptiveNetworkHardeningsEnforcePollerResponse) Resume(ctx context.Context, client *AdaptiveNetworkHardeningsClient, token string) error { pt, err := armruntime.NewPollerFromResumeToken("AdaptiveNetworkHardeningsClient.Enforce", token, client.pl, client.enforceHandleError) if err != nil { return err } poller := &AdaptiveNetworkHardeningsEnforcePoller{ pt: pt, } resp, err := poller.Poll(ctx) if err != nil { return err } l.Poller = poller l.RawResponse = resp return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (l *WorkspaceManagedSQLServerEncryptionProtectorClientRevalidatePollerResponse) Resume(ctx context.Context, client *WorkspaceManagedSQLServerEncryptionProtectorClient, token string) error {\n\tpt, err := armruntime.NewPollerFromResumeToken(\"WorkspaceManagedSQLServerEncryptionProtectorClient.Revalidate\", tok...
[ "0.7977291", "0.78237575", "0.772744", "0.7726858", "0.7710988", "0.7694588", "0.7675609", "0.75921535", "0.7566447", "0.75447327", "0.75436836", "0.75272745", "0.7527257", "0.75233424", "0.75203735", "0.7513311", "0.7507816", "0.75030106", "0.74958706", "0.749215", "0.747994...
0.8376427
0
PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. freq: the time to wait between intervals in absence of a RetryAfter header. Allowed minimum is one second. A good starting value is 30 seconds. Note that some resources might benefit from a different value.
func (l AlertsSimulatePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (AlertsSimulateResponse, error) { respType := AlertsSimulateResponse{} resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) if err != nil { return respType, err } respType.RawResponse = resp return respType, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (l WatchersClientGetTroubleshootingPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WatchersClientGetTroubleshootingResponse, error) {\n\trespType := WatchersClientGetTroubleshootingResponse{}\n\tresp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.TroubleshootingResult)\n\tif er...
[ "0.62593186", "0.6195651", "0.61801505", "0.61666083", "0.61615384", "0.61615384", "0.61542344", "0.60752875", "0.6071086", "0.6070844", "0.6060712", "0.60435015", "0.6043004", "0.6030803", "0.6021779", "0.6008477", "0.5998286", "0.5988331", "0.5979664", "0.59588003", "0.5956...
0.591079
23
Resume rehydrates a AlertsSimulatePollerResponse from the provided client and resume token.
func (l *AlertsSimulatePollerResponse) Resume(ctx context.Context, client *AlertsClient, token string) error { pt, err := armruntime.NewPollerFromResumeToken("AlertsClient.Simulate", token, client.pl, client.simulateHandleError) if err != nil { return err } poller := &AlertsSimulatePoller{ pt: pt, } resp, err := poller.Poll(ctx) if err != nil { return err } l.Poller = poller l.RawResponse = resp return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (l *ApplicationGatewaysClientStartPollerResponse) Resume(ctx context.Context, client *ApplicationGatewaysClient, token string) error {\n\tpt, err := armruntime.NewPollerFromResumeToken(\"ApplicationGatewaysClient.Start\", token, client.pl)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpoller := &ApplicationGatew...
[ "0.7727089", "0.7702642", "0.7667797", "0.76061624", "0.7586481", "0.7535351", "0.75290906", "0.750984", "0.74973065", "0.7481278", "0.74666893", "0.7465214", "0.7454607", "0.74507034", "0.74507034", "0.7420852", "0.7406041", "0.7398732", "0.7377792", "0.73760927", "0.7366950...
0.7973928
0
PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. freq: the time to wait between intervals in absence of a RetryAfter header. Allowed minimum is one second. A good starting value is 30 seconds. Note that some resources might benefit from a different value.
func (l ServerVulnerabilityAssessmentDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (ServerVulnerabilityAssessmentDeleteResponse, error) { respType := ServerVulnerabilityAssessmentDeleteResponse{} resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) if err != nil { return respType, err } respType.RawResponse = resp return respType, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (l WatchersClientGetTroubleshootingPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (WatchersClientGetTroubleshootingResponse, error) {\n\trespType := WatchersClientGetTroubleshootingResponse{}\n\tresp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.TroubleshootingResult)\n\tif er...
[ "0.6259292", "0.6195853", "0.61802083", "0.6166713", "0.61609143", "0.61609143", "0.6154409", "0.6075394", "0.60710424", "0.60707647", "0.60615396", "0.6043415", "0.60430884", "0.60313463", "0.6021775", "0.6007862", "0.5998663", "0.59888476", "0.5980255", "0.595896", "0.59563...
0.0
-1
Resume rehydrates a ServerVulnerabilityAssessmentDeletePollerResponse from the provided client and resume token.
func (l *ServerVulnerabilityAssessmentDeletePollerResponse) Resume(ctx context.Context, client *ServerVulnerabilityAssessmentClient, token string) error { pt, err := armruntime.NewPollerFromResumeToken("ServerVulnerabilityAssessmentClient.Delete", token, client.pl, client.deleteHandleError) if err != nil { return err } poller := &ServerVulnerabilityAssessmentDeletePoller{ pt: pt, } resp, err := poller.Poll(ctx) if err != nil { return err } l.Poller = poller l.RawResponse = resp return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (l *VPNGatewaysClientDeletePollerResponse) Resume(ctx context.Context, client *VPNGatewaysClient, token string) error {\n\tpt, err := armruntime.NewPollerFromResumeToken(\"VPNGatewaysClient.Delete\", token, client.pl)\n\tif err != nil {\n\t\treturn err\n\t}\n\tpoller := &VPNGatewaysClientDeletePoller{\n\t\tpt...
[ "0.81951827", "0.81379056", "0.80936027", "0.8085295", "0.8065316", "0.8061482", "0.8058655", "0.8053732", "0.8043651", "0.8019985", "0.8019461", "0.8018657", "0.8012718", "0.8009122", "0.80089366", "0.80024755", "0.7994542", "0.7992985", "0.7992747", "0.79916984", "0.7982053...
0.8414383
0
UnmarshalJSON implements the json.Unmarshaller interface for type SettingsGetResult.
func (s *SettingsGetResult) UnmarshalJSON(data []byte) error { res, err := unmarshalSettingClassification(data) if err != nil { return err } s.SettingClassification = res return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (p *ProductSettingsClientGetResult) UnmarshalJSON(data []byte) error {\n\tres, err := unmarshalSettingsClassification(data)\n\tif err != nil {\n\t\treturn err\n\t}\n\tp.SettingsClassification = res\n\treturn nil\n}", "func (s *SettingsUpdateResult) UnmarshalJSON(data []byte) error {\n\tres, err := unmarshal...
[ "0.6875413", "0.6686578", "0.62999934", "0.5880715", "0.58680254", "0.5806092", "0.57214934", "0.5703393", "0.5693801", "0.5664528", "0.5656249", "0.5615088", "0.5578815", "0.5578258", "0.55728483", "0.55662054", "0.55587554", "0.55584365", "0.55446297", "0.554454", "0.552927...
0.7434199
0
UnmarshalJSON implements the json.Unmarshaller interface for type SettingsUpdateResult.
func (s *SettingsUpdateResult) UnmarshalJSON(data []byte) error { res, err := unmarshalSettingClassification(data) if err != nil { return err } s.SettingClassification = res return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (p *ProductSettingsClientUpdateResult) UnmarshalJSON(data []byte) error {\n\tres, err := unmarshalSettingsClassification(data)\n\tif err != nil {\n\t\treturn err\n\t}\n\tp.SettingsClassification = res\n\treturn nil\n}", "func (s *SettingsGetResult) UnmarshalJSON(data []byte) error {\n\tres, err := unmarshal...
[ "0.7052551", "0.66646963", "0.6281283", "0.627407", "0.61887354", "0.61412156", "0.6101325", "0.6062967", "0.60167694", "0.60028285", "0.59863514", "0.5935965", "0.58691716", "0.58244735", "0.58145964", "0.5798269", "0.579495", "0.5794271", "0.57862407", "0.578138", "0.576284...
0.74987465
0
Test that status transitions from Inactive to Active, once the start time is reached
func TestActivation(t *testing.T) { mockclock := clock.NewMock() setClock(mockclock) // replace clock with mock for speedy testing now := mockclock.Now() reset() p, _ := New("Promo1", now.Add(1*time.Hour), now.Add(24*time.Hour)) runtime.Gosched() if res := p.AllowDisplay(ip); res != false { t.Errorf("Bad Promo status, got: %v want %v", res, false) } // wind clock forward until after start time; enter display period mockclock.Add(2 * time.Hour) if res := p.AllowDisplay(ip); res != true { t.Errorf("Bad Promo status, got: %v want %v", res, true) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (pas *PodAutoscalerStatus) inStatusFor(status corev1.ConditionStatus, now time.Time) time.Duration {\n\tcond := pas.GetCondition(PodAutoscalerConditionActive)\n\tif cond == nil || cond.Status != status {\n\t\treturn -1\n\t}\n\treturn now.Sub(cond.LastTransitionTime.Inner.Time)\n}", "func (v *ObservabilityVe...
[ "0.6315328", "0.5751217", "0.5707817", "0.57021505", "0.5679295", "0.5671448", "0.56645894", "0.56333077", "0.5627383", "0.56199175", "0.56196296", "0.55565387", "0.5556034", "0.553161", "0.5514312", "0.54835093", "0.54337984", "0.53858835", "0.5380496", "0.537922", "0.537194...
0.5440705
16
Test that status transitions from Active to Expired, once the end time is reached
func TestExpiration(t *testing.T) { mockclock := clock.NewMock() setClock(mockclock) // replace clock with mock for speedy testing now := mockclock.Now() reset() p, _ := New("Promo1", now, now.Add(1*time.Hour)) runtime.Gosched() if res := p.AllowDisplay(ip); res != true { t.Errorf("Bad Promo status, got: %v want %v", res, true) } // wind clock forward until after display period mockclock.Add(1*time.Hour + 1*time.Second) if res := p.AllowDisplay(ip); res != false { t.Errorf("Bad Promo status, got: %v want %v", res, false) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (_TrialRulesAbstract *TrialRulesAbstractTransactor) Expired(opts *bind.TransactOpts, caseId [32]byte, status uint8) (*types.Transaction, error) {\n\treturn _TrialRulesAbstract.contract.Transact(opts, \"expired\", caseId, status)\n}", "func TestExpiration(t *testing.T) {\n\tr := NewRegistrar()\n\tr.Add(sessi...
[ "0.58127785", "0.5769869", "0.5630366", "0.5617064", "0.56041414", "0.5535202", "0.5517026", "0.5507166", "0.5478939", "0.54784715", "0.54395", "0.54349065", "0.54201555", "0.5401868", "0.5392047", "0.53748745", "0.5346386", "0.5321631", "0.53121084", "0.53112787", "0.5302717...
0.5692739
2
Test that an initially expired promo may not be displayed
func TestPreExpired(t *testing.T) { var tm time.Time // initial value is in the past reset() p, _ := New("Promo1", tm, tm) if res := p.AllowDisplay(ip); res != false { t.Errorf("Bad Promo status, got: %v want %v", res, false) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestExpiration(t *testing.T) {\n\tmockclock := clock.NewMock()\n\tsetClock(mockclock) // replace clock with mock for speedy testing\n\n\tnow := mockclock.Now()\n\treset()\n\tp, _ := New(\"Promo1\", now, now.Add(1*time.Hour))\n\n\truntime.Gosched()\n\n\tif res := p.AllowDisplay(ip); res != true {\n\t\tt.Errorf...
[ "0.7152463", "0.61216784", "0.5975197", "0.59364676", "0.59358203", "0.59336835", "0.5894708", "0.58882517", "0.57942945", "0.57901603", "0.57711214", "0.57444674", "0.5736263", "0.5717031", "0.5687377", "0.5684727", "0.56167704", "0.5595198", "0.55641276", "0.55085486", "0.5...
0.7433115
0
Callback sends the CallbackRequest type to the configured StatusCallbackUrl. If it fails to deliver in n attempts or the request is invalid it will return an error.
func Callback(cbReq *CallbackRequest, opts *CallbackOptions) error { client := opts.Client if client == nil { client = http.DefaultClient } buf := bytes.NewBuffer(nil) err := json.NewEncoder(buf).Encode(cbReq) if err != nil { return err } signature, err := opts.Signer.Sign(buf.Bytes()) if err != nil { return err } req, err := http.NewRequest("POST", cbReq.StatusCallbackUrl, buf) if err != nil { return err } req.Header.Set("X-OpenGDPR-Processor-Domain", opts.ProcessorDomain) req.Header.Set("X-OpenGDPR-Signature", signature) // Attempt to make callback for i := 0; i < opts.MaxAttempts; i++ { resp, err := client.Do(req) if err != nil || resp.StatusCode != 200 { time.Sleep(opts.Backoff) continue } // Success return nil } return fmt.Errorf("callback timed out for %s", cbReq.StatusCallbackUrl) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (client *Client) ServiceStatusWithCallback(request *ServiceStatusRequest, callback func(response *ServiceStatusResponse, err error)) (<-chan int) {\nresult := make(chan int, 1)\nerr := client.AddAsyncTask(func() {\nvar response *ServiceStatusResponse\nvar err error\ndefer close(result)\nresponse, err = client...
[ "0.5872548", "0.57046133", "0.55930907", "0.5435281", "0.5425485", "0.5421743", "0.53905284", "0.5348863", "0.5294707", "0.5120781", "0.50986767", "0.50361735", "0.5031683", "0.5016335", "0.50109285", "0.50042754", "0.49984872", "0.49728155", "0.48938978", "0.4870915", "0.485...
0.6648428
0
Add indexes into MongoDB
func addIndexes() { var err error ufIndex1 := mgo.Index{ Key: []string{"codigo"}, Unique: true, Background: true, Sparse: true, } municipioIndex1 := mgo.Index{ Key: []string{"codigo"}, Unique: true, Background: true, Sparse: true, } // Add indexes into MongoDB session := Session.Copy() defer session.Close() ufCol := session.DB(commons.AppConfig.Database).C("ufs") municipioCol := session.DB(commons.AppConfig.Database).C("municipios") // cria indice codigo para UF err = ufCol.EnsureIndex(ufIndex1) if err != nil { log.Fatalf("[addIndexes]: %s\n", err) } log.Println("Indice para UF criado com sucesso") // cria indice codigo para Municipio err = municipioCol.EnsureIndex(municipioIndex1) if err != nil { log.Fatalf("[addIndexes]: %s\n", err) } log.Println("Indice para Municipio criado com sucesso") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func addIndexes() {\n\tvar err error\n\tuserIndex := mgo.Index{\n\t\tKey: []string{\"email\"},\n\t\tUnique: true,\n\t\tBackground: true,\n\t\tSparse: true,\n\t}\n\n\tauthIndex := mgo.Index{\n\t\tKey: []string{\"sender_id\"},\n\t\tUnique: true,\n\t\tBackground: true,\n\t\tSparse: true,...
[ "0.804923", "0.78490174", "0.7118752", "0.70991796", "0.7068827", "0.69319904", "0.6840407", "0.6802941", "0.6791201", "0.6669298", "0.66180503", "0.6590874", "0.6555461", "0.6504994", "0.6485711", "0.64855134", "0.6479472", "0.63830847", "0.63748515", "0.63636535", "0.632665...
0.7907395
1
Close closes a mgo.Session value. Used to add defer statements for closing the copied session.
func (ds *DataStore) Close() { ds.MongoSession.Close() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Close(session *mgo.Session) {\n\tsession.Close()\n\t}", "func SessionClose(testingInstance TestingInstance, session *discordgo.Session) {\n\terr := session.Close()\n\tif err != nil {\n\t\ttestingInstance.Error(err)\n\t}\n}", "func (sp *SessionProxy) Close() error { return sp.GetSession().Close() }", "fu...
[ "0.71127445", "0.6988447", "0.6953739", "0.68764406", "0.6822951", "0.6751179", "0.6730526", "0.6690702", "0.6605853", "0.6533115", "0.65138006", "0.6497762", "0.6476485", "0.64715266", "0.6440591", "0.637412", "0.631042", "0.6295334", "0.6289746", "0.62867993", "0.62823224",...
0.0
-1
Collection returns mgo.collection for the given name
func (ds *DataStore) Collection(name string) *mgo.Collection { return ds.MongoSession.DB(commons.AppConfig.Database).C(name) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func GetCollection(name string) *mgo.Collection {\n\treturn DB.C(name)\n}", "func C(name string) *mgo.Collection {\n return Db.C(name)\n}", "func (m *MongoDB) C(name string) *mgo.Collection {\n\treturn m.db.C(name)\n}", "func (m *MongoDB) Collection(name string) (*mongo.Collection, error) {\n\tcoll, ok :=...
[ "0.7958804", "0.79391026", "0.73163956", "0.73108506", "0.73050374", "0.72839034", "0.7242758", "0.72282404", "0.7102441", "0.70284396", "0.70057887", "0.69019735", "0.68647474", "0.6844251", "0.6840011", "0.683378", "0.68303245", "0.6718207", "0.66450536", "0.6634506", "0.66...
0.7683345
2
NewDataStore creates a new DataStore object to be used for each HTTP request.
func NewDataStore() *DataStore { session := Session.Copy() dataStore := &DataStore{ MongoSession: session, } return dataStore }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewDataStore() *DataStore {\n\treturn &DataStore{}\n}", "func newDataStore() *dataStore {\n\tds := dataStore{\n\t\tdata: make(map[string]Info),\n\t}\n\treturn &ds\n}", "func NewDataStore(db neo4j.Driver) DataStore {\n\tif store == nil {\n\t\tstore = &dataStore{db: db}\n\t}\n\n\treturn store\n}", "func N...
[ "0.82330394", "0.809883", "0.7739795", "0.7739755", "0.755764", "0.7512227", "0.7293508", "0.7257735", "0.71911937", "0.71226996", "0.69651943", "0.6802696", "0.6616057", "0.65748113", "0.649016", "0.64899117", "0.6447895", "0.64251417", "0.64111", "0.6393936", "0.6374082", ...
0.7506629
6
InitializeDB creates a DB connection from the provided configuration
func InitDB(pgConf *config.PostgresConf) (Datastore, error) { dbDSN := fmt.Sprintf("postgres://%s@%s:%d/%s?sslmode=disable", pgConf.DBUser, pgConf.DBServer, pgConf.DBPort, pgConf.DBName) db, err := gorm.Open(postgres.New(postgres.Config{DSN: dbDSN}), &gorm.Config{NamingStrategy: schema.NamingStrategy{SingularTable: true}}) if err != nil { sentry.CaptureException(err) return nil, err } log.Info("Database connection successful") return &Database{db}, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func InitializeDatabase(config string, log debug.Logger) {\n\tdatabaseAccess = databaseConnection{dbconfig: config, log: log}\n\tdatabaseAccess.initialize()\n}", "func InitializeDB() error {\n\tdsn := fmt.Sprintf(\"user=%s password=%s dbname=%s host=%s port=%s sslmode=disable\",\n\t\tconfig.C.Database.Postgres.P...
[ "0.7442992", "0.73547006", "0.72342485", "0.719802", "0.7148712", "0.7128819", "0.7119498", "0.71033305", "0.70790875", "0.7067338", "0.7016216", "0.69800913", "0.68921584", "0.6888181", "0.6864967", "0.6860298", "0.6841143", "0.682902", "0.6818211", "0.6807455", "0.6797582",...
0.6857958
16
Init Create DB tables
func (db *Database) CreateDBTable() error { if err := db.DbConn.AutoMigrate(&models.Holiday{}); err != nil { return err } if err := db.DbConn.AutoMigrate(&models.BSE_BHAV{}); err != nil { return err } if err := db.DbConn.AutoMigrate(&models.Order{}); err != nil { return err } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (db database) Init() error {\n\tscript := `CREATE TABLE IF NOT EXISTS txs (\n\t\thash VARCHAR NOT NULL PRIMARY KEY,\n\t\tstatus SMALLINT,\n\t\tcreated_time BIGINT,\n\t\tselector VARCHAR(255),\n\t\ttxid VARCHAR,\n\t\ttxindex BIGINT,\n\t\tamount...
[ "0.7706803", "0.7667855", "0.76524407", "0.7566775", "0.7562417", "0.74877805", "0.7485864", "0.7475944", "0.73747253", "0.7373994", "0.7367066", "0.723283", "0.72112584", "0.7204502", "0.7166722", "0.712205", "0.71092635", "0.708194", "0.70771164", "0.7050126", "0.70442826",...
0.6555467
73
NewAccessTokenHandlerFactory return new fake access token handler factory
func NewAccessTokenHandlerFactory(userIDFactory UserIDFactory) middleware.AccessTokenHandlerFactory { return &accessTokenHandlerFactory{ userIDFactory: userIDFactory, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewHandler(service services.Service) AccessTokenHandler {\n\treturn &accessTokenhandler{\n\t\tservice: service,\n\t}\n\n}", "func accessTokenHandlerConfig(oasvr *osin.Server) func(w http.ResponseWriter, r *http.Request) {\n\treturn func(w http.ResponseWriter, r *http.Request) {\n\t\tdbg.Println(\"Token star...
[ "0.6828804", "0.6349177", "0.63403344", "0.60474855", "0.6034249", "0.5923264", "0.59155315", "0.5915281", "0.58693445", "0.5771537", "0.5720014", "0.570903", "0.56361717", "0.5632971", "0.5632587", "0.5615423", "0.56022596", "0.55027896", "0.54784465", "0.54771185", "0.54516...
0.7244731
0
/ go run extended.go foo peter w bla everybody c=12 else Hello peter, how is the bla? Say hello to everybody Say hello to else You can count real high! Custom 1: bar2 Custom 2: bar1
func setStyle(style string, c *clif.Cli) { switch style { case "sunburn": if c != nil { c.Output().SetFormatter(clif.NewDefaultFormatter(clif.SunburnStyles)) } clif.DefaultStyles = clif.SunburnStyles case "winter": if c != nil { c.Output().SetFormatter(clif.NewDefaultFormatter(clif.WinterStyles)) } clif.DefaultStyles = clif.WinterStyles } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func main() {\n\ts1 := stringAppender(\"hoo\")\n\tfmt.Println(s1(\"woo\"))\n\n\ts2 := stringAppender(\"Orioles\")\n\tfmt.Println(s2(\"Baltimore \"))\n\n}", "func main() {\n\targs := os.Args[1:]\n\t// if len(args) == 5 {\n\t// \tfmt.Println(\"There are 5 arguments\")\n\t// } else if len(args) == 2 {\n\t// \tfmt.P...
[ "0.5223018", "0.5174197", "0.50365174", "0.5033618", "0.5012377", "0.5009525", "0.49829808", "0.49779582", "0.49590465", "0.4917345", "0.48560345", "0.48281768", "0.4814344", "0.4811926", "0.47952038", "0.47935736", "0.47702038", "0.4769694", "0.47628325", "0.47418863", "0.47...
0.0
-1
TestMockValidity ensures that we don't go into a wild goose chase if our mock system gets screwed up
func TestMockValidity(t *testing.T) { nr := 50 _, hlp := agreement.WireAgreement(nr) hash, _ := crypto.RandEntropy(32) handler := agreement.NewHandler(hlp.Keys[0], *hlp.P) for i := 0; i < nr; i++ { a := message.MockAgreement(hash, 1, 3, hlp.Keys, hlp.P, i) if !assert.NoError(t, handler.Verify(a)) { t.FailNow() } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func IsMockInvalid(cc ContractCall) bool {\n\treturn false\n}", "func TestMimeMessageValidity(t *testing.T) {\n\tm := MimeMessage{\n\t\tToAddress: \"bar@baz.org\",\n\t\tContent: []byte(\"This is my body. There are many like it but this one is mine.\")}\n\n\tif m.IsValid() != true {\n\t\tt.Error(\"Message shoul...
[ "0.6337174", "0.56319845", "0.56032586", "0.5550087", "0.5531006", "0.5520939", "0.55201274", "0.551606", "0.5490635", "0.54042244", "0.5372254", "0.53221875", "0.5322081", "0.53210413", "0.53143036", "0.5292445", "0.5291869", "0.5279467", "0.5277037", "0.525805", "0.5255182"...
0.6817638
0
Test the accumulation of agreement events. It should result in the agreement component publishing a round update. TODO: trap eventual errors
func TestAgreement(t *testing.T) { nr := 50 _, hlp := agreement.WireAgreement(nr) hash, _ := crypto.RandEntropy(32) for i := 0; i < nr; i++ { a := message.MockAgreement(hash, 1, 3, hlp.Keys, hlp.P, i) msg := message.New(topics.Agreement, a) hlp.Bus.Publish(topics.Agreement, msg) } res := <-hlp.CertificateChan cert := res.Payload().(message.Agreement) assert.Equal(t, hash, cert.State().BlockHash) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestSendAgreement(t *testing.T) {\n\tcommitteeMock, _ := agreement.MockCommittee(3, true, 3)\n\teb, _ := initAgreement(committeeMock)\n\n\tstreamer := helper.NewSimpleStreamer()\n\teb.SubscribeStream(string(topics.Gossip), streamer)\n\teb.RegisterPreprocessor(string(topics.Gossip), processing.NewGossip(protoc...
[ "0.6576471", "0.65324676", "0.63587064", "0.61780435", "0.6098367", "0.59411633", "0.591464", "0.57962435", "0.57424355", "0.57177454", "0.5620648", "0.5585404", "0.55817324", "0.557412", "0.554213", "0.5497874", "0.5467166", "0.54497343", "0.5400443", "0.53578997", "0.530880...
0.68284917
0
Test that we properly clean up after calling Finalize. TODO: trap eventual errors
func TestFinalize(t *testing.T) { numGRBefore := runtime.NumGoroutine() // Create a set of 100 agreement components, and finalize them immediately for i := 0; i < 100; i++ { c, _ := agreement.WireAgreement(50) c.FinalizeRound() } // Ensure we have freed up all of the resources associated with these components numGRAfter := runtime.NumGoroutine() // We should have roughly the same amount of goroutines assert.InDelta(t, numGRBefore, numGRAfter, 10.0) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *SparkCoreAdaptor) Finalize() (errs []error) {\n\treturn\n}", "func Finalise() error {\n\n\tif !globalData.initialised {\n\t\treturn fault.NotInitialised\n\t}\n\n\tglobalData.log.Info(\"shutting down…\")\n\tglobalData.log.Flush()\n\n\t// finally...\n\tglobalData.initialised = false\n\n\tglobalData.log.In...
[ "0.6841336", "0.68049765", "0.6798049", "0.67779976", "0.67707664", "0.67355555", "0.66572475", "0.66430855", "0.6611207", "0.65803516", "0.657241", "0.6484667", "0.6480284", "0.6463848", "0.6461248", "0.6414478", "0.637417", "0.63708615", "0.6358206", "0.6301211", "0.628449"...
0.6605337
9
GitCommonDir returns commondir where contains "config" file
func (v Repository) GitCommonDir() string { return v.gitCommonDir }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v Repository) CommonDir() string {\n\tdir := v.RepoDir()\n\tcommonDir := dir\n\tif path.IsFile(filepath.Join(dir, \"commondir\")) {\n\t\tf, err := os.Open(filepath.Join(dir, \"commondir\"))\n\t\tif err == nil {\n\t\t\ts := bufio.NewScanner(f)\n\t\t\tif s.Scan() {\n\t\t\t\tcommonDir = s.Text()\n\t\t\t\tif !fi...
[ "0.7268661", "0.698559", "0.67048705", "0.6670058", "0.64420474", "0.6358523", "0.6318514", "0.6305134", "0.629191", "0.6254382", "0.6215227", "0.6206227", "0.6198722", "0.6184039", "0.6167576", "0.61568576", "0.61452913", "0.6124343", "0.6116592", "0.6085793", "0.6062132", ...
0.7390736
0
IsBare indicates a repository is a bare repository.
func (v Repository) IsBare() bool { return v.workDir == "" }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func IsBareRepository(path string) bool {\n\n\tcmd := exec.Command(\"git\", fmt.Sprintf(\"--git-dir=%s\", path), \"rev-parse\", \"--is-bare-repository\")\n\tbody, err := cmd.Output()\n\n\tif err != nil {\n\t\treturn false\n\t}\n\n\tstatus := strings.Trim(string(body), \"\\n \")\n\treturn status == \"true\"\n}", ...
[ "0.80748403", "0.65109813", "0.6356934", "0.6285676", "0.6277902", "0.6159446", "0.58196324", "0.5621973", "0.5499171", "0.5424167", "0.5416235", "0.5323672", "0.51931185", "0.5172835", "0.5115312", "0.50820893", "0.5052068", "0.50374174", "0.49954063", "0.49940842", "0.49926...
0.8010365
1
Config returns git config object
func (v Repository) Config() GitConfig { return v.gitConfig }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (v Repository) Config() goconfig.GitConfig {\n\tcfg, err := goconfig.Load(v.configFile())\n\tif err != nil && err != goconfig.ErrNotExist {\n\t\tlog.Fatalf(\"fail to load config: %s: %s\", v.configFile(), err)\n\t}\n\tif cfg == nil {\n\t\tcfg = goconfig.NewGitConfig()\n\t}\n\treturn cfg\n}", "func (opt *Opt...
[ "0.7744009", "0.7410123", "0.670251", "0.661456", "0.6592749", "0.65113205", "0.6497694", "0.64752066", "0.6394821", "0.63012666", "0.62980485", "0.6286497", "0.6229654", "0.6194471", "0.61894053", "0.61824733", "0.61724776", "0.61576897", "0.61292005", "0.6120914", "0.612033...
0.7850194
0
FindRepository locates repository object search from the given dir.
func FindRepository(dir string) (*Repository, error) { var ( gitDir string commonDir string workDir string gitConfig GitConfig err error ) gitDir, err = findGitDir(dir) if err != nil { return nil, err } commonDir, err = getGitCommonDir(gitDir) if err != nil { return nil, err } gitConfig, err = LoadFileWithDefault(filepath.Join(commonDir, "config")) if err != nil { return nil, err } if !gitConfig.GetBool("core.bare", false) { workDir, _ = getWorkTree(gitDir) } return &Repository{ gitDir: gitDir, gitCommonDir: commonDir, workDir: workDir, gitConfig: gitConfig, }, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func FindRepository(ctx context.Context, exec boil.ContextExecutor, iD string, selectCols ...string) (*Repository, error) {\n\trepositoryObj := &Repository{}\n\n\tsel := \"*\"\n\tif len(selectCols) > 0 {\n\t\tsel = strings.Join(strmangle.IdentQuoteSlice(dialect.LQ, dialect.RQ, selectCols), \",\")\n\t}\n\tquery := ...
[ "0.67655885", "0.6583548", "0.5961574", "0.5914727", "0.58771306", "0.582271", "0.5820217", "0.5819151", "0.55795795", "0.5564507", "0.5556771", "0.55446625", "0.5502477", "0.5489713", "0.54813373", "0.5453073", "0.5391034", "0.536849", "0.5359692", "0.534294", "0.5341294", ...
0.7402806
0
CheckSemanticTitle checks if the given PR contains semantic title
func CheckSemanticTitle(pr *gogh.PullRequest, config PluginConfiguration, logger log.Logger) string { change := ghservice.NewRepositoryChangeForPR(pr) prefixes := GetValidTitlePrefixes(config) isTitleWithValidType := HasTitleWithValidType(prefixes, *pr.Title) if !isTitleWithValidType { if prefix, ok := wip.GetWorkInProgressPrefix(*pr.Title, wip.LoadConfiguration(logger, change)); ok { trimmedTitle := strings.TrimPrefix(*pr.Title, prefix) isTitleWithValidType = HasTitleWithValidType(prefixes, trimmedTitle) } } if !isTitleWithValidType { allPrefixes := "`" + strings.Join(prefixes, "`, `") + "`" return fmt.Sprintf(TitleFailureMessage, pr.GetTitle(), allPrefixes) } return "" }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func testFrontMatterTitle(mdBytes []byte) error {\n\tfm, _, err := frontparser.ParseFrontmatterAndContent(mdBytes)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif _, exists := fm[\"title\"]; exists == false {\n\t\treturn errors.New(\"can't find title in frontmatter\")\n\t}\n\treturn nil\n}", "func IsTitle(r rune) ...
[ "0.63894886", "0.61719227", "0.6123725", "0.60611886", "0.60287726", "0.6002876", "0.5939993", "0.5821647", "0.5766424", "0.57502794", "0.57399386", "0.5739377", "0.57328135", "0.572084", "0.5645825", "0.56444085", "0.56426454", "0.55887145", "0.55743915", "0.55185646", "0.55...
0.85127145
0
CheckDescriptionLength checks if the given PR's description contains enough number of arguments
func CheckDescriptionLength(pr *gogh.PullRequest, config PluginConfiguration, logger log.Logger) string { actualLength := len(strings.TrimSpace(issueLinkRegexp.ReplaceAllString(pr.GetBody(), ""))) if actualLength < config.DescriptionContentLength { return fmt.Sprintf(DescriptionLengthShortMessage, config.DescriptionContentLength, actualLength) } return "" }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CheckArgsLength(args []string, expectedLength int) error {\r\n\tif len(args) != expectedLength {\r\n\t\treturn fmt.Errorf(\"invalid number of arguments. Expected %v, got %v\", expectedLength, len(args))\r\n\t}\r\n\treturn nil\r\n}", "func IsValidArgsLength(args []string, n int) bool {\n\tif args == nil && n...
[ "0.66327566", "0.6183819", "0.61530507", "0.5897223", "0.58695334", "0.5821858", "0.5798817", "0.5707416", "0.5667413", "0.5666727", "0.5630328", "0.5620006", "0.55985975", "0.55719393", "0.553691", "0.55122423", "0.5494682", "0.5478022", "0.54566044", "0.5453439", "0.5440699...
0.7995943
0
CheckIssueLinkPresence checks if the given PR's description contains an issue link
func CheckIssueLinkPresence(pr *gogh.PullRequest, config PluginConfiguration, logger log.Logger) string { if !issueLinkRegexp.MatchString(pr.GetBody()) { return IssueLinkMissingMessage } return "" }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CheckDescriptionLength(pr *gogh.PullRequest, config PluginConfiguration, logger log.Logger) string {\n\tactualLength := len(strings.TrimSpace(issueLinkRegexp.ReplaceAllString(pr.GetBody(), \"\")))\n\tif actualLength < config.DescriptionContentLength {\n\t\treturn fmt.Sprintf(DescriptionLengthShortMessage, con...
[ "0.5827231", "0.52759945", "0.52670836", "0.52358055", "0.5205674", "0.50942165", "0.50830615", "0.50109303", "0.5003048", "0.4981114", "0.49796918", "0.4905218", "0.48997667", "0.4889865", "0.4878953", "0.48716253", "0.48570353", "0.48182932", "0.4803739", "0.47971547", "0.4...
0.7922563
0
GetValidTitlePrefixes returns list of valid prefixes
func GetValidTitlePrefixes(config PluginConfiguration) []string { prefixes := defaultTypes if len(config.TypePrefix) != 0 { if config.Combine { prefixes = append(prefixes, config.TypePrefix...) } else { prefixes = config.TypePrefix } } return prefixes }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o GoogleCloudRetailV2alphaSearchRequestFacetSpecFacetKeyPtrOutput) Prefixes() pulumi.StringArrayOutput {\n\treturn o.ApplyT(func(v *GoogleCloudRetailV2alphaSearchRequestFacetSpecFacetKey) []string {\n\t\tif v == nil {\n\t\t\treturn nil\n\t\t}\n\t\treturn v.Prefixes\n\t}).(pulumi.StringArrayOutput)\n}", "fu...
[ "0.6098155", "0.6092304", "0.602812", "0.58553684", "0.5671215", "0.5661387", "0.5588173", "0.5572023", "0.54787356", "0.54342926", "0.54087603", "0.5395631", "0.53830993", "0.5359162", "0.5359162", "0.5341388", "0.5303424", "0.5253235", "0.5222545", "0.52096283", "0.51101464...
0.8025123
0
HasTitleWithValidType checks if title prefix conforms with semantic message style.
func HasTitleWithValidType(prefixes []string, title string) bool { pureTitle := strings.TrimSpace(title) for _, prefix := range prefixes { prefixRegexp := regexp.MustCompile(`(?i)^` + prefix + `(:| |\()+`) if prefixRegexp.MatchString(pureTitle) { return true } } return false }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CheckSemanticTitle(pr *gogh.PullRequest, config PluginConfiguration, logger log.Logger) string {\n\tchange := ghservice.NewRepositoryChangeForPR(pr)\n\tprefixes := GetValidTitlePrefixes(config)\n\tisTitleWithValidType := HasTitleWithValidType(prefixes, *pr.Title)\n\n\tif !isTitleWithValidType {\n\t\tif prefix...
[ "0.6505668", "0.63963515", "0.63822585", "0.60263205", "0.58802074", "0.5860582", "0.58390754", "0.57830197", "0.57806534", "0.57744485", "0.57152456", "0.5694083", "0.56921774", "0.5678252", "0.56778", "0.56730336", "0.5671352", "0.56649643", "0.5638103", "0.5576951", "0.556...
0.80496615
0
CountCSVRowsGo returns a count of the number of rows in the give csv file
func CountCSVRowsGo(source string) (int, error) { defer un(trace("CountCSVRowsGo")) err := assertValidFilename(source) if err != nil { return 0, err } f, _ := os.Open(source) r := csv.NewReader(bufio.NewReader(f)) rowCount := 0 for { _, err := r.Read() if err == io.EOF { break } rowCount++ } return rowCount, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CSVFileInfo(f0 string) (size int64, nRec int64) {\n\tfd0, err := os.Open(f0)\n\tdefer fd0.Close()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tfi0, err := fd0.Stat()\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tbuf0 := bufio.NewReader(fd0)\n\tl0, _, err := buf0.ReadLine()\n\tif err != nil {\n\t\tlog.Fatal...
[ "0.6375762", "0.6306837", "0.61106974", "0.60449296", "0.60007024", "0.59904045", "0.58921826", "0.5806305", "0.57993895", "0.57476985", "0.56987125", "0.56797904", "0.56628454", "0.56590277", "0.5635066", "0.5588222", "0.55808735", "0.55445486", "0.5538845", "0.5538845", "0....
0.8511326
0
TestService is the doc.go usage example
func TestService(t *testing.T) { // Create service to test s := res.NewService("foo") s.Handle("bar.$id", res.Access(res.AccessGranted), res.GetModel(func(r res.ModelRequest) { r.Model(struct { Message string `json:"msg"` }{r.PathParam("id")}) }), ) // Create test session c := restest.NewSession(t, s) defer c.Close() // Test sending get request and validate response c.Get("foo.bar.42"). Response(). AssertModel(map[string]string{"msg": "42"}) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func testService() *corev1.Service {\n\treturn &corev1.Service{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tNamespace: \"default\",\n\t\t\tName: \"symbols\",\n\t\t\tLabels: map[string]string{\n\t\t\t\t\"deploy\": \"sourcegraph\",\n\t\t\t},\n\t\t},\n\t\tSpec: corev1.ServiceSpec{\n\t\t\tType: corev1.ServiceTypeC...
[ "0.69882417", "0.6967048", "0.68721616", "0.68416625", "0.67049074", "0.66628826", "0.65935975", "0.65935975", "0.63858414", "0.6379433", "0.6224912", "0.6220467", "0.6087149", "0.60556716", "0.60545856", "0.60364485", "0.6027248", "0.6005909", "0.5961527", "0.59466285", "0.5...
0.6961546
2
Test that the service returns the correct protocol version
func TestServiceProtocolVersion(t *testing.T) { s := res.NewService("test") restest.AssertEqualJSON(t, "ProtocolVersion()", s.ProtocolVersion(), "1.2.2") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestPeersService_Version(t *testing.T) {\n\tclient, mux, _, teardown := setupTest()\n\tdefer teardown()\n\n\tmux.HandleFunc(\"/peers/version\", func(writer http.ResponseWriter, request *http.Request) {\n\t\ttestMethod(t, request, \"GET\")\n\t\tfmt.Fprint(writer,\n\t\t\t`{\n\t\t\t \"version\": \"2.0.0\",\n\t\...
[ "0.6705135", "0.6438302", "0.6386366", "0.63707674", "0.6304543", "0.6262574", "0.617563", "0.6168916", "0.6146892", "0.6113688", "0.60996807", "0.6088013", "0.6075797", "0.6062475", "0.60598236", "0.60437936", "0.6016582", "0.599666", "0.59772485", "0.5974628", "0.5953988", ...
0.7818675
0
Test that the service can be served without error
func TestServiceStart(t *testing.T) { runTest(t, func(s *res.Service) { s.Handle("model", res.GetResource(func(r res.GetRequest) { r.NotFound() })) }, nil) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Test_NotFound(t *testing.T) {\n\tvar (\n\t\tnotFoundMsg ErrorMessage\n\t\tresp *http.Response\n\t)\n\n\tsvc := NewService()\n\tts := httptest.NewServer(svc.NewRouter(\"*\"))\n\tdefer ts.Close()\n\n\treq, _ := http.NewRequest(\"GET\", ts.URL+\"/not_found\", nil)\n\n\toutputLog := helpers.CaptureOutput(f...
[ "0.6174951", "0.61433923", "0.6138589", "0.6069285", "0.60072887", "0.59959316", "0.59840834", "0.59650725", "0.59454465", "0.59126145", "0.5888355", "0.5883821", "0.5823625", "0.57960033", "0.5772618", "0.57676363", "0.57636327", "0.5759152", "0.5754714", "0.5753475", "0.574...
0.5735269
21
Test that service can be served without logger
func TestServiceWithoutLogger(t *testing.T) { s := res.NewService("test") s.SetLogger(nil) s.Handle("model", res.GetResource(func(r res.GetRequest) { r.NotFound() })) session := restest.NewSession(t, s, restest.WithKeepLogger) defer session.Close() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Test_NotFound(t *testing.T) {\n\tvar (\n\t\tnotFoundMsg ErrorMessage\n\t\tresp *http.Response\n\t)\n\n\tsvc := NewService()\n\tts := httptest.NewServer(svc.NewRouter(\"*\"))\n\tdefer ts.Close()\n\n\treq, _ := http.NewRequest(\"GET\", ts.URL+\"/not_found\", nil)\n\n\toutputLog := helpers.CaptureOutput(f...
[ "0.6161699", "0.59672475", "0.5942423", "0.57929426", "0.578552", "0.57729983", "0.5761654", "0.5737634", "0.57193595", "0.5637695", "0.56319416", "0.56254923", "0.56139284", "0.55134445", "0.55043334", "0.54994684", "0.54989934", "0.54716086", "0.54499424", "0.54347134", "0....
0.72680014
0
Test that Logger returns the logger set with SetLogger
func TestServiceSetLogger(t *testing.T) { s := res.NewService("test") l := logger.NewMemLogger() s.SetLogger(l) if s.Logger() != l { t.Errorf("expected Logger to return the logger passed to SetLogger, but it didn't") } s.Handle("model", res.GetResource(func(r res.GetRequest) { r.NotFound() })) session := restest.NewSession(t, s, restest.WithKeepLogger) defer session.Close() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Logger() spidomtr.RunnerHandler {\n\treturn &TestLogger{}\n}", "func GetLogger() *log.Logger { return std.GetLogger() }", "func SetLogger(l utils.Logger) {\n\tlog = l\n}", "func SetLogger(l Logger) {\n\tlog = l\n}", "func SetLogger(l logger.Logger) {\n\tlog = l\n}", "func SetLogger(logger logger) {\...
[ "0.73071015", "0.7217698", "0.71225667", "0.7067874", "0.70242816", "0.7004462", "0.6998388", "0.69833803", "0.6974619", "0.69734454", "0.6970742", "0.69570327", "0.6933845", "0.69240355", "0.6911089", "0.69096345", "0.69042265", "0.6903018", "0.6900997", "0.6900997", "0.6900...
0.75092244
0
Test that With returns an error if there is no registered pattern matching the resource
func TestServiceWith_WithoutMatchingPattern(t *testing.T) { runTest(t, func(s *res.Service) { s.Handle("collection", res.GetResource(func(r res.GetRequest) { r.NotFound() })) }, func(s *restest.Session) { err := s.Service().With("test.model", func(r res.Resource) {}) if err == nil { t.Errorf("expected With to return an error, but it didn't") } }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Router) Resource(pattern string, resource Resource) {\n\tsub := r.Group(pattern)\n\n\tif usesRes, ok := resource.(ResourceUses); ok {\n\t\tif len(usesRes.Uses()) > 0 {\n\t\t\tsub.Use(usesRes.Uses()...)\n\t\t}\n\t}\n\n\tfor _, m := range allowedHTTPMethods {\n\t\tif hfn, ok := isHandlerFuncInResource(m, re...
[ "0.54446614", "0.53186023", "0.5237049", "0.51093924", "0.5071384", "0.50415397", "0.5041398", "0.5022821", "0.5021216", "0.50205475", "0.50031614", "0.49272117", "0.48908263", "0.48736688", "0.48641396", "0.48465416", "0.48355845", "0.482778", "0.48097754", "0.480847", "0.47...
0.68765235
0
Test that SetOwnedResources sets which resources are reset when calling Reset.
func TestServiceSetOwnedResources(t *testing.T) { resources := []string{"test.foo.>", "test.bar.>"} access := []string{"test.zoo.>", "test.baz.>"} runTest(t, func(s *res.Service) { s.SetOwnedResources(resources, access) }, nil, restest.WithReset(resources, access)) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (m *User) SetOwnedObjects(value []DirectoryObjectable)() {\n m.ownedObjects = value\n}", "func TestReset(t *testing.T) {\n\ttestCancel(t, false)\n}", "func TestApplyOwnershipDiff(t *testing.T) {\n\tusers := []*user.User{\n\t\tfakeUser(\"1\", \"1\", \"user-1\"),\n\t\tfakeUser(\"2\", \"2\", \"user-2\"),\...
[ "0.5632101", "0.54997927", "0.54261786", "0.5346862", "0.5218427", "0.51643884", "0.5162271", "0.51167315", "0.5096469", "0.5093228", "0.50793904", "0.5075024", "0.5042418", "0.5026725", "0.50028026", "0.49832165", "0.49498773", "0.4921987", "0.4913988", "0.4884722", "0.48834...
0.76563233
0
Test that TokenEvent sends a connection token event.
func TestServiceTokenEvent_WithObjectToken_SendsToken(t *testing.T) { runTest(t, func(s *res.Service) { s.Handle("model", res.GetResource(func(r res.GetRequest) { r.NotFound() })) }, func(s *restest.Session) { s.Service().TokenEvent(mock.CID, mock.Token) s.GetMsg().AssertTokenEvent(mock.CID, mock.Token) }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestAuthRequestTokenEvent(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\tr.TokenEvent(mock.Token)\n\t\t\tr.OK(nil)\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\treq := s.Auth(\"test.model\", \"method\", nil)\n\t\ts.GetMsg()....
[ "0.7312468", "0.66278255", "0.63569856", "0.6182798", "0.60594577", "0.59883547", "0.5914056", "0.58681816", "0.5785276", "0.56461126", "0.5483135", "0.54372364", "0.5330973", "0.52957696", "0.5283241", "0.52675366", "0.5232106", "0.52223915", "0.52166265", "0.52122736", "0.5...
0.7044898
1
Test that TokenEvent with nil sends a connection token event with a nil token.
func TestServiceTokenEvent_WithNilToken_SendsNilToken(t *testing.T) { runTest(t, func(s *res.Service) { s.Handle("model", res.GetResource(func(r res.GetRequest) { r.NotFound() })) }, func(s *restest.Session) { s.Service().TokenEvent(mock.CID, nil) s.GetMsg().AssertTokenEvent(mock.CID, nil) }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestServiceTokenEventWithID_WithNilToken_SendsNilToken(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.GetResource(func(r res.GetRequest) { r.NotFound() }))\n\t}, func(s *restest.Session) {\n\t\ts.Service().TokenEventWithID(mock.CID, \"foo\", nil)\n\t\ts.GetMsg().AssertTokenE...
[ "0.77936465", "0.7668459", "0.6160332", "0.6125415", "0.5994007", "0.5927848", "0.5891091", "0.56836843", "0.56730366", "0.56381816", "0.5634394", "0.55937874", "0.5510154", "0.54910815", "0.54667795", "0.5448074", "0.5422616", "0.5422521", "0.5380838", "0.535725", "0.5315453...
0.8175172
0
Test that TokenEvent with an invalid cid causes panic.
func TestServiceTokenEventWithID_WithInvalidCID_CausesPanic(t *testing.T) { runTest(t, func(s *res.Service) { s.Handle("model", res.GetResource(func(r res.GetRequest) { r.NotFound() })) }, func(s *restest.Session) { restest.AssertPanic(t, func() { s.Service().TokenEventWithID("invalid.*.cid", "foo", nil) }) }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestServiceTokenEvent_WithInvalidCID_CausesPanic(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.GetResource(func(r res.GetRequest) { r.NotFound() }))\n\t}, func(s *restest.Session) {\n\t\trestest.AssertPanic(t, func() {\n\t\t\ts.Service().TokenEvent(\"invalid.*.cid\", nil)\n...
[ "0.8047649", "0.57519215", "0.5298864", "0.5272522", "0.52437335", "0.52140474", "0.5171461", "0.5149031", "0.5140155", "0.5113895", "0.507982", "0.5015881", "0.5013838", "0.50101703", "0.5003114", "0.49705926", "0.49312204", "0.49038598", "0.48926267", "0.48593882", "0.48174...
0.78260386
1
Test that TokenEvent sends a connection token event.
func TestServiceTokenEventWithID_WithObjectToken_SendsToken(t *testing.T) { runTest(t, func(s *res.Service) { s.Handle("model", res.GetResource(func(r res.GetRequest) { r.NotFound() })) }, func(s *restest.Session) { s.Service().TokenEventWithID(mock.CID, "foo", mock.Token) s.GetMsg().AssertTokenEventWithID(mock.CID, "foo", mock.Token) }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestAuthRequestTokenEvent(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.Auth(\"method\", func(r res.AuthRequest) {\n\t\t\tr.TokenEvent(mock.Token)\n\t\t\tr.OK(nil)\n\t\t}))\n\t}, func(s *restest.Session) {\n\t\treq := s.Auth(\"test.model\", \"method\", nil)\n\t\ts.GetMsg()....
[ "0.7310845", "0.7044548", "0.6355642", "0.6183274", "0.60615444", "0.5989066", "0.591275", "0.5867129", "0.57831806", "0.5647044", "0.5481344", "0.5433984", "0.533381", "0.5294447", "0.52854496", "0.526756", "0.5230422", "0.5221526", "0.5216238", "0.5214109", "0.52059054", ...
0.66276056
2
Test that TokenEvent with nil sends a connection token event with a nil token.
func TestServiceTokenEventWithID_WithNilToken_SendsNilToken(t *testing.T) { runTest(t, func(s *res.Service) { s.Handle("model", res.GetResource(func(r res.GetRequest) { r.NotFound() })) }, func(s *restest.Session) { s.Service().TokenEventWithID(mock.CID, "foo", nil) s.GetMsg().AssertTokenEventWithID(mock.CID, "foo", nil) }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestServiceTokenEvent_WithNilToken_SendsNilToken(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.GetResource(func(r res.GetRequest) { r.NotFound() }))\n\t}, func(s *restest.Session) {\n\t\ts.Service().TokenEvent(mock.CID, nil)\n\t\ts.GetMsg().AssertTokenEvent(mock.CID, nil)\n...
[ "0.8175133", "0.7667413", "0.61625266", "0.61268103", "0.59948516", "0.5929725", "0.58923304", "0.56820005", "0.5672691", "0.5638859", "0.5632581", "0.5596265", "0.5511962", "0.5491512", "0.5467685", "0.54452044", "0.5420265", "0.54192835", "0.53779507", "0.5359243", "0.53143...
0.7793353
1
Test that TokenEvent with an invalid cid causes panic.
func TestServiceTokenEvent_WithInvalidCID_CausesPanic(t *testing.T) { runTest(t, func(s *res.Service) { s.Handle("model", res.GetResource(func(r res.GetRequest) { r.NotFound() })) }, func(s *restest.Session) { restest.AssertPanic(t, func() { s.Service().TokenEvent("invalid.*.cid", nil) }) }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestServiceTokenEventWithID_WithInvalidCID_CausesPanic(t *testing.T) {\n\trunTest(t, func(s *res.Service) {\n\t\ts.Handle(\"model\", res.GetResource(func(r res.GetRequest) { r.NotFound() }))\n\t}, func(s *restest.Session) {\n\t\trestest.AssertPanic(t, func() {\n\t\t\ts.Service().TokenEventWithID(\"invalid.*.c...
[ "0.78261864", "0.5751174", "0.52965206", "0.5272917", "0.5241354", "0.5213487", "0.5169806", "0.5148139", "0.5139948", "0.51134753", "0.5077146", "0.50146776", "0.50133395", "0.5010127", "0.500105", "0.49700215", "0.49307236", "0.4902067", "0.489147", "0.48595318", "0.4818535...
0.80473816
0
Test that Reset sends a system.reset event.
func TestServiceReset(t *testing.T) { tbl := []struct { Resources []string Access []string Expected interface{} }{ {nil, nil, nil}, {[]string{}, nil, nil}, {nil, []string{}, nil}, {[]string{}, []string{}, nil}, {[]string{"test.foo.>"}, nil, json.RawMessage(`{"resources":["test.foo.>"]}`)}, {nil, []string{"test.foo.>"}, json.RawMessage(`{"access":["test.foo.>"]}`)}, {[]string{"test.foo.>"}, []string{"test.bar.>"}, json.RawMessage(`{"resources":["test.foo.>"],"access":["test.bar.>"]}`)}, {[]string{"test.foo.>"}, []string{}, json.RawMessage(`{"resources":["test.foo.>"]}`)}, {[]string{}, []string{"test.foo.>"}, json.RawMessage(`{"access":["test.foo.>"]}`)}, } for _, l := range tbl { runTest(t, func(s *res.Service) { s.Handle("model", res.GetResource(func(r res.GetRequest) { r.NotFound() })) }, func(s *restest.Session) { s.Service().Reset(l.Resources, l.Access) // Send token event to flush any system.reset event s.Service().TokenEvent(mock.CID, nil) if l.Expected != nil { s.GetMsg(). AssertSubject("system.reset"). AssertPayload(l.Expected) } s.GetMsg().AssertTokenEvent(mock.CID, nil) }) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestReset(t *testing.T) {\n\ttestCancel(t, false)\n}", "func (m *Machine) Reset() error {\n\tm.State = driver.Running\n\tfmt.Printf(\"Reset %s: %s\\n\", m.Name, m.State)\n\treturn nil\n}", "func MockOnResetSystem(ctx context.Context, mockAPI *redfishMocks.RedfishAPI,\n\tsystemID string, requestBody *redfi...
[ "0.7429841", "0.67033285", "0.66388756", "0.65228575", "0.64425254", "0.6361065", "0.6352461", "0.63204896", "0.6292608", "0.6255345", "0.6237539", "0.6236271", "0.61987543", "0.61972404", "0.6187439", "0.61694217", "0.6162422", "0.6148909", "0.61209315", "0.61076725", "0.608...
0.7183463
1
Test that TokenReset sends a system.tokenReset event.
func TestServiceTokenReset(t *testing.T) { tbl := []struct { Subject string TIDs []string Expected interface{} }{ {"auth", nil, nil}, {"auth", []string{}, nil}, {"auth", []string{"foo"}, json.RawMessage(`{"tids":["foo"],"subject":"auth"}`)}, {"auth", []string{"foo", "bar"}, json.RawMessage(`{"tids":["foo","bar"],"subject":"auth"}`)}, {"auth.test.method", []string{"foo", "bar"}, json.RawMessage(`{"tids":["foo","bar"],"subject":"auth.test.method"}`)}, } for _, l := range tbl { runTest(t, func(s *res.Service) { s.Handle("model", res.GetResource(func(r res.GetRequest) { r.NotFound() })) }, func(s *restest.Session) { s.Service().TokenReset(l.Subject, l.TIDs...) // Send token event to flush any system.tokenReset event s.Service().TokenEvent(mock.CID, nil) if l.Expected != nil { s.GetMsg(). AssertSubject("system.tokenReset"). AssertPayload(l.Expected) } s.GetMsg().AssertTokenEvent(mock.CID, nil) }) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TestServiceReset(t *testing.T) {\n\ttbl := []struct {\n\t\tResources []string\n\t\tAccess []string\n\t\tExpected interface{}\n\t}{\n\t\t{nil, nil, nil},\n\t\t{[]string{}, nil, nil},\n\t\t{nil, []string{}, nil},\n\t\t{[]string{}, []string{}, nil},\n\n\t\t{[]string{\"test.foo.>\"}, nil, json.RawMessage(`{\"...
[ "0.6782514", "0.67578304", "0.63564855", "0.63515836", "0.626506", "0.616196", "0.6093224", "0.60746515", "0.602785", "0.58969015", "0.581825", "0.57836133", "0.5652502", "0.55837214", "0.5583631", "0.55784583", "0.5575923", "0.5546597", "0.55264384", "0.5520162", "0.54814744...
0.76338595
0
Each element in the new list is built by multiplying every value in the input list by a value in a repeating pattern and then adding up the results.
func FFT(in []int, phases int) []int { b := make([]int, len(in)) for n := range in { b[n] = FFTdigit(in, n, phases) } return b }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Accumulate(list []string, f func(string) string) []string {\n\tnewList := make([]string, len(list))\n\tfor i := range list {\n\t\tnewList[i] = f(list[i])\n\t}\n\treturn newList\n}", "func Multiply(nums ...float64) (total float64) {\n\ttotal = nums[0]\n\tfor i := 1; i < len(nums); i++ {\n\t\ttotal *= nums[i]...
[ "0.5405258", "0.5152699", "0.5114688", "0.5112069", "0.5109156", "0.5105612", "0.5098415", "0.5061247", "0.49656245", "0.4962712", "0.49513575", "0.49395883", "0.49349442", "0.49143258", "0.49084", "0.4908162", "0.48922318", "0.4881153", "0.48788738", "0.48718312", "0.4842656...
0.0
-1
IsAMPCustomElement returns true if the node is an AMP custom element.
func IsAMPCustomElement(n *html.Node) bool { return n.Type == html.ElementNode && strings.HasPrefix(n.Data, "amp-") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (decl SomeDecl) IsCustom() bool {\n\t_, is := decl.Properties.(CustomProperties)\n\treturn is\n}", "func IsScriptAMPExtension(n *html.Node) bool {\n\t_, ok := AMPExtensionName(n)\n\treturn ok\n}", "func (t *Type) IsCustom() bool {\n\treturn !t.IsPrimitive() && !t.IsContainer()\n}", "func IsScriptAMPRunt...
[ "0.61564237", "0.6037972", "0.57607794", "0.5394972", "0.5383893", "0.5306295", "0.5250998", "0.4929128", "0.49054834", "0.4893038", "0.48832464", "0.47255784", "0.4680999", "0.4679311", "0.46730384", "0.46495634", "0.4607126", "0.45523682", "0.4546803", "0.4519753", "0.44830...
0.90020335
0
AMPExtensionScriptDefinition returns a unique script definition that takes into account the extension name, version and if it is module/nomodule. Example (ampad): ampad0.1.js (regular/nomodule), ampad0.1.mjs (module). The AMP Validator prevents a mix of regular and nomodule extensions. If the pattern is not found then uses value of "src" attribute. Returns ok=false if this isn't an extension.
func AMPExtensionScriptDefinition(n *html.Node) (string, bool) { if n.DataAtom != atom.Script { return "", false } src, hasSrc := htmlnode.GetAttributeVal(n, "", "src") if hasSrc { m := srcURLRE.FindStringSubmatch(src) if len(m) < 2 { return src, true } return m[1], true } return "", false }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func IsScriptAMPExtension(n *html.Node) bool {\n\t_, ok := AMPExtensionName(n)\n\treturn ok\n}", "func AMPExtensionName(n *html.Node) (string, bool) {\n\tif n.DataAtom != atom.Script {\n\t\treturn \"\", false\n\t}\n\tfor _, attr := range n.Attr {\n\t\tfor _, k := range []string{AMPCustomElement, AMPCustomTemplat...
[ "0.5773764", "0.53484195", "0.4909956", "0.4629277", "0.45030597", "0.44573566", "0.4399511", "0.43457377", "0.4294057", "0.42767256", "0.4269526", "0.4240586", "0.41823775", "0.41584232", "0.4150533", "0.41313267", "0.40750483", "0.40618613", "0.40592343", "0.40531242", "0.4...
0.7917034
0
AMPExtensionName returns the name of the extension this node represents. For most extensions this is the value of the "customelement" attribute. Returns ok=false if this isn't an extension.
func AMPExtensionName(n *html.Node) (string, bool) { if n.DataAtom != atom.Script { return "", false } for _, attr := range n.Attr { for _, k := range []string{AMPCustomElement, AMPCustomTemplate, AMPHostService} { if attr.Key == k { return attr.Val, true } } } return "", false }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func IsScriptAMPExtension(n *html.Node) bool {\n\t_, ok := AMPExtensionName(n)\n\treturn ok\n}", "func (me TxsdImpactSimpleContentExtensionType) IsExtValue() bool { return me.String() == \"ext-value\" }", "func (me TxsdCounterSimpleContentExtensionType) IsExtValue() bool { return me.String() == \"ext-value\" }...
[ "0.5660772", "0.5495332", "0.53589237", "0.52444386", "0.52043265", "0.51868117", "0.51730925", "0.5127122", "0.512419", "0.5119247", "0.5100169", "0.50610256", "0.50594693", "0.50342685", "0.49987003", "0.49817717", "0.49522945", "0.49516153", "0.4924233", "0.49242046", "0.4...
0.74925065
0
IsScriptAMPExtension returns true if the node is a script tag representing an extension.
func IsScriptAMPExtension(n *html.Node) bool { _, ok := AMPExtensionName(n) return ok }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func IsScriptAMPRuntime(n *html.Node) bool {\n\tif n.DataAtom != atom.Script {\n\t\treturn false\n\t}\n\tif v, ok := htmlnode.GetAttributeVal(n, \"\", \"src\"); ok {\n\t\treturn htmlnode.HasAttribute(n, \"\", \"async\") &&\n\t\t\t!IsScriptAMPExtension(n) &&\n\t\t\tstrings.HasPrefix(v, AMPCacheRootURL) &&\n\t\t\t(s...
[ "0.6694262", "0.6552518", "0.6336672", "0.61952287", "0.61614895", "0.5731267", "0.5551006", "0.5041479", "0.5015922", "0.5001815", "0.4956", "0.49291924", "0.48919377", "0.48352566", "0.482244", "0.47968212", "0.47773254", "0.47717315", "0.47310606", "0.47221884", "0.4642533...
0.89359015
0
IsScriptAMPRuntime returns true if the node is of the form <script async src=
func IsScriptAMPRuntime(n *html.Node) bool { if n.DataAtom != atom.Script { return false } if v, ok := htmlnode.GetAttributeVal(n, "", "src"); ok { return htmlnode.HasAttribute(n, "", "async") && !IsScriptAMPExtension(n) && strings.HasPrefix(v, AMPCacheRootURL) && (strings.HasSuffix(v, "/v0.js") || strings.HasSuffix(v, "/v0.mjs") || strings.HasSuffix(v, "/amp4ads-v0.js") || strings.HasSuffix(v, "/amp4ads-v0.mjs")) } return false }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func IsScriptAMPViewer(n *html.Node) bool {\n\tif n.DataAtom != atom.Script {\n\t\treturn false\n\t}\n\ta, ok := htmlnode.FindAttribute(n, \"\", \"src\")\n\treturn ok &&\n\t\t!IsScriptAMPExtension(n) &&\n\t\tstrings.HasPrefix(a.Val,\n\t\t\tAMPCacheSchemeAndHost+\"/v0/amp-viewer-integration-\") &&\n\t\tstrings.HasS...
[ "0.71983045", "0.6859008", "0.6489399", "0.6116429", "0.59569806", "0.50658715", "0.48501772", "0.476661", "0.47604835", "0.4714461", "0.46902317", "0.4659031", "0.45383734", "0.44345397", "0.4392329", "0.4341767", "0.43279102", "0.4326666", "0.42890763", "0.42832336", "0.425...
0.85922056
0
IsScriptAMPViewer returns true if the node is of the form <script async src=
func IsScriptAMPViewer(n *html.Node) bool { if n.DataAtom != atom.Script { return false } a, ok := htmlnode.FindAttribute(n, "", "src") return ok && !IsScriptAMPExtension(n) && strings.HasPrefix(a.Val, AMPCacheSchemeAndHost+"/v0/amp-viewer-integration-") && strings.HasSuffix(a.Val, ".js") && htmlnode.HasAttribute(n, "", "async") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func IsScriptAMPRuntime(n *html.Node) bool {\n\tif n.DataAtom != atom.Script {\n\t\treturn false\n\t}\n\tif v, ok := htmlnode.GetAttributeVal(n, \"\", \"src\"); ok {\n\t\treturn htmlnode.HasAttribute(n, \"\", \"async\") &&\n\t\t\t!IsScriptAMPExtension(n) &&\n\t\t\tstrings.HasPrefix(v, AMPCacheRootURL) &&\n\t\t\t(s...
[ "0.7577506", "0.6722259", "0.65249646", "0.6250946", "0.6023484", "0.5208977", "0.49847195", "0.4919317", "0.48820964", "0.47879615", "0.47224522", "0.4716671", "0.46345818", "0.44537893", "0.4429202", "0.42752665", "0.42705268", "0.42685997", "0.42263883", "0.42169845", "0.4...
0.8310235
0
IsScriptRenderDelaying returns true if the node has one of these values for attribute 'customelement': ampdynamiccssclasses, ampexperiment, ampstory.
func IsScriptRenderDelaying(n *html.Node) bool { if n.DataAtom != atom.Script { return false } if IsScriptAMPViewer(n) { return true } if v, ok := htmlnode.GetAttributeVal(n, "", AMPCustomElement); ok { // TODO(b/77581738): Remove amp-story from this list. return (v == AMPDynamicCSSClasses || v == AMPExperiment || v == AMPStory) } return false }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func IsScriptAMPRuntime(n *html.Node) bool {\n\tif n.DataAtom != atom.Script {\n\t\treturn false\n\t}\n\tif v, ok := htmlnode.GetAttributeVal(n, \"\", \"src\"); ok {\n\t\treturn htmlnode.HasAttribute(n, \"\", \"async\") &&\n\t\t\t!IsScriptAMPExtension(n) &&\n\t\t\tstrings.HasPrefix(v, AMPCacheRootURL) &&\n\t\t\t(s...
[ "0.54627293", "0.5384497", "0.52935505", "0.52349025", "0.5183518", "0.51164085", "0.5027169", "0.49183807", "0.48826963", "0.48015487", "0.47464487", "0.47278962", "0.4711677", "0.4694349", "0.46618658", "0.46478906", "0.46302602", "0.460766", "0.45946616", "0.45566878", "0....
0.8075554
0
NewDOM constructs and returns a pointer to a DOM struct by finding the HTML nodes relevant to an AMP Document or an error if there was a problem. TODO(alin04): I don't think this can EVER return an error. The golang parser creates all these nodes if they're missing.
func NewDOM(n *html.Node) (*DOM, error) { var ok bool d := &DOM{RootNode: n} if d.HTMLNode, ok = htmlnode.FindNode(n, atom.Html); !ok { return d, errors.New("missing <html> node") } if d.HeadNode, ok = htmlnode.FindNode(d.HTMLNode, atom.Head); !ok { return d, errors.New("missing <head> node") } if d.BodyNode, ok = htmlnode.FindNode(d.HTMLNode, atom.Body); !ok { return d, errors.New("missing <body> node") } return d, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewDOM() *DOM {\n\treturn &DOM{\n\t\tGlobalInst: map[string]*Instruction{},\n\t\tScenarios: map[string]*Instruction{},\n\t\tSubScenarios: map[string]*Instruction{},\n\t\tOtherScenarios: map[string]map[string]*Instruction{},\n\t\tOtherSubScenarios: map[string]map[string]*Instruction{},\n...
[ "0.64554495", "0.5551131", "0.5162261", "0.49324796", "0.4877913", "0.4703432", "0.46724957", "0.45684707", "0.45434424", "0.45177507", "0.44259483", "0.43745458", "0.43526706", "0.4270929", "0.42546213", "0.4241416", "0.41487038", "0.41184837", "0.40987206", "0.4083889", "0....
0.6929188
0
InitStudentsSubscriptionsHandler initialize studentsSubscriptions router
func InitStudentsSubscriptionsHandler(r *atreugo.Router, s *service.Service) { r.GET("/", getAllStudentsSubscriptions(s)) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *StanServer) initSubscriptions() error {\n\n\t// Do not create internal subscriptions in clustered mode,\n\t// the leader will when it gets elected.\n\tif !s.isClustered {\n\t\tcreateSubOnClientPublish := true\n\n\t\tif s.partitions != nil {\n\t\t\t// Receive published messages from clients, but only on th...
[ "0.6481434", "0.59553516", "0.54364514", "0.5402741", "0.53732777", "0.5366589", "0.53303486", "0.53290343", "0.5289545", "0.5288495", "0.52735746", "0.5230477", "0.5226967", "0.5205135", "0.5198127", "0.5193747", "0.5155629", "0.5143773", "0.5122913", "0.5113694", "0.5110221...
0.8779293
0
convert entities to a response
func getLocaleUpdate(localeId string) (map[string]interface{}, error) { resp := map[string]interface{}{} entities, err := model.GetEntitiesAtLocale(localeId) if err != nil { return resp, fmt.Errorf("error retrieving entities to broadcast for locale %v: %v", localeId, err) } resp["entities"] = entities if err != nil { return resp, fmt.Errorf("error marshalling response: %v", err) } return resp, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r Response) AsEntities() (*Entities, bool) {\n\treturn nil, false\n}", "func (rb ResponseBase) AsEntities() (*Entities, bool) {\n\treturn nil, false\n}", "func (r Response) WriteEntity(value interface{}) Response {\n\tif \"\" == r.accept || \"*/*\" == r.accept {\n\t\tfor _, each := range r.produces {\n\t...
[ "0.6419725", "0.6268671", "0.6093652", "0.60556287", "0.6050197", "0.5891716", "0.58705986", "0.5824377", "0.57977885", "0.57548875", "0.57182443", "0.5651574", "0.5629503", "0.5601155", "0.5591449", "0.5591449", "0.5590175", "0.5575622", "0.551894", "0.55042535", "0.5479917"...
0.0
-1
/ Notes: Only allow entities manipulate locales they exist in
func broadcastLocale(localeId string, stop chan bool) error { ticker := time.NewTicker(BroadcastInterval * time.Second) for { select { case <-ticker.C: // todo ensure the query never takes more than BroadcastInterval time resp, _ := getLocaleUpdate(localeId) err := BroadcastToLocale(localeId, resp) if err != nil { log.Warnf("Error broadcasting: %v", err) } case <-stop: ticker.Stop() log.Debug("Manually stopping broadcast") } } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getLocaleUpdate(localeId string) (map[string]interface{}, error) {\n\tresp := map[string]interface{}{}\n\n\tentities, err := model.GetEntitiesAtLocale(localeId)\n\tif err != nil {\n\t\treturn resp, fmt.Errorf(\"error retrieving entities to broadcast for locale %v: %v\", localeId, err)\n\t}\n\n\tresp[\"entitie...
[ "0.5990479", "0.57793176", "0.57150275", "0.5671891", "0.56348187", "0.5617904", "0.5606874", "0.5580314", "0.55197036", "0.5379397", "0.5370767", "0.53688985", "0.53483874", "0.53311455", "0.53258777", "0.5303042", "0.5290124", "0.5245603", "0.5230171", "0.5212097", "0.51987...
0.0
-1
parse string map into local struct
func parseLocale(data interface{}) (model.Locale, error) { var locale model.Locale mData, err := json.Marshal(data) if err != nil { return locale, fmt.Errorf("failed to parse locale from data: %v", err) } err = json.Unmarshal(mData, &locale) if err != nil { return locale, fmt.Errorf("failed to un parse locale from data: %v", err) } return locale, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func mapFromString(s string, t reflect.Type) (interface{}, error) {\n\tmp := reflect.New(t)\n\tif s != \"\" {\n\t\terr := json.Unmarshal([]byte(s), mp.Interface())\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t} else {\n\t\tmp.Elem().Set(reflect.MakeMap(t))\n\t}\n\treturn mp.Elem().Interface(), nil\n}", ...
[ "0.6854407", "0.64725333", "0.6340307", "0.6208719", "0.6053783", "0.60045505", "0.59692", "0.59418225", "0.5891847", "0.587586", "0.5810818", "0.5806822", "0.57869965", "0.5742572", "0.5738563", "0.5701027", "0.5696601", "0.56867707", "0.5680063", "0.56742865", "0.5658497", ...
0.0
-1
Compile will compile solution if not yet compiled. The compilation prosess will execute compile script of the language. It will use debugcompile script when debug parameter is true. When debug is true, but the language is not debuggable (doesn't contain debugcompile script), an ErrLanguageNotDebuggable error will returned. This function will execute the compilation script (could be compile/debugcompile) that defined in language definition. This execution could be skipped when the solution already compiled before.
func (cptool *CPTool) Compile(ctx context.Context, solution Solution, debug bool) (CompilationResult, error) { language := solution.Language if debug && !language.Debuggable { return CompilationResult{}, ErrLanguageNotDebuggable } targetDir := cptool.getCompiledDirectory(solution, debug) cptool.fs.MkdirAll(targetDir, os.ModePerm) targetPath := cptool.getCompiledTarget(solution, debug) if cptool.logger != nil { cptool.logger.Println(logger.VERBOSE, "Compiling to: ", targetPath) } info, err := cptool.fs.Stat(targetPath) if err == nil { compiledTime := info.ModTime() if compiledTime.After(solution.LastUpdated) { return CompilationResult{ Skipped: true, TargetPath: targetPath, }, nil } } commandPath := language.CompileScript if debug { commandPath = language.DebugScript } if cptool.logger != nil { cptool.logger.Println(logger.VERBOSE, "Compiling using script: ", commandPath) } cmd := cptool.exec.CommandContext(ctx, commandPath, solution.Path, targetPath) stderr, err := cmd.StderrPipe() if err != nil { return CompilationResult{}, err } err = cmd.Start() if err != nil { return CompilationResult{}, err } compilationError, err := ioutil.ReadAll(stderr) if err != nil { return CompilationResult{}, err } err = cmd.Wait() if err != nil { if cptool.logger != nil { cptool.logger.Print(logger.VERBOSE, "Compilation script execution giving error result") } return CompilationResult{ErrorMessage: string(compilationError)}, err } return CompilationResult{ Skipped: false, TargetPath: targetPath, }, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func Compile(ctx context.Context, targets []string) error {\n\tlog := logger.NewDefault(\"compile\")\n\tlog.SetLogLevel(logger.LevelInfo)\n\tif consts.IsDebugMode(ctx) {\n\t\tlog.SetLogLevel(logger.LevelDebug)\n\t}\n\n\tconfigManager, err := configmanager.NewConfigManager(log)\n\tif err != nil {\n\t\treturn err\n\...
[ "0.5822461", "0.5743868", "0.53007513", "0.5181535", "0.51645374", "0.5097689", "0.500081", "0.47883692", "0.47864297", "0.47329405", "0.46677637", "0.4661549", "0.4639248", "0.4619214", "0.45559263", "0.454181", "0.45335022", "0.44954574", "0.44724452", "0.444016", "0.440288...
0.77606845
0
CompileByName will compile solution if not yet compiled. This method will search the language and solution by its name and then call Compile method. This method will return an error if the language or solution with it's name doesn't exist.
func (cptool *CPTool) CompileByName(ctx context.Context, languageName string, solutionName string, debug bool) (CompilationResult, error) { start := time.Now() language, err := cptool.GetLanguageByName(languageName) if err != nil { return CompilationResult{}, err } if cptool.logger != nil { cptool.logger.Println(logger.VERBOSE, "Compiling using language:", language.Name) } solution, err := cptool.GetSolution(solutionName, language) if err != nil { return CompilationResult{}, err } if cptool.logger != nil { cptool.logger.Println(logger.VERBOSE, "Compiling solution:", solution.Name) } result, err := cptool.Compile(ctx, solution, debug) if err != nil { return result, err } result.Duration = time.Since(start) return result, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (cptool *CPTool) Compile(ctx context.Context, solution Solution, debug bool) (CompilationResult, error) {\n\tlanguage := solution.Language\n\tif debug && !language.Debuggable {\n\t\treturn CompilationResult{}, ErrLanguageNotDebuggable\n\t}\n\n\ttargetDir := cptool.getCompiledDirectory(solution, debug)\n\tcpto...
[ "0.5584038", "0.50285786", "0.50141174", "0.49621782", "0.4875996", "0.48572075", "0.4854768", "0.4850871", "0.4748288", "0.46886098", "0.46881205", "0.4676761", "0.46507636", "0.4649425", "0.4638744", "0.4593714", "0.4560371", "0.45371085", "0.45201123", "0.4494501", "0.4493...
0.8204627
0
GetCompilationRootDir returns directory of all compiled solutions.
func (cptool *CPTool) GetCompilationRootDir() string { return path.Join(cptool.workingDirectory, ".cptool/solutions") }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func GetRootProjectDir() (string, error) {\n\twd, err := os.Getwd()\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\tfor !strings.HasSuffix(wd, \"git2consul-go\") {\n\t\tif wd == \"/\" {\n\t\t\treturn \"\", errors.New(`cannot find project directory, \"/\" reached`)\n\t\t}\n\t\twd = filepath.Dir(wd)\n\t}\n\treturn ...
[ "0.6979527", "0.61517763", "0.6130268", "0.61221904", "0.60577995", "0.601363", "0.60060436", "0.59370095", "0.59113044", "0.58437407", "0.5744886", "0.5708629", "0.5654415", "0.5567339", "0.55459046", "0.55438185", "0.5506007", "0.54859716", "0.5441813", "0.5428665", "0.5411...
0.8156449
0
initializes a queryTerm from a given Filter
func (dg *dependencyGraph) makeQueryTerm(t sparql.Triple) *queryTerm { qt := &queryTerm{ t, []*queryTerm{}, []string{}, } if qt.Subject.IsVariable() { dg.variables[qt.Subject.String()] = false qt.variables = append(qt.variables, qt.Subject.String()) } if qt.Predicates[0].Predicate.IsVariable() { dg.variables[qt.Predicates[0].Predicate.String()] = false qt.variables = append(qt.variables, qt.Predicates[0].Predicate.String()) } if qt.Object.IsVariable() { dg.variables[qt.Object.String()] = false qt.variables = append(qt.variables, qt.Object.String()) } return qt }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (f *FilterOp) Term(field string, value interface{}) *FilterOp {\n\tif len(f.TermMap) == 0 {\n\t\tf.TermMap = make(map[string]interface{})\n\t}\n\n\tf.TermMap[field] = value\n\treturn f\n}", "func NewFilterType(t string) (FilterType, error) {\n\t_, ok := fts[t]\n\tif !ok {\n\t\treturn \"\", fmt.Errorf(\"unsu...
[ "0.6605704", "0.5789612", "0.57304215", "0.5618418", "0.5567405", "0.5561679", "0.5525997", "0.5523312", "0.5509586", "0.5504292", "0.5501908", "0.5493613", "0.5439888", "0.5420406", "0.5420044", "0.5417559", "0.540583", "0.5404166", "0.54037094", "0.5397271", "0.53965527", ...
0.50716466
50
returns true if two query terms are equal
func (qt *queryTerm) equals(qt2 *queryTerm) bool { return qt.Subject == qt2.Subject && qt.Object == qt2.Object && reflect.DeepEqual(qt.Predicates, qt2.Predicates) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (term *Term) Equal(other *Term) bool {\n\tif term == nil && other != nil {\n\t\treturn false\n\t}\n\tif term != nil && other == nil {\n\t\treturn false\n\t}\n\tif term == other {\n\t\treturn true\n\t}\n\n\t// TODO(tsandall): This early-exit avoids allocations for types that have\n\t// Equal() functions that j...
[ "0.6278379", "0.6265848", "0.6265848", "0.58121437", "0.57692087", "0.57653165", "0.56731814", "0.56653947", "0.56645983", "0.5595077", "0.5544077", "0.5541766", "0.55375445", "0.5516763", "0.5507575", "0.54917985", "0.5487973", "0.54676956", "0.5441852", "0.54316646", "0.538...
0.71522367
0
NewGitHubClient creates and initializes a new GitHubClient
func NewGitHubClient(owner, repo, token string) (GitHub, error) { var client *github.Client if token != "" { ts := oauth2.StaticTokenSource(&oauth2.Token{ AccessToken: token, }) tc := oauth2.NewClient(context.TODO(), ts) client = github.NewClient(tc) } else { client = github.NewClient(nil) } return &Client{ Owner: owner, Repo: repo, Client: client, }, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func NewGitHubClient(httpClient *http.Client) GitHubClient {\n\tclient := github.NewClient(httpClient)\n\n\treturn GitHubClient{\n\t\tRepositories: client.Repositories,\n\t}\n}", "func newTestGitHubClient() *Client {\n\tgclient := github.NewClient(nil)\n\tclient := Client{\n\t\tclient: gclient,\n\t}\n\treturn &c...
[ "0.7759529", "0.77101016", "0.73958576", "0.72508085", "0.72462213", "0.71401393", "0.711106", "0.7109243", "0.6980343", "0.69798774", "0.6979324", "0.6939871", "0.6929803", "0.6923655", "0.6916688", "0.68918586", "0.6881709", "0.6701082", "0.6700863", "0.6653842", "0.6622923...
0.7156345
5
GetRepository fetches a repository
func (c *Client) GetRepository(ctx context.Context) (*github.Repository, error) { repo, res, err := c.Repositories.Get(context.TODO(), c.Owner, c.Repo) if err != nil { if res.StatusCode == http.StatusNotFound { return nil, nil } panic(err) } return repo, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func GetRepository(ctx *pulumi.Context,\n\tname string, id pulumi.IDInput, state *RepositoryState, opts ...pulumi.ResourceOption) (*Repository, error) {\n\tvar resource Repository\n\terr := ctx.ReadResource(\"aws-native:ecr:Repository\", name, id, state, &resource, opts...)\n\tif err != nil {\n\t\treturn nil, err\...
[ "0.76943356", "0.74888605", "0.7419276", "0.73818403", "0.73109317", "0.73045814", "0.72826105", "0.72484", "0.7221816", "0.72175574", "0.72043943", "0.71991307", "0.71787184", "0.7144311", "0.7124235", "0.7099846", "0.70911855", "0.6998159", "0.695291", "0.69476277", "0.6937...
0.669049
29
CreateRelease creates a new release object in the GitHub API
func (c *Client) CreateRelease(ctx context.Context, req *github.RepositoryRelease) (*github.RepositoryRelease, error) { release, res, err := c.Repositories.CreateRelease(context.TODO(), c.Owner, c.Repo, req) if err != nil { return nil, errors.Wrap(err, "failed to create a release") } if res.StatusCode != http.StatusCreated { return nil, errors.Errorf("create release: invalid status: %s", res.Status) } return release, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func CreateRelease(res http.ResponseWriter, req *http.Request) {\n\tres.Header().Set(\"Content-Type\", \"application/json\")\n\tc := Release{\"relid\", \"http://ispw:8080/ispw/ispw/releases/relid\"}\n\toutgoingJSON, err := json.Marshal(c)\n\tif err != nil {\n\t\tlog.Println(err.Error())\n\t\thttp.Error(res, err.Er...
[ "0.82238644", "0.8206941", "0.80329555", "0.7918589", "0.7841578", "0.7819708", "0.76169693", "0.7502176", "0.719978", "0.71835524", "0.68819135", "0.68103856", "0.67815125", "0.66911125", "0.65367913", "0.6471042", "0.64619577", "0.63036394", "0.62942827", "0.6293456", "0.62...
0.7646442
6
GetRelease queries the GitHub API for a specified release object
func (c *Client) GetRelease(ctx context.Context, tag string) (*github.RepositoryRelease, error) { // Check Release whether already exists or not release, res, err := c.Repositories.GetReleaseByTag(context.TODO(), c.Owner, c.Repo, tag) if err != nil { if res == nil { return nil, errors.Wrapf(err, "failed to get release tag: %s", tag) } // TODO(tcnksm): Handle invalid token if res.StatusCode != http.StatusNotFound { return nil, errors.Wrapf(err, "get release tag: invalid status: %s", res.Status) } return nil, nil } return release, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func GetRelease(ctx *context.APIContext) {\n\t// swagger:operation GET /repos/{owner}/{repo}/releases/{id} repository repoGetRelease\n\t// ---\n\t// summary: Get a release\n\t// produces:\n\t// - application/json\n\t// parameters:\n\t// - name: owner\n\t// in: path\n\t// description: owner of the repo\n\t// ...
[ "0.78475475", "0.75622654", "0.73541814", "0.7291853", "0.7269361", "0.7257871", "0.70396906", "0.7035385", "0.6988299", "0.695543", "0.67087036", "0.67073405", "0.665561", "0.66521287", "0.6647988", "0.6646991", "0.65817267", "0.64389217", "0.64276576", "0.6333727", "0.62475...
0.71325344
6
EditRelease edit a release object within the GitHub API
func (c *Client) EditRelease(ctx context.Context, releaseID int64, req *github.RepositoryRelease) (*github.RepositoryRelease, error) { var release *github.RepositoryRelease err := retry.Retry(3, 3*time.Second, func() error { var ( res *github.Response err error ) release, res, err = c.Repositories.EditRelease(context.TODO(), c.Owner, c.Repo, releaseID, req) if err != nil { return errors.Wrapf(err, "failed to edit release: %d", releaseID) } if res.StatusCode != http.StatusOK { return errors.Errorf("edit release: invalid status: %s", res.Status) } return nil }) return release, err }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func EditRelease(ctx *context.APIContext) {\n\t// swagger:operation PATCH /repos/{owner}/{repo}/releases/{id} repository repoEditRelease\n\t// ---\n\t// summary: Update a release\n\t// consumes:\n\t// - application/json\n\t// produces:\n\t// - application/json\n\t// parameters:\n\t// - name: owner\n\t// in: path...
[ "0.797417", "0.63441503", "0.6101559", "0.60008246", "0.5971021", "0.5868578", "0.583974", "0.57195973", "0.57152265", "0.5610921", "0.5536156", "0.55010283", "0.5471195", "0.5419356", "0.54037344", "0.5372626", "0.5371148", "0.5351311", "0.5314843", "0.5248477", "0.52337307"...
0.758511
1
ListReleases lists Releases given a repository
func (c *Client) ListReleases(ctx context.Context) ([]*github.RepositoryRelease, error) { result := []*github.RepositoryRelease{} page := 1 for { assets, res, err := c.Repositories.ListReleases(context.TODO(), c.Owner, c.Repo, &github.ListOptions{Page: page}) if err != nil { return nil, errors.Wrap(err, "failed to list releases") } if res.StatusCode != http.StatusOK { return nil, errors.Errorf("list repository releases: invalid status code: %s", res.Status) } result = append(result, assets...) if res.NextPage <= page { break } page = res.NextPage } return result, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func ListReleases(ctx *context.APIContext) {\n\t// swagger:operation GET /repos/{owner}/{repo}/releases repository repoListReleases\n\t// ---\n\t// summary: List a repo's releases\n\t// produces:\n\t// - application/json\n\t// parameters:\n\t// - name: owner\n\t// in: path\n\t// description: owner of the repo\...
[ "0.84172493", "0.7788706", "0.7698476", "0.75473577", "0.74319696", "0.7400406", "0.73194414", "0.7206904", "0.71547836", "0.7135346", "0.70355684", "0.6940326", "0.6883375", "0.6841564", "0.6699606", "0.6596501", "0.65950054", "0.6545528", "0.6530167", "0.652993", "0.6440224...
0.77434057
2
UploadAsset uploads specified assets to a given release object
func (c *Client) UploadAsset(ctx context.Context, releaseID int64, filename string) (*github.ReleaseAsset, error) { filename, err := filepath.Abs(filename) if err != nil { return nil, errors.Wrap(err, "failed to get abs path") } f, err := os.Open(filename) if err != nil { return nil, errors.Wrap(err, "failed to open file") } opts := &github.UploadOptions{ // Use base name by default Name: filepath.Base(filename), } var asset *github.ReleaseAsset err = retry.Retry(3, 3*time.Second, func() error { var ( res *github.Response err error ) asset, res, err = c.Repositories.UploadReleaseAsset(context.TODO(), c.Owner, c.Repo, releaseID, opts, f) if err != nil { return errors.Wrapf(err, "failed to upload release asset: %s", filename) } switch res.StatusCode { case http.StatusCreated: return nil case 422: return errors.Errorf( "upload release asset: invalid status code: %s", "422 (this is probably because the asset already uploaded)") default: return errors.Errorf( "upload release asset: invalid status code: %s", res.Status) } }) return asset, err }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Release) UploadAsset(path string) error {\n\tfile, err := os.OpenFile(path, os.O_RDONLY, 0755)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer file.Close()\n\tasset, _, err := r.client.Repositories.UploadReleaseAsset(context.Background(), r.owner, r.repository, r.ID, &gogithub.UploadOptions{\n\t\tName: f...
[ "0.7155658", "0.67493165", "0.62648684", "0.6197935", "0.6143918", "0.5810587", "0.5751974", "0.5732749", "0.5682815", "0.56697494", "0.5604278", "0.558865", "0.5574292", "0.55547374", "0.5546097", "0.55362713", "0.5516788", "0.54986763", "0.5481066", "0.5473339", "0.54333305...
0.682041
1
ListAssets lists assets associated with a given release
func (c *Client) ListAssets(ctx context.Context, releaseID int64) ([]*github.ReleaseAsset, error) { result := []*github.ReleaseAsset{} page := 1 for { assets, res, err := c.Repositories.ListReleaseAssets(context.TODO(), c.Owner, c.Repo, releaseID, &github.ListOptions{Page: page}) if err != nil { return nil, errors.Wrap(err, "failed to list assets") } if res.StatusCode != http.StatusOK { return nil, errors.Errorf("list release assets: invalid status code: %s", res.Status) } result = append(result, assets...) if res.NextPage <= page { break } page = res.NextPage } return result, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func ListReleases(ctx *context.APIContext) {\n\t// swagger:operation GET /repos/{owner}/{repo}/releases repository repoListReleases\n\t// ---\n\t// summary: List a repo's releases\n\t// produces:\n\t// - application/json\n\t// parameters:\n\t// - name: owner\n\t// in: path\n\t// description: owner of the repo\...
[ "0.6093649", "0.6046222", "0.59944326", "0.59482193", "0.59288824", "0.58725035", "0.5847745", "0.5836617", "0.5797065", "0.5786176", "0.56488395", "0.5619454", "0.5564959", "0.55334187", "0.55060554", "0.55030614", "0.5474657", "0.5451275", "0.5429421", "0.5429421", "0.54062...
0.77932364
0
set up the database connection
func init() { //load in environment variables from .env //will print error message when running from docker image //because env file is passed into docker run command envErr := godotenv.Load("/home/ubuntu/go/src/github.com/200106-uta-go/BAM-P2/.env") if envErr != nil { if !strings.Contains(envErr.Error(), "no such file or directory") { log.Println("Error loading .env: ", envErr) } } var server = os.Getenv("DB_SERVER") var dbPort = os.Getenv("DB_PORT") var dbUser = os.Getenv("DB_USER") var dbPass = os.Getenv("DB_PASS") var db = os.Getenv("DB_NAME") // Build connection string connString := fmt.Sprintf("server=%s;user id=%s;password=%s;port=%s;database=%s;", server, dbUser, dbPass, dbPort, db) // Create connection pool var err error database, err = sql.Open("sqlserver", connString) if err != nil { log.Fatal("Error creating connection pool: ", err.Error()) } ctx := context.Background() err = database.PingContext(ctx) httputil.GenericErrHandler("error", err) //create user table if it doesn't exist statement, err := database.Prepare(`IF NOT EXISTS (SELECT * FROM sysobjects WHERE name='user_table' and xtype='U') CREATE TABLE user_table (id INT NOT NULL IDENTITY(1,1) PRIMARY KEY, username VARCHAR(255), password VARCHAR(255))`) if err != nil { log.Fatal(err) } _, err = statement.Exec() if err != nil { log.Fatalln(err) } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *syncer) dbSetup() error {\n\ts.logger.Info(\"Connecting to the database\")\n\n\tsqlDB, err := sql.Open(\"sqlite3_with_fk\", s.config.Database)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\t// Setup the DB struct\n\ts.db = sqlDB\n\n\t// We don't want multiple clients during setup\n\ts.db.SetMaxOpenConns(1)\...
[ "0.76872724", "0.744406", "0.7325846", "0.7274146", "0.72703093", "0.71773756", "0.7104648", "0.7033461", "0.70319754", "0.70185804", "0.7011035", "0.7006", "0.70054144", "0.7000145", "0.699882", "0.69944245", "0.6985961", "0.6961673", "0.6960904", "0.6960904", "0.6959783", ...
0.7022797
9
middleware to send all http requests to the logger
func logRequest(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { log.Println(r.RequestURI) next.ServeHTTP(w, r) }) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func logAllRequestsMiddleware(next http.Handler) http.Handler {\r\n\treturn http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {\r\n\t\tlogger.Info(\"%s %s\", r.Method, r.URL.Path)\r\n\r\n\t\tnext.ServeHTTP(w, r)\r\n\t})\r\n}", "func Logger(next http.Handler) http.Handler {\n\treturn http.HandlerFunc(...
[ "0.7804974", "0.7682003", "0.74303913", "0.7404096", "0.73647726", "0.7348642", "0.7313029", "0.73093975", "0.7300574", "0.7281842", "0.72493076", "0.7230931", "0.72171444", "0.720737", "0.7204911", "0.7202087", "0.7200994", "0.71565276", "0.7132212", "0.712089", "0.7096644",...
0.672749
56
TrustAnchorString convert a TrustAnchor to a string encoded as XML.
func TrustAnchorString(t []*TrustAnchor) string { xta := new(XMLTrustAnchor) xta.KeyDigest = make([]*XMLKeyDigest, 0) for _, ta := range t { xta.Id = ta.Id // Sets the everytime, but that is OK. xta.Source = ta.Source xta.Zone = ta.Anchor.Hdr.Name xkd := new(XMLKeyDigest) xkd.Id = ta.AnchorId xkd.ValidFrom = ta.ValidFrom.Format("2006-01-02T15:04:05-07:00") if !ta.ValidUntil.IsZero() { xkd.ValidUntil = ta.ValidUntil.Format("2006-01-02T15:04:05-07:00") } xkd.KeyTag = ta.Anchor.KeyTag xkd.Algorithm = ta.Anchor.Algorithm xkd.DigestType = ta.Anchor.DigestType xkd.Digest = ta.Anchor.Digest xta.KeyDigest = append(xta.KeyDigest, xkd) } b, _ := xml.MarshalIndent(xta, "", "\t") return string(b) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (me TxsdPresentationAttributesTextContentElementsTextAnchor) ToXsdtString() xsdt.String {\n\treturn xsdt.String(me)\n}", "func (me TxsdPresentationAttributesTextContentElementsTextAnchor) String() string {\n\treturn xsdt.String(me).String()\n}", "func (s TlsValidationContextAcmTrust) String() string {\n\t...
[ "0.57817805", "0.5648022", "0.5617549", "0.54700416", "0.5343101", "0.52947736", "0.52883303", "0.51470983", "0.5059527", "0.5048072", "0.49670568", "0.4913151", "0.4862687", "0.4851099", "0.4848319", "0.48402482", "0.4776784", "0.47474617", "0.47324777", "0.47219345", "0.472...
0.7828417
0
ReadTrustAnchor reads a root trust anchor from: and returns the data or an error.
func ReadTrustAnchor(q io.Reader) ([]*TrustAnchor, error) { d := xml.NewDecoder(q) t := new(XMLTrustAnchor) if e := d.Decode(t); e != nil { return nil, e } ta := make([]*TrustAnchor, 0) var err error for _, digest := range t.KeyDigest { t1 := new(TrustAnchor) t1.Id = t.Id t1.Source = t.Source t1.AnchorId = digest.Id if t1.ValidFrom, err = time.Parse("2006-01-02T15:04:05-07:00", digest.ValidFrom); err != nil { return nil, err } if digest.ValidUntil != "" { if t1.ValidUntil, err = time.Parse("2006-01-02T15:04:05-07:00", digest.ValidUntil); err != nil { return nil, err } } d := new(RR_DS) d.Hdr = RR_Header{Name: t.Zone, Class: ClassINET, Rrtype: TypeDS} d.KeyTag = digest.KeyTag d.Algorithm = digest.Algorithm d.DigestType = digest.DigestType d.Digest = digest.Digest t1.Anchor = d // Some checks here too? ta = append(ta, t1) } return ta, nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getTrustAnchor() (*trustAnchor, error) {\n\tresp, err := http.Get(trustAnchorURL)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif resp.StatusCode != http.StatusOK {\n\t\treturn nil, fmt.Errorf(\"bad http response: %d\", resp.StatusCode)\n\t}\n\tbyteValue, err := ioutil.ReadAll(resp.Body)\n\tif err != nil {...
[ "0.70352846", "0.54166305", "0.5376895", "0.5034828", "0.50329363", "0.5005947", "0.4975937", "0.49141535", "0.49141535", "0.47976542", "0.4571982", "0.45457885", "0.44578916", "0.44233346", "0.44013694", "0.43893903", "0.4377805", "0.4350652", "0.4340766", "0.42625472", "0.4...
0.75947404
0
NewStreamToSubStream instantiates a new StreamToSubStream process
func NewStreamToSubStream(wf *scipipe.Workflow, name string) *StreamToSubStream { stss := &StreamToSubStream{ name: name, In: scipipe.NewInPort("in"), OutSubStream: scipipe.NewOutPort("out_substream"), } wf.AddProc(stss) return stss }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (s *Stream) CreateSubStream(headers http.Header, fin bool) (*Stream, error) {\n\treturn s.conn.CreateStream(headers, s, fin)\n}", "func newStream(id common.StreamId, hostStr string, handler MutationHandler) (*Stream, error) {\n\n\t// TODO: use constant\n\tmutch := make(chan interface{}, 1000)\n\tstopch := m...
[ "0.68944746", "0.63039505", "0.62568027", "0.6222708", "0.61755145", "0.61426306", "0.60578835", "0.5902729", "0.58879554", "0.58243144", "0.5664884", "0.5650889", "0.56348413", "0.5619227", "0.5600658", "0.55868405", "0.55131215", "0.5471899", "0.5466271", "0.54618245", "0.5...
0.6649371
1
Name returns the name of the StreamToSubStream process
func (p *StreamToSubStream) Name() string { return p.name }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (o *Echo) GetStreamName() string {\n\treturn \"\"\n}", "func (s *Stream) Name() string { return s.file.Name() }", "func (o *ExportData) GetStreamName() string {\n\treturn \"\"\n}", "func (o *Kanban) GetStreamName() string {\n\treturn \"\"\n}", "func (o *ProjectWebhook) GetStreamName() string {\n\tretu...
[ "0.6440815", "0.62418556", "0.61738175", "0.61010945", "0.6079546", "0.60654175", "0.6047112", "0.58845854", "0.58486265", "0.5778065", "0.56679744", "0.56591153", "0.5604969", "0.5579104", "0.5553676", "0.5548935", "0.55190974", "0.5492352", "0.54096514", "0.5362376", "0.534...
0.75903994
0
Connected tells whether all the ports of the process are connected
func (p *StreamToSubStream) Connected() bool { return p.In.Connected() && p.OutSubStream.Connected() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (r *Runtime) IsConnected() bool { return r.isConnected }", "func (o *Switch) Connected() bool {\n\tfor _, out := range o.outputs {\n\t\tif !out.Connected() {\n\t\t\treturn false\n\t\t}\n\t}\n\treturn true\n}", "func (d *Device) Connected() bool {\n\tdata := []byte{0}\n\td.bus.ReadRegister(uint8(d.Address)...
[ "0.7308632", "0.70478034", "0.69318163", "0.6841799", "0.6802986", "0.68025744", "0.6785902", "0.67671365", "0.6764436", "0.6752102", "0.6681452", "0.66715723", "0.66356033", "0.65785146", "0.6510589", "0.6454273", "0.6446856", "0.64368707", "0.64300346", "0.6411145", "0.6408...
0.602785
62
InPorts returns all the inports for the process
func (p *StreamToSubStream) InPorts() map[string]*scipipe.InPort { return map[string]*scipipe.InPort{ p.In.Name(): p.In, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func getOpenPorts(n int) []string {\n\tports := []string{}\n\tfor i := 0; i < n; i++ {\n\t\tts := httptest.NewServer(http.NewServeMux())\n\t\tdefer ts.Close()\n\t\tu, err := url.Parse(ts.URL)\n\t\trtx.Must(err, \"Could not parse url to local server:\", ts.URL)\n\t\tports = append(ports, \":\"+u.Port())\n\t}\n\tret...
[ "0.64647835", "0.6422319", "0.63509274", "0.63215864", "0.61700624", "0.6103362", "0.6066713", "0.59493285", "0.5909167", "0.58834195", "0.5870035", "0.5831617", "0.5827247", "0.5792798", "0.5737", "0.57368517", "0.5730379", "0.56791705", "0.5650435", "0.5606307", "0.55864406...
0.66762453
0
OutPorts returns all the outports for the process
func (p *StreamToSubStream) OutPorts() map[string]*scipipe.OutPort { return map[string]*scipipe.OutPort{ p.OutSubStream.Name(): p.OutSubStream, } }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func exposedPorts(node *parser.Node) [][]string {\n\tvar allPorts [][]string\n\tvar ports []string\n\tfroms := FindAll(node, command.From)\n\texposes := FindAll(node, command.Expose)\n\tfor i, j := len(froms)-1, len(exposes)-1; i >= 0; i-- {\n\t\tfor ; j >= 0 && exposes[j] > froms[i]; j-- {\n\t\t\tports = append(n...
[ "0.6585004", "0.63949406", "0.62217176", "0.62065995", "0.6160004", "0.6110914", "0.60794294", "0.60426825", "0.5992903", "0.59849274", "0.59713376", "0.5946364", "0.59203386", "0.58586967", "0.5844431", "0.58431566", "0.5813805", "0.57923704", "0.57910407", "0.5782212", "0.5...
0.67671174
0
Run runs the StreamToSubStream
func (p *StreamToSubStream) Run() { defer p.OutSubStream.Close() scipipe.Debug.Println("Creating new information packet for the substream...") subStreamIP := scipipe.NewIP("") scipipe.Debug.Printf("Setting in-port of process %s to IP substream field\n", p.Name()) subStreamIP.SubStream = p.In scipipe.Debug.Printf("Sending sub-stream IP in process %s...\n", p.Name()) p.OutSubStream.Send(subStreamIP) scipipe.Debug.Printf("Done sending sub-stream IP in process %s.\n", p.Name()) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (transmuxer *Transmuxer) Run() {\n\tif transmuxer.closed {\n\t\treturn\n\t}\n\n\tif transmuxer.running {\n\t\treturn\n\t}\n\n\ttransmuxer.running = true\n\n\tfor {\n\t\tvar sample float64\n\n\t\tfor _, streamer := range transmuxer.Streamers {\n\t\t\tnewSample, err := streamer.ReadSample()\n\t\t\tif err != nil...
[ "0.68090886", "0.6607723", "0.62104803", "0.6052246", "0.60397995", "0.6036606", "0.6014039", "0.5855327", "0.584613", "0.5787809", "0.5786557", "0.57808554", "0.57723176", "0.5762391", "0.5720863", "0.5698172", "0.56778085", "0.56413287", "0.56297857", "0.5620973", "0.559650...
0.79116404
0
reconcileStorage will ensure that the storage options for the ArgoCDExport are present.
func (r *ReconcileArgoCDExport) reconcileStorage(cr *argoprojv1a1.ArgoCDExport) error { if cr.Spec.Storage == nil { cr.Spec.Storage = &argoprojv1a1.ArgoCDExportStorageSpec{ Backend: common.ArgoCDExportStorageBackendLocal, } return r.Client.Update(context.TODO(), cr) } // Local storage if err := r.reconcileLocalStorage(cr); err != nil { return err } return nil }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (p *PBM) ResyncStorage(l *log.Event) error {\n\tstg, err := p.GetStorage(l)\n\tif err != nil {\n\t\treturn errors.Wrap(err, \"unable to get backup store\")\n\t}\n\n\t_, err = stg.FileStat(StorInitFile)\n\tif errors.Is(err, storage.ErrNotExist) {\n\t\terr = stg.Save(StorInitFile, bytes.NewBufferString(version....
[ "0.59389216", "0.5565799", "0.5399797", "0.52743936", "0.5260172", "0.5217568", "0.519692", "0.5181096", "0.517504", "0.51422614", "0.5113219", "0.50962377", "0.5088531", "0.5082477", "0.50752294", "0.5073554", "0.5038864", "0.5020849", "0.5003397", "0.49999294", "0.49972135"...
0.8529653
0
Equals returns true if the tags are equal.
func (in Labels) Equals(other Labels) bool { return reflect.DeepEqual(in, other) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (t Tags) Equal(other Tags) bool {\n\tif len(t.Values()) != len(other.Values()) {\n\t\treturn false\n\t}\n\tfor i := 0; i < len(t.Values()); i++ {\n\t\tequal := t.values[i].Name.Equal(other.values[i].Name) &&\n\t\t\tt.values[i].Value.Equal(other.values[i].Value)\n\t\tif !equal {\n\t\t\treturn false\n\t\t}\n\t}...
[ "0.7741452", "0.69702935", "0.6477298", "0.6450072", "0.6274128", "0.6194222", "0.6008676", "0.59470457", "0.59356153", "0.58936787", "0.5872481", "0.5845245", "0.5827634", "0.5815576", "0.58080417", "0.5789719", "0.5784037", "0.5775299", "0.575321", "0.57492834", "0.5722611"...
0.6086048
6
HasOwned returns true if the tags contains a tag that marks the resource as owned by the cluster from the perspective of this management tooling.
func (in Labels) HasOwned(cluster string) bool { value, ok := in[ClusterTagKey(cluster)] return ok && ResourceLifecycle(value) == ResourceLifecycleOwned }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func IsOwned(object metav1.Object) (owned bool, err error) {\n\trefs, err := getRefs(object)\n\tif err != nil {\n\t\treturn false, err\n\t}\n\treturn len(refs) > 0, nil\n}", "func (k keeper) HasOwner(ctx sdk.Context, name string) bool {\n\treturn !k.GetWhois(ctx, name).Owner.Empty()\n}", "func (o *DeployKey) H...
[ "0.65666986", "0.61177206", "0.59844804", "0.59676355", "0.596722", "0.5791662", "0.57812816", "0.577984", "0.56838113", "0.5683395", "0.56106216", "0.55367696", "0.5497445", "0.5447929", "0.53616506", "0.52428067", "0.5231064", "0.52302146", "0.5227012", "0.5203173", "0.5201...
0.7708871
0
ToComputeFilter returns the string representation of the labels as a filter to be used in google compute sdk calls.
func (in Labels) ToComputeFilter() string { var builder strings.Builder for k, v := range in { builder.WriteString(fmt.Sprintf("(labels.%s = %q) ", k, v)) } return builder.String() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func (q *Query) ToFilter() string {\n\treturn fmt.Sprintf(`\nresource.type=k8s_container\nAND (\n\tlogName=projects/%s/logs/stderr\n\tOR logName=projects/%s/logs/stdout\n)\nAND resource.labels.cluster_name=%q\nAND resource.labels.namespace_name=%q\nAND labels.%q=%q\n`,\n\t\tq.Project,\n\t\tq.Project,\n\t\tq.Cluste...
[ "0.63834465", "0.574212", "0.55767214", "0.55669326", "0.55330604", "0.55210286", "0.54926217", "0.53527564", "0.52048385", "0.51603985", "0.5131564", "0.5130316", "0.51199216", "0.50214374", "0.4973829", "0.4970531", "0.49135852", "0.4864435", "0.48620355", "0.48164833", "0....
0.8348716
0
Difference returns the difference between this map of tags and the other map of tags. Items are considered equals if key and value are equals.
func (in Labels) Difference(other Labels) Labels { res := make(Labels, len(in)) for key, value := range in { if otherValue, ok := other[key]; ok && value == otherValue { continue } res[key] = value } return res }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func TagsDiff(sqsTags map[string]string, newTags map[string]string) (removed, added map[string]string) {\n\tremoved = map[string]string{}\n\tfor k, v := range sqsTags {\n\t\tif _, ok := newTags[k]; !ok {\n\t\t\tremoved[k] = v\n\t\t}\n\t}\n\n\tadded = map[string]string{}\n\tfor k, newV := range newTags {\n\t\tif ol...
[ "0.7123335", "0.7117373", "0.6249632", "0.6098153", "0.6051251", "0.59984875", "0.59709567", "0.5913765", "0.59114486", "0.5909879", "0.58669716", "0.5807775", "0.57989705", "0.5741582", "0.5656751", "0.5651042", "0.5592614", "0.5587161", "0.5564429", "0.55570143", "0.5551818...
0.6719608
2
AddLabels adds (and overwrites) the current labels with the ones passed in.
func (in Labels) AddLabels(other Labels) Labels { for key, value := range other { if in == nil { in = make(map[string]string, len(other)) } in[key] = value } return in }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func AddLabels(obj metav1.Object, additionalLabels map[string]string) {\n\tlabels := obj.GetLabels()\n\tif labels == nil {\n\t\tlabels = map[string]string{}\n\t\tobj.SetLabels(labels)\n\t}\n\tfor k, v := range additionalLabels {\n\t\tlabels[k] = v\n\t}\n}", "func (d *DeviceInfo) AddLabels(labels map[string]strin...
[ "0.7185251", "0.7184332", "0.7106733", "0.7091991", "0.705142", "0.70098543", "0.698809", "0.68857425", "0.6851677", "0.68134856", "0.6807551", "0.6742338", "0.6718384", "0.6718384", "0.6577891", "0.65086764", "0.6257343", "0.62466973", "0.6238192", "0.62083596", "0.6200173",...
0.690418
7
ClusterTagKey generates the key for resources associated with a cluster.
func ClusterTagKey(name string) string { return fmt.Sprintf("%s%s", NameGCPProviderOwned, name) }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func GetClusterKey(clusterId string) string {\n\treturn ClusterKeyPrefix + clusterId\n}", "func ToClusterKey(vc *v1alpha1.Virtualcluster) string {\n\tif len(vc.GetNamespace()) > 0 {\n\t\treturn vc.GetNamespace() + \"-\" + vc.GetName()\n\t}\n\treturn vc.GetName()\n}", "func ResourceKey(group, version, kind stri...
[ "0.6541917", "0.6501025", "0.61764675", "0.5924296", "0.5737486", "0.5630355", "0.55596966", "0.5547573", "0.54778725", "0.54484475", "0.53929687", "0.5359112", "0.53568804", "0.5336668", "0.5244287", "0.52346826", "0.5230897", "0.5210514", "0.52006227", "0.51887405", "0.5183...
0.7726849
0
Build builds tags including the cluster tag and returns them in map form.
func Build(params BuildParams) Labels { tags := make(Labels) for k, v := range params.Additional { tags[strings.ToLower(k)] = strings.ToLower(v) } tags[ClusterTagKey(params.ClusterName)] = string(params.Lifecycle) if params.Role != nil { tags[NameGCPClusterAPIRole] = strings.ToLower(*params.Role) } return tags }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "func buildTags() string {\n\treturn *tags\n}", "func (src *prometheusMetricsSource) buildTags(m *dto.Metric) map[string]string {\n\tresult := map[string]string{}\n\tfor k, v := range src.tags {\n\t\tif len(v) > 0 {\n\t\t\tresult[k] = v\n\t\t}\n\t}\n\tfor _, lp := range m.Label {\n\t\tif len(lp.GetValue()) > 0 {\...
[ "0.61947906", "0.6137007", "0.6052599", "0.6052599", "0.59727746", "0.5800963", "0.57946444", "0.56435233", "0.5506044", "0.5390409", "0.5332386", "0.5301837", "0.5233257", "0.5230261", "0.5214728", "0.5183021", "0.516498", "0.51597834", "0.5121788", "0.51138663", "0.50568736...
0.6989099
0