id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
17,300
cloudfoundry-community/go-cfclient
appevents.go
ListAppEventsByQuery
func (c *Client) ListAppEventsByQuery(eventType string, queries []AppEventQuery) ([]AppEventEntity, error) { var events []AppEventEntity if eventType != AppCrash && eventType != AppStart && eventType != AppStop && eventType != AppUpdate && eventType != AppCreate && eventType != AppDelete && eventType != AppSSHAuth...
go
func (c *Client) ListAppEventsByQuery(eventType string, queries []AppEventQuery) ([]AppEventEntity, error) { var events []AppEventEntity if eventType != AppCrash && eventType != AppStart && eventType != AppStop && eventType != AppUpdate && eventType != AppCreate && eventType != AppDelete && eventType != AppSSHAuth...
[ "func", "(", "c", "*", "Client", ")", "ListAppEventsByQuery", "(", "eventType", "string", ",", "queries", "[", "]", "AppEventQuery", ")", "(", "[", "]", "AppEventEntity", ",", "error", ")", "{", "var", "events", "[", "]", "AppEventEntity", "\n\n", "if", ...
// ListAppEventsByQuery returns all app events based on eventType and queries
[ "ListAppEventsByQuery", "returns", "all", "app", "events", "based", "on", "eventType", "and", "queries" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/appevents.go#L115-L153
17,301
cloudfoundry-community/go-cfclient
service_keys.go
CreateServiceKey
func (c *Client) CreateServiceKey(csr CreateServiceKeyRequest) (ServiceKey, error) { var serviceKeyResource ServiceKeyResource buf := bytes.NewBuffer(nil) err := json.NewEncoder(buf).Encode(csr) if err != nil { return ServiceKey{}, err } req := c.NewRequestWithBody("POST", "/v2/service_keys", buf) resp, err :...
go
func (c *Client) CreateServiceKey(csr CreateServiceKeyRequest) (ServiceKey, error) { var serviceKeyResource ServiceKeyResource buf := bytes.NewBuffer(nil) err := json.NewEncoder(buf).Encode(csr) if err != nil { return ServiceKey{}, err } req := c.NewRequestWithBody("POST", "/v2/service_keys", buf) resp, err :...
[ "func", "(", "c", "*", "Client", ")", "CreateServiceKey", "(", "csr", "CreateServiceKeyRequest", ")", "(", "ServiceKey", ",", "error", ")", "{", "var", "serviceKeyResource", "ServiceKeyResource", "\n\n", "buf", ":=", "bytes", ".", "NewBuffer", "(", "nil", ")",...
// CreateServiceKey creates a service key from the request. If a service key // exists already, it returns an error containing `CF-ServiceKeyNameTaken`
[ "CreateServiceKey", "creates", "a", "service", "key", "from", "the", "request", ".", "If", "a", "service", "key", "exists", "already", "it", "returns", "an", "error", "containing", "CF", "-", "ServiceKeyNameTaken" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/service_keys.go#L131-L159
17,302
cloudfoundry-community/go-cfclient
secgroups.go
respBodyToSecGroup
func respBodyToSecGroup(body io.ReadCloser, c *Client) (*SecGroup, error) { //get the json from the response body bodyRaw, err := ioutil.ReadAll(body) if err != nil { return nil, errors.Wrap(err, "Could not read response body") } jStruct := SecGroupResource{} //make it a SecGroup err = json.Unmarshal(bodyRaw, ...
go
func respBodyToSecGroup(body io.ReadCloser, c *Client) (*SecGroup, error) { //get the json from the response body bodyRaw, err := ioutil.ReadAll(body) if err != nil { return nil, errors.Wrap(err, "Could not read response body") } jStruct := SecGroupResource{} //make it a SecGroup err = json.Unmarshal(bodyRaw, ...
[ "func", "respBodyToSecGroup", "(", "body", "io", ".", "ReadCloser", ",", "c", "*", "Client", ")", "(", "*", "SecGroup", ",", "error", ")", "{", "//get the json from the response body", "bodyRaw", ",", "err", ":=", "ioutil", ".", "ReadAll", "(", "body", ")", ...
//Reads most security group response bodies into a SecGroup object
[ "Reads", "most", "security", "group", "response", "bodies", "into", "a", "SecGroup", "object" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/secgroups.go#L456-L475
17,303
cloudfoundry-community/go-cfclient
secgroups.go
secGroupCreateHelper
func (c *Client) secGroupCreateHelper(url, method, name string, rules []SecGroupRule, spaceGuids []string) (*SecGroup, error) { reqRules := make([]map[string]interface{}, len(rules)) for i, rule := range rules { reqRules[i] = convertStructToMap(rule) protocol := strings.ToLower(reqRules[i]["protocol"].(string)) ...
go
func (c *Client) secGroupCreateHelper(url, method, name string, rules []SecGroupRule, spaceGuids []string) (*SecGroup, error) { reqRules := make([]map[string]interface{}, len(rules)) for i, rule := range rules { reqRules[i] = convertStructToMap(rule) protocol := strings.ToLower(reqRules[i]["protocol"].(string)) ...
[ "func", "(", "c", "*", "Client", ")", "secGroupCreateHelper", "(", "url", ",", "method", ",", "name", "string", ",", "rules", "[", "]", "SecGroupRule", ",", "spaceGuids", "[", "]", "string", ")", "(", "*", "SecGroup", ",", "error", ")", "{", "reqRules"...
//Create and Update secGroup pretty much do the same thing, so this function abstracts those out.
[ "Create", "and", "Update", "secGroup", "pretty", "much", "do", "the", "same", "thing", "so", "this", "function", "abstracts", "those", "out", "." ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/secgroups.go#L511-L560
17,304
cloudfoundry-community/go-cfclient
processes.go
ListAllProcessesByQuery
func (c *Client) ListAllProcessesByQuery(query url.Values) ([]Process, error) { var allProcesses []Process urlPath := "/v3/processes" for { resp, err := c.getProcessPage(urlPath, query) if err != nil { return nil, err } if resp.Pagination.TotalResults == 0 { return nil, nil } if allProcesses == ...
go
func (c *Client) ListAllProcessesByQuery(query url.Values) ([]Process, error) { var allProcesses []Process urlPath := "/v3/processes" for { resp, err := c.getProcessPage(urlPath, query) if err != nil { return nil, err } if resp.Pagination.TotalResults == 0 { return nil, nil } if allProcesses == ...
[ "func", "(", "c", "*", "Client", ")", "ListAllProcessesByQuery", "(", "query", "url", ".", "Values", ")", "(", "[", "]", "Process", ",", "error", ")", "{", "var", "allProcesses", "[", "]", "Process", "\n\n", "urlPath", ":=", "\"", "\"", "\n", "for", ...
// ListAllProcessesByQuery will call the v3 processes api
[ "ListAllProcessesByQuery", "will", "call", "the", "v3", "processes", "api" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/processes.go#L49-L106
17,305
cloudfoundry-community/go-cfclient
apps.go
ListAppsByQueryWithLimits
func (c *Client) ListAppsByQueryWithLimits(query url.Values, totalPages int) ([]App, error) { return c.listApps("/v2/apps?"+query.Encode(), totalPages) }
go
func (c *Client) ListAppsByQueryWithLimits(query url.Values, totalPages int) ([]App, error) { return c.listApps("/v2/apps?"+query.Encode(), totalPages) }
[ "func", "(", "c", "*", "Client", ")", "ListAppsByQueryWithLimits", "(", "query", "url", ".", "Values", ",", "totalPages", "int", ")", "(", "[", "]", "App", ",", "error", ")", "{", "return", "c", ".", "listApps", "(", "\"", "\"", "+", "query", ".", ...
// ListAppsByQueryWithLimits queries totalPages app info. When totalPages is // less and equal than 0, it queries all app info // When there are no more than totalPages apps on server side, all apps info will be returned
[ "ListAppsByQueryWithLimits", "queries", "totalPages", "app", "info", ".", "When", "totalPages", "is", "less", "and", "equal", "than", "0", "it", "queries", "all", "app", "info", "When", "there", "are", "no", "more", "than", "totalPages", "apps", "on", "server"...
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/apps.go#L270-L272
17,306
cloudfoundry-community/go-cfclient
apps.go
GetAppByGuidNoInlineCall
func (c *Client) GetAppByGuidNoInlineCall(guid string) (App, error) { var appResource AppResource r := c.NewRequest("GET", "/v2/apps/"+guid) resp, err := c.DoRequest(r) if err != nil { return App{}, errors.Wrap(err, "Error requesting apps") } defer resp.Body.Close() resBody, err := ioutil.ReadAll(resp.Body) i...
go
func (c *Client) GetAppByGuidNoInlineCall(guid string) (App, error) { var appResource AppResource r := c.NewRequest("GET", "/v2/apps/"+guid) resp, err := c.DoRequest(r) if err != nil { return App{}, errors.Wrap(err, "Error requesting apps") } defer resp.Body.Close() resBody, err := ioutil.ReadAll(resp.Body) i...
[ "func", "(", "c", "*", "Client", ")", "GetAppByGuidNoInlineCall", "(", "guid", "string", ")", "(", "App", ",", "error", ")", "{", "var", "appResource", "AppResource", "\n", "r", ":=", "c", ".", "NewRequest", "(", "\"", "\"", ",", "\"", "\"", "+", "gu...
// GetAppByGuidNoInlineCall will fetch app info including space and orgs information // Without using inline-relations-depth=2 call
[ "GetAppByGuidNoInlineCall", "will", "fetch", "app", "info", "including", "space", "and", "orgs", "information", "Without", "using", "inline", "-", "relations", "-", "depth", "=", "2", "call" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/apps.go#L280-L320
17,307
cloudfoundry-community/go-cfclient
apps.go
AppByName
func (c *Client) AppByName(appName, spaceGuid, orgGuid string) (app App, err error) { query := url.Values{} query.Add("q", fmt.Sprintf("organization_guid:%s", orgGuid)) query.Add("q", fmt.Sprintf("space_guid:%s", spaceGuid)) query.Add("q", fmt.Sprintf("name:%s", appName)) apps, err := c.ListAppsByQuery(query) if ...
go
func (c *Client) AppByName(appName, spaceGuid, orgGuid string) (app App, err error) { query := url.Values{} query.Add("q", fmt.Sprintf("organization_guid:%s", orgGuid)) query.Add("q", fmt.Sprintf("space_guid:%s", spaceGuid)) query.Add("q", fmt.Sprintf("name:%s", appName)) apps, err := c.ListAppsByQuery(query) if ...
[ "func", "(", "c", "*", "Client", ")", "AppByName", "(", "appName", ",", "spaceGuid", ",", "orgGuid", "string", ")", "(", "app", "App", ",", "err", "error", ")", "{", "query", ":=", "url", ".", "Values", "{", "}", "\n", "query", ".", "Add", "(", "...
//AppByName takes an appName, and GUIDs for a space and org, and performs // the API lookup with those query parameters set to return you the desired // App object.
[ "AppByName", "takes", "an", "appName", "and", "GUIDs", "for", "a", "space", "and", "org", "and", "performs", "the", "API", "lookup", "with", "those", "query", "parameters", "set", "to", "return", "you", "the", "desired", "App", "object", "." ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/apps.go#L478-L493
17,308
cloudfoundry-community/go-cfclient
apps.go
UploadAppBits
func (c *Client) UploadAppBits(file io.Reader, appGUID string) error { requestFile, err := ioutil.TempFile("", "requests") defer func() { requestFile.Close() os.Remove(requestFile.Name()) }() writer := multipart.NewWriter(requestFile) err = writer.WriteField("resources", "[]") if err != nil { return error...
go
func (c *Client) UploadAppBits(file io.Reader, appGUID string) error { requestFile, err := ioutil.TempFile("", "requests") defer func() { requestFile.Close() os.Remove(requestFile.Name()) }() writer := multipart.NewWriter(requestFile) err = writer.WriteField("resources", "[]") if err != nil { return error...
[ "func", "(", "c", "*", "Client", ")", "UploadAppBits", "(", "file", "io", ".", "Reader", ",", "appGUID", "string", ")", "error", "{", "requestFile", ",", "err", ":=", "ioutil", ".", "TempFile", "(", "\"", "\"", ",", "\"", "\"", ")", "\n\n", "defer", ...
// UploadAppBits uploads the application's contents
[ "UploadAppBits", "uploads", "the", "application", "s", "contents" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/apps.go#L496-L551
17,309
cloudfoundry-community/go-cfclient
apps.go
GetAppBits
func (c *Client) GetAppBits(guid string) (io.ReadCloser, error) { requestURL := fmt.Sprintf("/v2/apps/%s/download", guid) req := c.NewRequest("GET", requestURL) resp, err := c.DoRequestWithoutRedirects(req) if err != nil { return nil, errors.Wrapf(err, "Error downloading app %s bits, API request failed", guid) }...
go
func (c *Client) GetAppBits(guid string) (io.ReadCloser, error) { requestURL := fmt.Sprintf("/v2/apps/%s/download", guid) req := c.NewRequest("GET", requestURL) resp, err := c.DoRequestWithoutRedirects(req) if err != nil { return nil, errors.Wrapf(err, "Error downloading app %s bits, API request failed", guid) }...
[ "func", "(", "c", "*", "Client", ")", "GetAppBits", "(", "guid", "string", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "requestURL", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "guid", ")", "\n", "req", ":=", "c", ".", "NewR...
// GetAppBits downloads the application's bits as a tar file
[ "GetAppBits", "downloads", "the", "application", "s", "bits", "as", "a", "tar", "file" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/apps.go#L554-L577
17,310
cloudfoundry-community/go-cfclient
apps.go
CreateApp
func (c *Client) CreateApp(req AppCreateRequest) (App, error) { var appResp AppResource buf := bytes.NewBuffer(nil) err := json.NewEncoder(buf).Encode(req) if err != nil { return App{}, err } r := c.NewRequestWithBody("POST", "/v2/apps", buf) resp, err := c.DoRequest(r) if err != nil { return App{}, errors....
go
func (c *Client) CreateApp(req AppCreateRequest) (App, error) { var appResp AppResource buf := bytes.NewBuffer(nil) err := json.NewEncoder(buf).Encode(req) if err != nil { return App{}, err } r := c.NewRequestWithBody("POST", "/v2/apps", buf) resp, err := c.DoRequest(r) if err != nil { return App{}, errors....
[ "func", "(", "c", "*", "Client", ")", "CreateApp", "(", "req", "AppCreateRequest", ")", "(", "App", ",", "error", ")", "{", "var", "appResp", "AppResource", "\n", "buf", ":=", "bytes", ".", "NewBuffer", "(", "nil", ")", "\n", "err", ":=", "json", "."...
// CreateApp creates a new empty application that still needs it's // app bit uploaded and to be started
[ "CreateApp", "creates", "a", "new", "empty", "application", "that", "still", "needs", "it", "s", "app", "bit", "uploaded", "and", "to", "be", "started" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/apps.go#L581-L606
17,311
cloudfoundry-community/go-cfclient
info.go
GetInfo
func (c *Client) GetInfo() (*Info, error) { r := c.NewRequest("GET", "/v2/info") resp, err := c.DoRequest(r) if err != nil { return nil, errors.Wrap(err, "Error requesting info") } defer resp.Body.Close() var i Info err = json.NewDecoder(resp.Body).Decode(&i) if err != nil { return nil, errors.Wrap(err, "Er...
go
func (c *Client) GetInfo() (*Info, error) { r := c.NewRequest("GET", "/v2/info") resp, err := c.DoRequest(r) if err != nil { return nil, errors.Wrap(err, "Error requesting info") } defer resp.Body.Close() var i Info err = json.NewDecoder(resp.Body).Decode(&i) if err != nil { return nil, errors.Wrap(err, "Er...
[ "func", "(", "c", "*", "Client", ")", "GetInfo", "(", ")", "(", "*", "Info", ",", "error", ")", "{", "r", ":=", "c", ".", "NewRequest", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "resp", ",", "err", ":=", "c", ".", "DoRequest", "(", "r", ...
// GetInfo retrieves Info from the Cloud Controller API
[ "GetInfo", "retrieves", "Info", "from", "the", "Cloud", "Controller", "API" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/info.go#L30-L43
17,312
cloudfoundry-community/go-cfclient
error.go
NewCloudFoundryErrorFromV3Errors
func NewCloudFoundryErrorFromV3Errors(cfErrorsV3 CloudFoundryErrorsV3) CloudFoundryError { if len(cfErrorsV3.Errors) == 0 { return CloudFoundryError{ 0, "GO-Client-No-Errors", "No Errors in response from V3", } } return CloudFoundryError{ cfErrorsV3.Errors[0].Code, cfErrorsV3.Errors[0].Title, cfE...
go
func NewCloudFoundryErrorFromV3Errors(cfErrorsV3 CloudFoundryErrorsV3) CloudFoundryError { if len(cfErrorsV3.Errors) == 0 { return CloudFoundryError{ 0, "GO-Client-No-Errors", "No Errors in response from V3", } } return CloudFoundryError{ cfErrorsV3.Errors[0].Code, cfErrorsV3.Errors[0].Title, cfE...
[ "func", "NewCloudFoundryErrorFromV3Errors", "(", "cfErrorsV3", "CloudFoundryErrorsV3", ")", "CloudFoundryError", "{", "if", "len", "(", "cfErrorsV3", ".", "Errors", ")", "==", "0", "{", "return", "CloudFoundryError", "{", "0", ",", "\"", "\"", ",", "\"", "\"", ...
// CF APIs v3 can return multiple errors, we take the first one and convert it into a V2 model
[ "CF", "APIs", "v3", "can", "return", "multiple", "errors", "we", "take", "the", "first", "one", "and", "convert", "it", "into", "a", "V2", "model" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/error.go#L26-L40
17,313
cloudfoundry-community/go-cfclient
service_usage_events.go
ListServiceUsageEventsByQuery
func (c *Client) ListServiceUsageEventsByQuery(query url.Values) ([]ServiceUsageEvent, error) { var serviceUsageEvents []ServiceUsageEvent requestURL := fmt.Sprintf("/v2/service_usage_events?%s", query.Encode()) for { var serviceUsageEventsResponse ServiceUsageEventsResponse r := c.NewRequest("GET", requestURL) ...
go
func (c *Client) ListServiceUsageEventsByQuery(query url.Values) ([]ServiceUsageEvent, error) { var serviceUsageEvents []ServiceUsageEvent requestURL := fmt.Sprintf("/v2/service_usage_events?%s", query.Encode()) for { var serviceUsageEventsResponse ServiceUsageEventsResponse r := c.NewRequest("GET", requestURL) ...
[ "func", "(", "c", "*", "Client", ")", "ListServiceUsageEventsByQuery", "(", "query", "url", ".", "Values", ")", "(", "[", "]", "ServiceUsageEvent", ",", "error", ")", "{", "var", "serviceUsageEvents", "[", "]", "ServiceUsageEvent", "\n", "requestURL", ":=", ...
// ListServiceUsageEventsByQuery lists all events matching the provided query.
[ "ListServiceUsageEventsByQuery", "lists", "all", "events", "matching", "the", "provided", "query", "." ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/service_usage_events.go#L41-L67
17,314
cloudfoundry-community/go-cfclient
events.go
ListEventsByQuery
func (c *Client) ListEventsByQuery(query url.Values) ([]Event, error) { var events []Event requestURL := fmt.Sprintf("/v2/events?%s", query.Encode()) for { var eventResp EventsResponse r := c.NewRequest("GET", requestURL) resp, err := c.DoRequest(r) if err != nil { return nil, errors.Wrap(err, "error requ...
go
func (c *Client) ListEventsByQuery(query url.Values) ([]Event, error) { var events []Event requestURL := fmt.Sprintf("/v2/events?%s", query.Encode()) for { var eventResp EventsResponse r := c.NewRequest("GET", requestURL) resp, err := c.DoRequest(r) if err != nil { return nil, errors.Wrap(err, "error requ...
[ "func", "(", "c", "*", "Client", ")", "ListEventsByQuery", "(", "query", "url", ".", "Values", ")", "(", "[", "]", "Event", ",", "error", ")", "{", "var", "events", "[", "]", "Event", "\n", "requestURL", ":=", "fmt", ".", "Sprintf", "(", "\"", "\""...
// ListEventsByQuery lists all events matching the provided query.
[ "ListEventsByQuery", "lists", "all", "events", "matching", "the", "provided", "query", "." ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/events.go#L43-L69
17,315
cloudfoundry-community/go-cfclient
events.go
TotalEventsByQuery
func (c *Client) TotalEventsByQuery(query url.Values) (int, error) { r := c.NewRequest("GET", fmt.Sprintf("/v2/events?%s", query.Encode())) resp, err := c.DoRequest(r) if err != nil { return 0, errors.Wrap(err, "error requesting events") } defer resp.Body.Close() var apiResp EventsResponse if err := json.NewDe...
go
func (c *Client) TotalEventsByQuery(query url.Values) (int, error) { r := c.NewRequest("GET", fmt.Sprintf("/v2/events?%s", query.Encode())) resp, err := c.DoRequest(r) if err != nil { return 0, errors.Wrap(err, "error requesting events") } defer resp.Body.Close() var apiResp EventsResponse if err := json.NewDe...
[ "func", "(", "c", "*", "Client", ")", "TotalEventsByQuery", "(", "query", "url", ".", "Values", ")", "(", "int", ",", "error", ")", "{", "r", ":=", "c", ".", "NewRequest", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "query"...
// TotalEventsByQuery returns the number of events matching the provided query.
[ "TotalEventsByQuery", "returns", "the", "number", "of", "events", "matching", "the", "provided", "query", "." ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/events.go#L77-L89
17,316
cloudfoundry-community/go-cfclient
tasks.go
CreateTask
func (c *Client) CreateTask(tr TaskRequest) (task Task, err error) { bodyReader, err := createReader(tr) if err != nil { return task, err } request := fmt.Sprintf("/v3/apps/%s/tasks", tr.DropletGUID) req := c.NewRequestWithBody("POST", request, bodyReader) resp, err := c.DoRequest(req) if err != nil { retu...
go
func (c *Client) CreateTask(tr TaskRequest) (task Task, err error) { bodyReader, err := createReader(tr) if err != nil { return task, err } request := fmt.Sprintf("/v3/apps/%s/tasks", tr.DropletGUID) req := c.NewRequestWithBody("POST", request, bodyReader) resp, err := c.DoRequest(req) if err != nil { retu...
[ "func", "(", "c", "*", "Client", ")", "CreateTask", "(", "tr", "TaskRequest", ")", "(", "task", "Task", ",", "err", "error", ")", "{", "bodyReader", ",", "err", ":=", "createReader", "(", "tr", ")", "\n", "if", "err", "!=", "nil", "{", "return", "t...
// CreateTask creates a new task in CF system and returns its structure.
[ "CreateTask", "creates", "a", "new", "task", "in", "CF", "system", "and", "returns", "its", "structure", "." ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/tasks.go#L137-L162
17,317
cloudfoundry-community/go-cfclient
tasks.go
GetTaskByGuid
func (c *Client) GetTaskByGuid(guid string) (task Task, err error) { request := fmt.Sprintf("/v3/tasks/%s", guid) req := c.NewRequest("GET", request) resp, err := c.DoRequest(req) if err != nil { return task, errors.Wrap(err, "Error requesting task") } defer resp.Body.Close() body, err := ioutil.ReadAll(resp...
go
func (c *Client) GetTaskByGuid(guid string) (task Task, err error) { request := fmt.Sprintf("/v3/tasks/%s", guid) req := c.NewRequest("GET", request) resp, err := c.DoRequest(req) if err != nil { return task, errors.Wrap(err, "Error requesting task") } defer resp.Body.Close() body, err := ioutil.ReadAll(resp...
[ "func", "(", "c", "*", "Client", ")", "GetTaskByGuid", "(", "guid", "string", ")", "(", "task", "Task", ",", "err", "error", ")", "{", "request", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "guid", ")", "\n", "req", ":=", "c", ".", "NewReq...
// GetTaskByGuid returns a task structure by requesting it with the tasks GUID.
[ "GetTaskByGuid", "returns", "a", "task", "structure", "by", "requesting", "it", "with", "the", "tasks", "GUID", "." ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/tasks.go#L165-L185
17,318
cloudfoundry-community/go-cfclient
tasks.go
TerminateTask
func (c *Client) TerminateTask(guid string) error { req := c.NewRequest("PUT", fmt.Sprintf("/v3/tasks/%s/cancel", guid)) resp, err := c.DoRequest(req) if err != nil { return errors.Wrap(err, "Error terminating task") } defer resp.Body.Close() if resp.StatusCode != 202 { return errors.Wrapf(err, "Failed termi...
go
func (c *Client) TerminateTask(guid string) error { req := c.NewRequest("PUT", fmt.Sprintf("/v3/tasks/%s/cancel", guid)) resp, err := c.DoRequest(req) if err != nil { return errors.Wrap(err, "Error terminating task") } defer resp.Body.Close() if resp.StatusCode != 202 { return errors.Wrapf(err, "Failed termi...
[ "func", "(", "c", "*", "Client", ")", "TerminateTask", "(", "guid", "string", ")", "error", "{", "req", ":=", "c", ".", "NewRequest", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "guid", ")", ")", "\n", "resp", ",", "err", ...
// TerminateTask cancels a task identified by its GUID.
[ "TerminateTask", "cancels", "a", "task", "identified", "by", "its", "GUID", "." ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/tasks.go#L192-L204
17,319
cloudfoundry-community/go-cfclient
client.go
DefaultConfig
func DefaultConfig() *Config { return &Config{ ApiAddress: "http://api.bosh-lite.com", Username: "admin", Password: "admin", Token: "", SkipSslValidation: false, HttpClient: http.DefaultClient, UserAgent: "Go-CF-client/1.1", } }
go
func DefaultConfig() *Config { return &Config{ ApiAddress: "http://api.bosh-lite.com", Username: "admin", Password: "admin", Token: "", SkipSslValidation: false, HttpClient: http.DefaultClient, UserAgent: "Go-CF-client/1.1", } }
[ "func", "DefaultConfig", "(", ")", "*", "Config", "{", "return", "&", "Config", "{", "ApiAddress", ":", "\"", "\"", ",", "Username", ":", "\"", "\"", ",", "Password", ":", "\"", "\"", ",", "Token", ":", "\"", "\"", ",", "SkipSslValidation", ":", "fal...
//DefaultConfig configuration for client //Keep LoginAdress for backward compatibility //Need to be remove in close future
[ "DefaultConfig", "configuration", "for", "client", "Keep", "LoginAdress", "for", "backward", "compatibility", "Need", "to", "be", "remove", "in", "close", "future" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/client.go#L61-L71
17,320
cloudfoundry-community/go-cfclient
client.go
getUserTokenAuth
func getUserTokenAuth(ctx context.Context, config Config, endpoint *Endpoint) Config { authConfig := &oauth2.Config{ ClientID: "cf", Scopes: []string{""}, Endpoint: oauth2.Endpoint{ AuthURL: endpoint.AuthEndpoint + "/oauth/auth", TokenURL: endpoint.TokenEndpoint + "/oauth/token", }, } // Token is e...
go
func getUserTokenAuth(ctx context.Context, config Config, endpoint *Endpoint) Config { authConfig := &oauth2.Config{ ClientID: "cf", Scopes: []string{""}, Endpoint: oauth2.Endpoint{ AuthURL: endpoint.AuthEndpoint + "/oauth/auth", TokenURL: endpoint.TokenEndpoint + "/oauth/token", }, } // Token is e...
[ "func", "getUserTokenAuth", "(", "ctx", "context", ".", "Context", ",", "config", "Config", ",", "endpoint", "*", "Endpoint", ")", "Config", "{", "authConfig", ":=", "&", "oauth2", ".", "Config", "{", "ClientID", ":", "\"", "\"", ",", "Scopes", ":", "[",...
// getUserTokenAuth initializes client credentials from existing bearer token.
[ "getUserTokenAuth", "initializes", "client", "credentials", "from", "existing", "bearer", "token", "." ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/client.go#L190-L209
17,321
cloudfoundry-community/go-cfclient
client.go
NewRequest
func (c *Client) NewRequest(method, path string) *Request { r := &Request{ method: method, url: c.Config.ApiAddress + path, params: make(map[string][]string), } return r }
go
func (c *Client) NewRequest(method, path string) *Request { r := &Request{ method: method, url: c.Config.ApiAddress + path, params: make(map[string][]string), } return r }
[ "func", "(", "c", "*", "Client", ")", "NewRequest", "(", "method", ",", "path", "string", ")", "*", "Request", "{", "r", ":=", "&", "Request", "{", "method", ":", "method", ",", "url", ":", "c", ".", "Config", ".", "ApiAddress", "+", "path", ",", ...
// NewRequest is used to create a new Request
[ "NewRequest", "is", "used", "to", "create", "a", "new", "Request" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/client.go#L233-L240
17,322
cloudfoundry-community/go-cfclient
client.go
NewRequestWithBody
func (c *Client) NewRequestWithBody(method, path string, body io.Reader) *Request { r := c.NewRequest(method, path) // Set request body r.body = body return r }
go
func (c *Client) NewRequestWithBody(method, path string, body io.Reader) *Request { r := c.NewRequest(method, path) // Set request body r.body = body return r }
[ "func", "(", "c", "*", "Client", ")", "NewRequestWithBody", "(", "method", ",", "path", "string", ",", "body", "io", ".", "Reader", ")", "*", "Request", "{", "r", ":=", "c", ".", "NewRequest", "(", "method", ",", "path", ")", "\n\n", "// Set request bo...
// NewRequestWithBody is used to create a new request with // arbigtrary body io.Reader.
[ "NewRequestWithBody", "is", "used", "to", "create", "a", "new", "request", "with", "arbigtrary", "body", "io", ".", "Reader", "." ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/client.go#L244-L251
17,323
cloudfoundry-community/go-cfclient
client.go
DoRequestWithoutRedirects
func (c *Client) DoRequestWithoutRedirects(r *Request) (*http.Response, error) { prevCheckRedirect := c.Config.HttpClient.CheckRedirect c.Config.HttpClient.CheckRedirect = func(httpReq *http.Request, via []*http.Request) error { return http.ErrUseLastResponse } defer func() { c.Config.HttpClient.CheckRedirect =...
go
func (c *Client) DoRequestWithoutRedirects(r *Request) (*http.Response, error) { prevCheckRedirect := c.Config.HttpClient.CheckRedirect c.Config.HttpClient.CheckRedirect = func(httpReq *http.Request, via []*http.Request) error { return http.ErrUseLastResponse } defer func() { c.Config.HttpClient.CheckRedirect =...
[ "func", "(", "c", "*", "Client", ")", "DoRequestWithoutRedirects", "(", "r", "*", "Request", ")", "(", "*", "http", ".", "Response", ",", "error", ")", "{", "prevCheckRedirect", ":=", "c", ".", "Config", ".", "HttpClient", ".", "CheckRedirect", "\n", "c"...
// DoRequestWithoutRedirects executes the request without following redirects
[ "DoRequestWithoutRedirects", "executes", "the", "request", "without", "following", "redirects" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/client.go#L263-L272
17,324
cloudfoundry-community/go-cfclient
service_plan_visibilities.go
CreateServicePlanVisibilityByUniqueId
func (c *Client) CreateServicePlanVisibilityByUniqueId(uniqueId string, organizationGuid string) (ServicePlanVisibility, error) { q := url.Values{} q.Set("q", fmt.Sprintf("unique_id:%s", uniqueId)) plans, err := c.ListServicePlansByQuery(q) if err != nil { return ServicePlanVisibility{}, errors.Wrap(err, fmt.Spri...
go
func (c *Client) CreateServicePlanVisibilityByUniqueId(uniqueId string, organizationGuid string) (ServicePlanVisibility, error) { q := url.Values{} q.Set("q", fmt.Sprintf("unique_id:%s", uniqueId)) plans, err := c.ListServicePlansByQuery(q) if err != nil { return ServicePlanVisibility{}, errors.Wrap(err, fmt.Spri...
[ "func", "(", "c", "*", "Client", ")", "CreateServicePlanVisibilityByUniqueId", "(", "uniqueId", "string", ",", "organizationGuid", "string", ")", "(", "ServicePlanVisibility", ",", "error", ")", "{", "q", ":=", "url", ".", "Values", "{", "}", "\n", "q", ".",...
//a uniqueID is the id of the service in the catalog and not in cf internal db
[ "a", "uniqueID", "is", "the", "id", "of", "the", "service", "in", "the", "catalog", "and", "not", "in", "cf", "internal", "db" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/service_plan_visibilities.go#L85-L93
17,325
cloudfoundry-community/go-cfclient
users.go
GetUserByGUID
func (c *Client) GetUserByGUID(guid string) (User, error) { var userRes UserResource r := c.NewRequest("GET", "/v2/users/"+guid) resp, err := c.DoRequest(r) if err != nil { return User{}, err } body, err := ioutil.ReadAll(resp.Body) defer resp.Body.Close() if err != nil { return User{}, err } err = json.U...
go
func (c *Client) GetUserByGUID(guid string) (User, error) { var userRes UserResource r := c.NewRequest("GET", "/v2/users/"+guid) resp, err := c.DoRequest(r) if err != nil { return User{}, err } body, err := ioutil.ReadAll(resp.Body) defer resp.Body.Close() if err != nil { return User{}, err } err = json.U...
[ "func", "(", "c", "*", "Client", ")", "GetUserByGUID", "(", "guid", "string", ")", "(", "User", ",", "error", ")", "{", "var", "userRes", "UserResource", "\n", "r", ":=", "c", ".", "NewRequest", "(", "\"", "\"", ",", "\"", "\"", "+", "guid", ")", ...
// GetUserByGUID retrieves the user with the provided guid.
[ "GetUserByGUID", "retrieves", "the", "user", "with", "the", "provided", "guid", "." ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/users.go#L52-L69
17,326
cloudfoundry-community/go-cfclient
app_usage_events.go
ListAppUsageEventsByQuery
func (c *Client) ListAppUsageEventsByQuery(query url.Values) ([]AppUsageEvent, error) { var appUsageEvents []AppUsageEvent requestURL := fmt.Sprintf("/v2/app_usage_events?%s", query.Encode()) for { var appUsageEventsResponse AppUsageEventsResponse r := c.NewRequest("GET", requestURL) resp, err := c.DoRequest(r...
go
func (c *Client) ListAppUsageEventsByQuery(query url.Values) ([]AppUsageEvent, error) { var appUsageEvents []AppUsageEvent requestURL := fmt.Sprintf("/v2/app_usage_events?%s", query.Encode()) for { var appUsageEventsResponse AppUsageEventsResponse r := c.NewRequest("GET", requestURL) resp, err := c.DoRequest(r...
[ "func", "(", "c", "*", "Client", ")", "ListAppUsageEventsByQuery", "(", "query", "url", ".", "Values", ")", "(", "[", "]", "AppUsageEvent", ",", "error", ")", "{", "var", "appUsageEvents", "[", "]", "AppUsageEvent", "\n", "requestURL", ":=", "fmt", ".", ...
// ListAppUsageEventsByQuery lists all events matching the provided query.
[ "ListAppUsageEventsByQuery", "lists", "all", "events", "matching", "the", "provided", "query", "." ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/app_usage_events.go#L49-L75
17,327
cloudfoundry-community/go-cfclient
routes.go
CreateRoute
func (c *Client) CreateRoute(routeRequest RouteRequest) (Route, error) { routesResource, err := c.createRoute("/v2/routes", routeRequest) if nil != err { return Route{}, err } return c.mergeRouteResource(routesResource), nil }
go
func (c *Client) CreateRoute(routeRequest RouteRequest) (Route, error) { routesResource, err := c.createRoute("/v2/routes", routeRequest) if nil != err { return Route{}, err } return c.mergeRouteResource(routesResource), nil }
[ "func", "(", "c", "*", "Client", ")", "CreateRoute", "(", "routeRequest", "RouteRequest", ")", "(", "Route", ",", "error", ")", "{", "routesResource", ",", "err", ":=", "c", ".", "createRoute", "(", "\"", "\"", ",", "routeRequest", ")", "\n", "if", "ni...
// CreateRoute creates a regular http route
[ "CreateRoute", "creates", "a", "regular", "http", "route" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/routes.go#L48-L54
17,328
cloudfoundry-community/go-cfclient
routes.go
BindRoute
func (c *Client) BindRoute(routeGUID, appGUID string) error { resp, err := c.DoRequest(c.NewRequest("PUT", fmt.Sprintf("/v2/routes/%s/apps/%s", routeGUID, appGUID))) if err != nil { return errors.Wrapf(err, "Error binding route %s to app %s", routeGUID, appGUID) } if resp.StatusCode != http.StatusCreated { retu...
go
func (c *Client) BindRoute(routeGUID, appGUID string) error { resp, err := c.DoRequest(c.NewRequest("PUT", fmt.Sprintf("/v2/routes/%s/apps/%s", routeGUID, appGUID))) if err != nil { return errors.Wrapf(err, "Error binding route %s to app %s", routeGUID, appGUID) } if resp.StatusCode != http.StatusCreated { retu...
[ "func", "(", "c", "*", "Client", ")", "BindRoute", "(", "routeGUID", ",", "appGUID", "string", ")", "error", "{", "resp", ",", "err", ":=", "c", ".", "DoRequest", "(", "c", ".", "NewRequest", "(", "\"", "\"", ",", "fmt", ".", "Sprintf", "(", "\"", ...
// BindRoute associates the specified route with the application
[ "BindRoute", "associates", "the", "specified", "route", "with", "the", "application" ]
f136f9222381e2fea5099f62e4b751dcb660ff82
https://github.com/cloudfoundry-community/go-cfclient/blob/f136f9222381e2fea5099f62e4b751dcb660ff82/routes.go#L66-L75
17,329
bamiaux/rez
image.go
Check
func (d *Descriptor) Check() error { if d.Pack < 1 || d.Pack > 4 { return fmt.Errorf("invalid pack value %v", d.Pack) } for i := 0; i < d.Planes; i++ { h := d.GetHeight(i) if d.Interlaced && h%2 != 0 && h != d.Height { return fmt.Errorf("invalid interlaced input height %v", d.Height) } } return nil }
go
func (d *Descriptor) Check() error { if d.Pack < 1 || d.Pack > 4 { return fmt.Errorf("invalid pack value %v", d.Pack) } for i := 0; i < d.Planes; i++ { h := d.GetHeight(i) if d.Interlaced && h%2 != 0 && h != d.Height { return fmt.Errorf("invalid interlaced input height %v", d.Height) } } return nil }
[ "func", "(", "d", "*", "Descriptor", ")", "Check", "(", ")", "error", "{", "if", "d", ".", "Pack", "<", "1", "||", "d", ".", "Pack", ">", "4", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "d", ".", "Pack", ")", "\n", "}", "\n"...
// Check returns whether the descriptor is valid
[ "Check", "returns", "whether", "the", "descriptor", "is", "valid" ]
29f4463c688b986c11f166b12734f69b58b5555f
https://github.com/bamiaux/rez/blob/29f4463c688b986c11f166b12734f69b58b5555f/image.go#L84-L95
17,330
bamiaux/rez
image.go
GetWidth
func (d *Descriptor) GetWidth(plane int) int { if plane < 0 || plane+1 > maxPlanes { panic(fmt.Errorf("invalid plane %v", plane)) } if plane == 0 { return d.Width } switch d.Ratio { case Ratio410, Ratio411: return (d.Width + 3) >> 2 case Ratio420, Ratio422: return (d.Width + 1) >> 1 case Ratio440, Ratio...
go
func (d *Descriptor) GetWidth(plane int) int { if plane < 0 || plane+1 > maxPlanes { panic(fmt.Errorf("invalid plane %v", plane)) } if plane == 0 { return d.Width } switch d.Ratio { case Ratio410, Ratio411: return (d.Width + 3) >> 2 case Ratio420, Ratio422: return (d.Width + 1) >> 1 case Ratio440, Ratio...
[ "func", "(", "d", "*", "Descriptor", ")", "GetWidth", "(", "plane", "int", ")", "int", "{", "if", "plane", "<", "0", "||", "plane", "+", "1", ">", "maxPlanes", "{", "panic", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "plane", ")", ")", "\...
// GetWidth returns the width in pixels for the input plane
[ "GetWidth", "returns", "the", "width", "in", "pixels", "for", "the", "input", "plane" ]
29f4463c688b986c11f166b12734f69b58b5555f
https://github.com/bamiaux/rez/blob/29f4463c688b986c11f166b12734f69b58b5555f/image.go#L98-L114
17,331
bamiaux/rez
image.go
GetHeight
func (d *Descriptor) GetHeight(plane int) int { if plane < 0 || plane+1 > maxPlanes { panic(fmt.Errorf("invalid plane %v", plane)) } if plane == 0 { return d.Height } switch d.Ratio { case Ratio411, Ratio422, Ratio444: return d.Height case Ratio410, Ratio420, Ratio440: h := (d.Height + 1) >> 1 if d.Int...
go
func (d *Descriptor) GetHeight(plane int) int { if plane < 0 || plane+1 > maxPlanes { panic(fmt.Errorf("invalid plane %v", plane)) } if plane == 0 { return d.Height } switch d.Ratio { case Ratio411, Ratio422, Ratio444: return d.Height case Ratio410, Ratio420, Ratio440: h := (d.Height + 1) >> 1 if d.Int...
[ "func", "(", "d", "*", "Descriptor", ")", "GetHeight", "(", "plane", "int", ")", "int", "{", "if", "plane", "<", "0", "||", "plane", "+", "1", ">", "maxPlanes", "{", "panic", "(", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "plane", ")", ")", "...
// GetHeight returns the height in pixels for the input plane
[ "GetHeight", "returns", "the", "height", "in", "pixels", "for", "the", "input", "plane" ]
29f4463c688b986c11f166b12734f69b58b5555f
https://github.com/bamiaux/rez/blob/29f4463c688b986c11f166b12734f69b58b5555f/image.go#L117-L135
17,332
bamiaux/rez
image.go
GetRatio
func GetRatio(value image.YCbCrSubsampleRatio) ChromaRatio { switch value { case image.YCbCrSubsampleRatio410: return Ratio410 case image.YCbCrSubsampleRatio411: return Ratio411 case image.YCbCrSubsampleRatio420: return Ratio420 case image.YCbCrSubsampleRatio422: return Ratio422 case image.YCbCrSubsampleR...
go
func GetRatio(value image.YCbCrSubsampleRatio) ChromaRatio { switch value { case image.YCbCrSubsampleRatio410: return Ratio410 case image.YCbCrSubsampleRatio411: return Ratio411 case image.YCbCrSubsampleRatio420: return Ratio420 case image.YCbCrSubsampleRatio422: return Ratio422 case image.YCbCrSubsampleR...
[ "func", "GetRatio", "(", "value", "image", ".", "YCbCrSubsampleRatio", ")", "ChromaRatio", "{", "switch", "value", "{", "case", "image", ".", "YCbCrSubsampleRatio410", ":", "return", "Ratio410", "\n", "case", "image", ".", "YCbCrSubsampleRatio411", ":", "return", ...
// GetRatio returns a ChromaRatio from an image.YCbCrSubsampleRatio
[ "GetRatio", "returns", "a", "ChromaRatio", "from", "an", "image", ".", "YCbCrSubsampleRatio" ]
29f4463c688b986c11f166b12734f69b58b5555f
https://github.com/bamiaux/rez/blob/29f4463c688b986c11f166b12734f69b58b5555f/image.go#L300-L316
17,333
bamiaux/rez
image.go
PrepareConversion
func PrepareConversion(output, input image.Image) (*ConverterConfig, error) { src, _, err := inspect(input, false) if err != nil { return nil, err } dst, _, err := inspect(output, false) if err != nil { return nil, err } err = checkConversion(dst, src) if err != nil { return nil, err } return &Converter...
go
func PrepareConversion(output, input image.Image) (*ConverterConfig, error) { src, _, err := inspect(input, false) if err != nil { return nil, err } dst, _, err := inspect(output, false) if err != nil { return nil, err } err = checkConversion(dst, src) if err != nil { return nil, err } return &Converter...
[ "func", "PrepareConversion", "(", "output", ",", "input", "image", ".", "Image", ")", "(", "*", "ConverterConfig", ",", "error", ")", "{", "src", ",", "_", ",", "err", ":=", "inspect", "(", "input", ",", "false", ")", "\n", "if", "err", "!=", "nil", ...
// PrepareConversion returns a ConverterConfig properly set for a conversion // from input images to output images // Returns an error if the conversion is not possible
[ "PrepareConversion", "returns", "a", "ConverterConfig", "properly", "set", "for", "a", "conversion", "from", "input", "images", "to", "output", "images", "Returns", "an", "error", "if", "the", "conversion", "is", "not", "possible" ]
29f4463c688b986c11f166b12734f69b58b5555f
https://github.com/bamiaux/rez/blob/29f4463c688b986c11f166b12734f69b58b5555f/image.go#L486-L503
17,334
bamiaux/rez
image.go
Psnr
func Psnr(a, b image.Image) ([]float64, error) { psnrs := []float64{} id, src, err := inspect(a, false) if err != nil { return nil, err } od, dst, err := inspect(b, false) if err != nil { return nil, err } if *id != *od { return nil, fmt.Errorf("unable to psnr different formats") } for i := 0; i < len(d...
go
func Psnr(a, b image.Image) ([]float64, error) { psnrs := []float64{} id, src, err := inspect(a, false) if err != nil { return nil, err } od, dst, err := inspect(b, false) if err != nil { return nil, err } if *id != *od { return nil, fmt.Errorf("unable to psnr different formats") } for i := 0; i < len(d...
[ "func", "Psnr", "(", "a", ",", "b", "image", ".", "Image", ")", "(", "[", "]", "float64", ",", "error", ")", "{", "psnrs", ":=", "[", "]", "float64", "{", "}", "\n", "id", ",", "src", ",", "err", ":=", "inspect", "(", "a", ",", "false", ")", ...
// Psnr computes the PSNR between two input images // Only ycbcr is currently supported
[ "Psnr", "computes", "the", "PSNR", "between", "two", "input", "images", "Only", "ycbcr", "is", "currently", "supported" ]
29f4463c688b986c11f166b12734f69b58b5555f
https://github.com/bamiaux/rez/blob/29f4463c688b986c11f166b12734f69b58b5555f/image.go#L523-L540
17,335
bamiaux/rez
resize.go
NewResize
func NewResize(cfg *ResizerConfig, filter Filter) Resizer { ctx := context{ cfg: *cfg, } ctx.cfg.Depth = 8 // only 8-bit for now if ctx.cfg.Pack < 1 { ctx.cfg.Pack = 1 } ctx.kernels = []kernel{makeKernel(&ctx.cfg, filter, 0)} ctx.scaler = getHorizontalScaler(ctx.kernels[0].size, !cfg.DisableAsm) if cfg.Vert...
go
func NewResize(cfg *ResizerConfig, filter Filter) Resizer { ctx := context{ cfg: *cfg, } ctx.cfg.Depth = 8 // only 8-bit for now if ctx.cfg.Pack < 1 { ctx.cfg.Pack = 1 } ctx.kernels = []kernel{makeKernel(&ctx.cfg, filter, 0)} ctx.scaler = getHorizontalScaler(ctx.kernels[0].size, !cfg.DisableAsm) if cfg.Vert...
[ "func", "NewResize", "(", "cfg", "*", "ResizerConfig", ",", "filter", "Filter", ")", "Resizer", "{", "ctx", ":=", "context", "{", "cfg", ":", "*", "cfg", ",", "}", "\n", "ctx", ".", "cfg", ".", "Depth", "=", "8", "// only 8-bit for now", "\n", "if", ...
// NewResize returns a new resizer // cfg = resize configuration // filter = filter used for computing weights
[ "NewResize", "returns", "a", "new", "resizer", "cfg", "=", "resize", "configuration", "filter", "=", "filter", "used", "for", "computing", "weights" ]
29f4463c688b986c11f166b12734f69b58b5555f
https://github.com/bamiaux/rez/blob/29f4463c688b986c11f166b12734f69b58b5555f/resize.go#L80-L97
17,336
bamiaux/rez
fixedscalers.go
h8scale2Go
func h8scale2Go(dst, src []byte, cof, off []int16, taps, width, height, dp, sp int) { di := 0 si := 0 for y := 0; y < height; y++ { c := cof s := src[si:] d := dst[di:] for x, xoff := range off[:width] { pix := int(s[xoff+0])*int(c[0]) + int(s[xoff+1])*int(c[1]) d[x] = u8((pix + 1<<(Bits-1)) >> Bi...
go
func h8scale2Go(dst, src []byte, cof, off []int16, taps, width, height, dp, sp int) { di := 0 si := 0 for y := 0; y < height; y++ { c := cof s := src[si:] d := dst[di:] for x, xoff := range off[:width] { pix := int(s[xoff+0])*int(c[0]) + int(s[xoff+1])*int(c[1]) d[x] = u8((pix + 1<<(Bits-1)) >> Bi...
[ "func", "h8scale2Go", "(", "dst", ",", "src", "[", "]", "byte", ",", "cof", ",", "off", "[", "]", "int16", ",", "taps", ",", "width", ",", "height", ",", "dp", ",", "sp", "int", ")", "{", "di", ":=", "0", "\n", "si", ":=", "0", "\n", "for", ...
// This file is auto-generated - do not modify
[ "This", "file", "is", "auto", "-", "generated", "-", "do", "not", "modify" ]
29f4463c688b986c11f166b12734f69b58b5555f
https://github.com/bamiaux/rez/blob/29f4463c688b986c11f166b12734f69b58b5555f/fixedscalers.go#L9-L26
17,337
bamiaux/rez
utils.go
DumpImage
func DumpImage(prefix string, img image.Image) error { _, src, err := inspect(img, false) if err != nil { return err } for i, p := range src { err = dumpPlane(prefix, &p, i) if err != nil { return err } } return nil }
go
func DumpImage(prefix string, img image.Image) error { _, src, err := inspect(img, false) if err != nil { return err } for i, p := range src { err = dumpPlane(prefix, &p, i) if err != nil { return err } } return nil }
[ "func", "DumpImage", "(", "prefix", "string", ",", "img", "image", ".", "Image", ")", "error", "{", "_", ",", "src", ",", "err", ":=", "inspect", "(", "img", ",", "false", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n"...
// DumpImage dumps each img planes to disk using the input prefix
[ "DumpImage", "dumps", "each", "img", "planes", "to", "disk", "using", "the", "input", "prefix" ]
29f4463c688b986c11f166b12734f69b58b5555f
https://github.com/bamiaux/rez/blob/29f4463c688b986c11f166b12734f69b58b5555f/utils.go#L31-L43
17,338
weppos/publicsuffix-go
publicsuffix/publicsuffix.go
NewListFromString
func NewListFromString(src string, options *ParserOption) (*List, error) { l := NewList() _, err := l.LoadString(src, options) return l, err }
go
func NewListFromString(src string, options *ParserOption) (*List, error) { l := NewList() _, err := l.LoadString(src, options) return l, err }
[ "func", "NewListFromString", "(", "src", "string", ",", "options", "*", "ParserOption", ")", "(", "*", "List", ",", "error", ")", "{", "l", ":=", "NewList", "(", ")", "\n", "_", ",", "err", ":=", "l", ".", "LoadString", "(", "src", ",", "options", ...
// NewListFromString parses a string that represents a Public Suffix source // and returns a List initialized with the rules in the source.
[ "NewListFromString", "parses", "a", "string", "that", "represents", "a", "Public", "Suffix", "source", "and", "returns", "a", "List", "initialized", "with", "the", "rules", "in", "the", "source", "." ]
7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d
https://github.com/weppos/publicsuffix-go/blob/7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d/publicsuffix/publicsuffix.go#L94-L98
17,339
weppos/publicsuffix-go
publicsuffix/publicsuffix.go
NewListFromFile
func NewListFromFile(path string, options *ParserOption) (*List, error) { l := NewList() _, err := l.LoadFile(path, options) return l, err }
go
func NewListFromFile(path string, options *ParserOption) (*List, error) { l := NewList() _, err := l.LoadFile(path, options) return l, err }
[ "func", "NewListFromFile", "(", "path", "string", ",", "options", "*", "ParserOption", ")", "(", "*", "List", ",", "error", ")", "{", "l", ":=", "NewList", "(", ")", "\n", "_", ",", "err", ":=", "l", ".", "LoadFile", "(", "path", ",", "options", ")...
// NewListFromFile parses a string that represents a Public Suffix source // and returns a List initialized with the rules in the source.
[ "NewListFromFile", "parses", "a", "string", "that", "represents", "a", "Public", "Suffix", "source", "and", "returns", "a", "List", "initialized", "with", "the", "rules", "in", "the", "source", "." ]
7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d
https://github.com/weppos/publicsuffix-go/blob/7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d/publicsuffix/publicsuffix.go#L102-L106
17,340
weppos/publicsuffix-go
publicsuffix/publicsuffix.go
Load
func (l *List) Load(r io.Reader, options *ParserOption) ([]Rule, error) { return l.parse(r, options) }
go
func (l *List) Load(r io.Reader, options *ParserOption) ([]Rule, error) { return l.parse(r, options) }
[ "func", "(", "l", "*", "List", ")", "Load", "(", "r", "io", ".", "Reader", ",", "options", "*", "ParserOption", ")", "(", "[", "]", "Rule", ",", "error", ")", "{", "return", "l", ".", "parse", "(", "r", ",", "options", ")", "\n", "}" ]
// Load parses and loads a set of rules from an io.Reader into the current list.
[ "Load", "parses", "and", "loads", "a", "set", "of", "rules", "from", "an", "io", ".", "Reader", "into", "the", "current", "list", "." ]
7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d
https://github.com/weppos/publicsuffix-go/blob/7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d/publicsuffix/publicsuffix.go#L109-L111
17,341
weppos/publicsuffix-go
publicsuffix/publicsuffix.go
LoadString
func (l *List) LoadString(src string, options *ParserOption) ([]Rule, error) { r := strings.NewReader(src) return l.parse(r, options) }
go
func (l *List) LoadString(src string, options *ParserOption) ([]Rule, error) { r := strings.NewReader(src) return l.parse(r, options) }
[ "func", "(", "l", "*", "List", ")", "LoadString", "(", "src", "string", ",", "options", "*", "ParserOption", ")", "(", "[", "]", "Rule", ",", "error", ")", "{", "r", ":=", "strings", ".", "NewReader", "(", "src", ")", "\n", "return", "l", ".", "p...
// LoadString parses and loads a set of rules from a String into the current list.
[ "LoadString", "parses", "and", "loads", "a", "set", "of", "rules", "from", "a", "String", "into", "the", "current", "list", "." ]
7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d
https://github.com/weppos/publicsuffix-go/blob/7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d/publicsuffix/publicsuffix.go#L114-L117
17,342
weppos/publicsuffix-go
publicsuffix/publicsuffix.go
LoadFile
func (l *List) LoadFile(path string, options *ParserOption) ([]Rule, error) { f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() return l.parse(f, options) }
go
func (l *List) LoadFile(path string, options *ParserOption) ([]Rule, error) { f, err := os.Open(path) if err != nil { return nil, err } defer f.Close() return l.parse(f, options) }
[ "func", "(", "l", "*", "List", ")", "LoadFile", "(", "path", "string", ",", "options", "*", "ParserOption", ")", "(", "[", "]", "Rule", ",", "error", ")", "{", "f", ",", "err", ":=", "os", ".", "Open", "(", "path", ")", "\n", "if", "err", "!=",...
// LoadFile parses and loads a set of rules from a File into the current list.
[ "LoadFile", "parses", "and", "loads", "a", "set", "of", "rules", "from", "a", "File", "into", "the", "current", "list", "." ]
7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d
https://github.com/weppos/publicsuffix-go/blob/7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d/publicsuffix/publicsuffix.go#L120-L127
17,343
weppos/publicsuffix-go
publicsuffix/publicsuffix.go
AddRule
func (l *List) AddRule(r *Rule) error { l.rules[r.Value] = r return nil }
go
func (l *List) AddRule(r *Rule) error { l.rules[r.Value] = r return nil }
[ "func", "(", "l", "*", "List", ")", "AddRule", "(", "r", "*", "Rule", ")", "error", "{", "l", ".", "rules", "[", "r", ".", "Value", "]", "=", "r", "\n", "return", "nil", "\n", "}" ]
// AddRule adds a new rule to the list. // // The exact position of the rule into the list is unpredictable. // The list may be optimized internally for lookups, therefore the algorithm // will decide the best position for the new rule.
[ "AddRule", "adds", "a", "new", "rule", "to", "the", "list", ".", "The", "exact", "position", "of", "the", "rule", "into", "the", "list", "is", "unpredictable", ".", "The", "list", "may", "be", "optimized", "internally", "for", "lookups", "therefore", "the"...
7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d
https://github.com/weppos/publicsuffix-go/blob/7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d/publicsuffix/publicsuffix.go#L134-L137
17,344
weppos/publicsuffix-go
publicsuffix/publicsuffix.go
Find
func (l *List) Find(name string, options *FindOptions) *Rule { if options == nil { options = DefaultFindOptions } part := name for { rule, ok := l.rules[part] if ok && rule.Match(name) && !(options.IgnorePrivate && rule.Private) { return rule } i := strings.IndexRune(part, '.') if i < 0 { retur...
go
func (l *List) Find(name string, options *FindOptions) *Rule { if options == nil { options = DefaultFindOptions } part := name for { rule, ok := l.rules[part] if ok && rule.Match(name) && !(options.IgnorePrivate && rule.Private) { return rule } i := strings.IndexRune(part, '.') if i < 0 { retur...
[ "func", "(", "l", "*", "List", ")", "Find", "(", "name", "string", ",", "options", "*", "FindOptions", ")", "*", "Rule", "{", "if", "options", "==", "nil", "{", "options", "=", "DefaultFindOptions", "\n", "}", "\n\n", "part", ":=", "name", "\n", "for...
// Find and returns the most appropriate rule for the domain name.
[ "Find", "and", "returns", "the", "most", "appropriate", "rule", "for", "the", "domain", "name", "." ]
7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d
https://github.com/weppos/publicsuffix-go/blob/7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d/publicsuffix/publicsuffix.go#L197-L219
17,345
weppos/publicsuffix-go
publicsuffix/publicsuffix.go
MustNewRule
func MustNewRule(content string) *Rule { rule, err := NewRule(content) if err != nil { panic(err) } return rule }
go
func MustNewRule(content string) *Rule { rule, err := NewRule(content) if err != nil { panic(err) } return rule }
[ "func", "MustNewRule", "(", "content", "string", ")", "*", "Rule", "{", "rule", ",", "err", ":=", "NewRule", "(", "content", ")", "\n", "if", "err", "!=", "nil", "{", "panic", "(", "err", ")", "\n", "}", "\n", "return", "rule", "\n", "}" ]
// MustNewRule is like NewRule, but panics if the content cannot be parsed.
[ "MustNewRule", "is", "like", "NewRule", "but", "panics", "if", "the", "content", "cannot", "be", "parsed", "." ]
7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d
https://github.com/weppos/publicsuffix-go/blob/7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d/publicsuffix/publicsuffix.go#L260-L266
17,346
weppos/publicsuffix-go
publicsuffix/publicsuffix.go
PublicSuffix
func (l cookiejarList) PublicSuffix(domain string) string { rule := l.List.Find(domain, nil) return rule.Decompose(domain)[1] }
go
func (l cookiejarList) PublicSuffix(domain string) string { rule := l.List.Find(domain, nil) return rule.Decompose(domain)[1] }
[ "func", "(", "l", "cookiejarList", ")", "PublicSuffix", "(", "domain", "string", ")", "string", "{", "rule", ":=", "l", ".", "List", ".", "Find", "(", "domain", ",", "nil", ")", "\n", "return", "rule", ".", "Decompose", "(", "domain", ")", "[", "1", ...
// PublicSuffix implements cookiejar.PublicSuffixList.
[ "PublicSuffix", "implements", "cookiejar", ".", "PublicSuffixList", "." ]
7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d
https://github.com/weppos/publicsuffix-go/blob/7c1d5dc5cdc2b05f1ea58e40ed9bdee01d9d0e4d/publicsuffix/publicsuffix.go#L530-L533
17,347
a8m/tree
node.go
Visit
func (node *Node) Visit(opts *Options) (dirs, files int) { // visited paths if path, err := filepath.Abs(node.path); err == nil { path = filepath.Clean(path) node.vpaths[path] = true } // stat fi, err := opts.Fs.Stat(node.path) if err != nil { node.err = err return } node.FileInfo = fi if !fi.IsDir() {...
go
func (node *Node) Visit(opts *Options) (dirs, files int) { // visited paths if path, err := filepath.Abs(node.path); err == nil { path = filepath.Clean(path) node.vpaths[path] = true } // stat fi, err := opts.Fs.Stat(node.path) if err != nil { node.err = err return } node.FileInfo = fi if !fi.IsDir() {...
[ "func", "(", "node", "*", "Node", ")", "Visit", "(", "opts", "*", "Options", ")", "(", "dirs", ",", "files", "int", ")", "{", "// visited paths", "if", "path", ",", "err", ":=", "filepath", ".", "Abs", "(", "node", ".", "path", ")", ";", "err", "...
// Visit all files under the given node.
[ "Visit", "all", "files", "under", "the", "given", "node", "." ]
6a0b80129de45f91880d18428b95fab29df91d7e
https://github.com/a8m/tree/blob/6a0b80129de45f91880d18428b95fab29df91d7e/node.go#L82-L155
17,348
a8m/tree
node.go
formatBytes
func formatBytes(i int64) (result string) { var n float64 sFmt, eFmt := "%.01f", "" switch { case i > EB: eFmt = "E" n = float64(i) / float64(EB) case i > PB: eFmt = "P" n = float64(i) / float64(PB) case i > TB: eFmt = "T" n = float64(i) / float64(TB) case i > GB: eFmt = "G" n = float64(i) / floa...
go
func formatBytes(i int64) (result string) { var n float64 sFmt, eFmt := "%.01f", "" switch { case i > EB: eFmt = "E" n = float64(i) / float64(EB) case i > PB: eFmt = "P" n = float64(i) / float64(PB) case i > TB: eFmt = "T" n = float64(i) / float64(TB) case i > GB: eFmt = "G" n = float64(i) / floa...
[ "func", "formatBytes", "(", "i", "int64", ")", "(", "result", "string", ")", "{", "var", "n", "float64", "\n", "sFmt", ",", "eFmt", ":=", "\"", "\"", ",", "\"", "\"", "\n", "switch", "{", "case", "i", ">", "EB", ":", "eFmt", "=", "\"", "\"", "\...
// Convert bytes to human readable string. Like a 2 MB, 64.2 KB, 52 B
[ "Convert", "bytes", "to", "human", "readable", "string", ".", "Like", "a", "2", "MB", "64", ".", "2", "KB", "52", "B" ]
6a0b80129de45f91880d18428b95fab29df91d7e
https://github.com/a8m/tree/blob/6a0b80129de45f91880d18428b95fab29df91d7e/node.go#L367-L399
17,349
a8m/tree
color.go
contains
func contains(slice []string, str string) bool { for _, val := range slice { if val == strings.ToLower(str) { return true } } return false }
go
func contains(slice []string, str string) bool { for _, val := range slice { if val == strings.ToLower(str) { return true } } return false }
[ "func", "contains", "(", "slice", "[", "]", "string", ",", "str", "string", ")", "bool", "{", "for", "_", ",", "val", ":=", "range", "slice", "{", "if", "val", "==", "strings", ".", "ToLower", "(", "str", ")", "{", "return", "true", "\n", "}", "\...
// case-insensitive contains helper
[ "case", "-", "insensitive", "contains", "helper" ]
6a0b80129de45f91880d18428b95fab29df91d7e
https://github.com/a8m/tree/blob/6a0b80129de45f91880d18428b95fab29df91d7e/color.go#L65-L72
17,350
ghetzel/pivot
dal/record_loader.go
getIdentityFieldNameFromStruct
func getIdentityFieldNameFromStruct(instance interface{}, fallbackIdentityFieldName string) (string, string, error) { if err := validatePtrToStructType(instance); err != nil { return ``, ``, err } s := structs.New(instance) // find a field with an ",identity" tag and get its value for _, field := range s.Field...
go
func getIdentityFieldNameFromStruct(instance interface{}, fallbackIdentityFieldName string) (string, string, error) { if err := validatePtrToStructType(instance); err != nil { return ``, ``, err } s := structs.New(instance) // find a field with an ",identity" tag and get its value for _, field := range s.Field...
[ "func", "getIdentityFieldNameFromStruct", "(", "instance", "interface", "{", "}", ",", "fallbackIdentityFieldName", "string", ")", "(", "string", ",", "string", ",", "error", ")", "{", "if", "err", ":=", "validatePtrToStructType", "(", "instance", ")", ";", "err...
// Retrieves the struct field name and key name that represents the identity field for a given struct.
[ "Retrieves", "the", "struct", "field", "name", "and", "key", "name", "that", "represents", "the", "identity", "field", "for", "a", "given", "struct", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/record_loader.go#L25-L58
17,351
ghetzel/pivot
dal/connection.go
Scheme
func (self *ConnectionString) Scheme() (string, string) { backend, protocol := stringutil.SplitPair(self.URI.Scheme, `+`) return backend, strings.Trim(protocol, `/`) }
go
func (self *ConnectionString) Scheme() (string, string) { backend, protocol := stringutil.SplitPair(self.URI.Scheme, `+`) return backend, strings.Trim(protocol, `/`) }
[ "func", "(", "self", "*", "ConnectionString", ")", "Scheme", "(", ")", "(", "string", ",", "string", ")", "{", "backend", ",", "protocol", ":=", "stringutil", ".", "SplitPair", "(", "self", ".", "URI", ".", "Scheme", ",", "`+`", ")", "\n", "return", ...
// Returns the backend and protocol components of the string.
[ "Returns", "the", "backend", "and", "protocol", "components", "of", "the", "string", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/connection.go#L54-L57
17,352
ghetzel/pivot
dal/connection.go
Protocol
func (self *ConnectionString) Protocol(defaults ...string) string { if _, protocol := self.Scheme(); protocol != `` { return protocol } else if len(defaults) > 0 { return defaults[0] } else { return `` } }
go
func (self *ConnectionString) Protocol(defaults ...string) string { if _, protocol := self.Scheme(); protocol != `` { return protocol } else if len(defaults) > 0 { return defaults[0] } else { return `` } }
[ "func", "(", "self", "*", "ConnectionString", ")", "Protocol", "(", "defaults", "...", "string", ")", "string", "{", "if", "_", ",", "protocol", ":=", "self", ".", "Scheme", "(", ")", ";", "protocol", "!=", "``", "{", "return", "protocol", "\n", "}", ...
// Returns the protocol component of the string.
[ "Returns", "the", "protocol", "component", "of", "the", "string", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/connection.go#L66-L75
17,353
ghetzel/pivot
dal/connection.go
Host
func (self *ConnectionString) Host(defaults ...string) string { if host := self.URI.Host; host != `` { return host } else if len(defaults) > 0 { return defaults[0] } else { return `` } }
go
func (self *ConnectionString) Host(defaults ...string) string { if host := self.URI.Host; host != `` { return host } else if len(defaults) > 0 { return defaults[0] } else { return `` } }
[ "func", "(", "self", "*", "ConnectionString", ")", "Host", "(", "defaults", "...", "string", ")", "string", "{", "if", "host", ":=", "self", ".", "URI", ".", "Host", ";", "host", "!=", "``", "{", "return", "host", "\n", "}", "else", "if", "len", "(...
// Returns the host component of the string.
[ "Returns", "the", "host", "component", "of", "the", "string", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/connection.go#L78-L86
17,354
ghetzel/pivot
dal/connection.go
Dataset
func (self *ConnectionString) Dataset() string { dataset := self.URI.Path dataset = strings.TrimPrefix(dataset, `/`) dataset = strings.TrimSuffix(dataset, `/`) return dataset }
go
func (self *ConnectionString) Dataset() string { dataset := self.URI.Path dataset = strings.TrimPrefix(dataset, `/`) dataset = strings.TrimSuffix(dataset, `/`) return dataset }
[ "func", "(", "self", "*", "ConnectionString", ")", "Dataset", "(", ")", "string", "{", "dataset", ":=", "self", ".", "URI", ".", "Path", "\n", "dataset", "=", "strings", ".", "TrimPrefix", "(", "dataset", ",", "`/`", ")", "\n", "dataset", "=", "strings...
// Returns the dataset component of the string.
[ "Returns", "the", "dataset", "component", "of", "the", "string", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/connection.go#L89-L94
17,355
ghetzel/pivot
dal/connection.go
SetCredentials
func (self *ConnectionString) SetCredentials(username string, password string) { self.URI.User = url.UserPassword(username, password) }
go
func (self *ConnectionString) SetCredentials(username string, password string) { self.URI.User = url.UserPassword(username, password) }
[ "func", "(", "self", "*", "ConnectionString", ")", "SetCredentials", "(", "username", "string", ",", "password", "string", ")", "{", "self", ".", "URI", ".", "User", "=", "url", ".", "UserPassword", "(", "username", ",", "password", ")", "\n", "}" ]
// Explicitly set username and password on this connection string
[ "Explicitly", "set", "username", "and", "password", "on", "this", "connection", "string" ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/connection.go#L97-L99
17,356
ghetzel/pivot
dal/connection.go
LoadCredentialsFromNetrc
func (self *ConnectionString) LoadCredentialsFromNetrc(filename string) error { if u := self.URI.User; u == nil && filename != `` { filename = fileutil.MustExpandUser(filename) if fileutil.IsNonemptyFile(filename) { if netrcFile, err := netrc.Parse(filename); err == nil { if machine := netrcFile.Machine(s...
go
func (self *ConnectionString) LoadCredentialsFromNetrc(filename string) error { if u := self.URI.User; u == nil && filename != `` { filename = fileutil.MustExpandUser(filename) if fileutil.IsNonemptyFile(filename) { if netrcFile, err := netrc.Parse(filename); err == nil { if machine := netrcFile.Machine(s...
[ "func", "(", "self", "*", "ConnectionString", ")", "LoadCredentialsFromNetrc", "(", "filename", "string", ")", "error", "{", "if", "u", ":=", "self", ".", "URI", ".", "User", ";", "u", "==", "nil", "&&", "filename", "!=", "``", "{", "filename", "=", "f...
// Reads a .netrc-style file and loads the appropriate credentials. The host component of // this connection string is matched with the netrc "machine" field.
[ "Reads", "a", ".", "netrc", "-", "style", "file", "and", "loads", "the", "appropriate", "credentials", ".", "The", "host", "component", "of", "this", "connection", "string", "is", "matched", "with", "the", "netrc", "machine", "field", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/connection.go#L103-L127
17,357
ghetzel/pivot
dal/collection.go
NewCollection
func NewCollection(name string) *Collection { return &Collection{ Name: name, Fields: make([]Field, 0), IdentityField: DefaultIdentityField, IdentityFieldType: DefaultIdentityFieldType, IdentityFieldValidator: ValidateNotEmpty, } }
go
func NewCollection(name string) *Collection { return &Collection{ Name: name, Fields: make([]Field, 0), IdentityField: DefaultIdentityField, IdentityFieldType: DefaultIdentityFieldType, IdentityFieldValidator: ValidateNotEmpty, } }
[ "func", "NewCollection", "(", "name", "string", ")", "*", "Collection", "{", "return", "&", "Collection", "{", "Name", ":", "name", ",", "Fields", ":", "make", "(", "[", "]", "Field", ",", "0", ")", ",", "IdentityField", ":", "DefaultIdentityField", ",",...
// Create a new colllection definition with no fields.
[ "Create", "a", "new", "colllection", "definition", "with", "no", "fields", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L112-L120
17,358
ghetzel/pivot
dal/collection.go
TTL
func (self *Collection) TTL(record *Record) time.Duration { if self.TimeToLiveField != `` { if value := record.Get(self.TimeToLiveField); !typeutil.IsZero(value) { if expireAt := typeutil.V(value).Time(); !expireAt.IsZero() { return expireAt.Sub(time.Now()) } } } return 0 }
go
func (self *Collection) TTL(record *Record) time.Duration { if self.TimeToLiveField != `` { if value := record.Get(self.TimeToLiveField); !typeutil.IsZero(value) { if expireAt := typeutil.V(value).Time(); !expireAt.IsZero() { return expireAt.Sub(time.Now()) } } } return 0 }
[ "func", "(", "self", "*", "Collection", ")", "TTL", "(", "record", "*", "Record", ")", "time", ".", "Duration", "{", "if", "self", ".", "TimeToLiveField", "!=", "``", "{", "if", "value", ":=", "record", ".", "Get", "(", "self", ".", "TimeToLiveField", ...
// Return the duration until the TimeToLiveField in given record expires within the current collection. // Collections with an empty TimeToLiveField, or records with a missing or zero-valued TimeToLiveField // will return 0. If the record has already expired, the returned duration will be a negative number.
[ "Return", "the", "duration", "until", "the", "TimeToLiveField", "in", "given", "record", "expires", "within", "the", "current", "collection", ".", "Collections", "with", "an", "empty", "TimeToLiveField", "or", "records", "with", "a", "missing", "or", "zero", "-"...
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L125-L135
17,359
ghetzel/pivot
dal/collection.go
IsExpired
func (self *Collection) IsExpired(record *Record) bool { if self.TTL(record) < 0 { return true } else { return false } }
go
func (self *Collection) IsExpired(record *Record) bool { if self.TTL(record) < 0 { return true } else { return false } }
[ "func", "(", "self", "*", "Collection", ")", "IsExpired", "(", "record", "*", "Record", ")", "bool", "{", "if", "self", ".", "TTL", "(", "record", ")", "<", "0", "{", "return", "true", "\n", "}", "else", "{", "return", "false", "\n", "}", "\n", "...
// Expired records are those whose TTL duration is non-zero and negative.
[ "Expired", "records", "are", "those", "whose", "TTL", "duration", "is", "non", "-", "zero", "and", "negative", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L138-L144
17,360
ghetzel/pivot
dal/collection.go
GetIndexName
func (self *Collection) GetIndexName() string { if self.IndexName != `` { return self.IndexName } return self.Name }
go
func (self *Collection) GetIndexName() string { if self.IndexName != `` { return self.IndexName } return self.Name }
[ "func", "(", "self", "*", "Collection", ")", "GetIndexName", "(", ")", "string", "{", "if", "self", ".", "IndexName", "!=", "``", "{", "return", "self", ".", "IndexName", "\n", "}", "\n\n", "return", "self", ".", "Name", "\n", "}" ]
// Get the canonical name of the external index name.
[ "Get", "the", "canonical", "name", "of", "the", "external", "index", "name", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L147-L153
17,361
ghetzel/pivot
dal/collection.go
GetAggregatorName
func (self *Collection) GetAggregatorName() string { if self.IndexName != `` { return self.IndexName } return self.Name }
go
func (self *Collection) GetAggregatorName() string { if self.IndexName != `` { return self.IndexName } return self.Name }
[ "func", "(", "self", "*", "Collection", ")", "GetAggregatorName", "(", ")", "string", "{", "if", "self", ".", "IndexName", "!=", "``", "{", "return", "self", ".", "IndexName", "\n", "}", "\n\n", "return", "self", ".", "Name", "\n", "}" ]
// Get the canonical name of the dataset in an external aggregator service.
[ "Get", "the", "canonical", "name", "of", "the", "dataset", "in", "an", "external", "aggregator", "service", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L156-L162
17,362
ghetzel/pivot
dal/collection.go
SetIdentity
func (self *Collection) SetIdentity(name string, idtype Type, formatter FieldFormatterFunc, validator FieldValidatorFunc) *Collection { if name != `` { self.IdentityField = name } self.IdentityFieldType = idtype if formatter != nil { self.IdentityFieldFormatter = formatter } if validator != nil { self.Id...
go
func (self *Collection) SetIdentity(name string, idtype Type, formatter FieldFormatterFunc, validator FieldValidatorFunc) *Collection { if name != `` { self.IdentityField = name } self.IdentityFieldType = idtype if formatter != nil { self.IdentityFieldFormatter = formatter } if validator != nil { self.Id...
[ "func", "(", "self", "*", "Collection", ")", "SetIdentity", "(", "name", "string", ",", "idtype", "Type", ",", "formatter", "FieldFormatterFunc", ",", "validator", "FieldValidatorFunc", ")", "*", "Collection", "{", "if", "name", "!=", "``", "{", "self", ".",...
// Configure the identity field of a collection in a single function call.
[ "Configure", "the", "identity", "field", "of", "a", "collection", "in", "a", "single", "function", "call", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L165-L181
17,363
ghetzel/pivot
dal/collection.go
AddFields
func (self *Collection) AddFields(fields ...Field) *Collection { self.Fields = append(self.Fields, fields...) return self }
go
func (self *Collection) AddFields(fields ...Field) *Collection { self.Fields = append(self.Fields, fields...) return self }
[ "func", "(", "self", "*", "Collection", ")", "AddFields", "(", "fields", "...", "Field", ")", "*", "Collection", "{", "self", ".", "Fields", "=", "append", "(", "self", ".", "Fields", ",", "fields", "...", ")", "\n", "return", "self", "\n", "}" ]
// Append a field definition to this collection.
[ "Append", "a", "field", "definition", "to", "this", "collection", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L184-L187
17,364
ghetzel/pivot
dal/collection.go
ApplyDefinition
func (self *Collection) ApplyDefinition(definition *Collection) error { if definition != nil { if v := definition.IdentityField; v != `` { self.IdentityField = v } if v := definition.IdentityFieldType; v != `` { self.IdentityFieldType = v } if fn := definition.IdentityFieldFormatter; fn != nil { s...
go
func (self *Collection) ApplyDefinition(definition *Collection) error { if definition != nil { if v := definition.IdentityField; v != `` { self.IdentityField = v } if v := definition.IdentityFieldType; v != `` { self.IdentityFieldType = v } if fn := definition.IdentityFieldFormatter; fn != nil { s...
[ "func", "(", "self", "*", "Collection", ")", "ApplyDefinition", "(", "definition", "*", "Collection", ")", "error", "{", "if", "definition", "!=", "nil", "{", "if", "v", ":=", "definition", ".", "IdentityField", ";", "v", "!=", "``", "{", "self", ".", ...
// Copies certain collection and field properties from the definition object into this collection // instance. This is useful for collections that are created by parsing the schema as it exists on // the remote datastore, which will have some but not all of the information we need to work with the // data. Definition...
[ "Copies", "certain", "collection", "and", "field", "properties", "from", "the", "definition", "object", "into", "this", "collection", "instance", ".", "This", "is", "useful", "for", "collections", "that", "are", "created", "by", "parsing", "the", "schema", "as",...
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L198-L247
17,365
ghetzel/pivot
dal/collection.go
GetField
func (self *Collection) GetField(name string) (Field, bool) { if name == self.GetIdentityFieldName() { return Field{ Name: name, Type: self.IdentityFieldType, Index: self.IdentityFieldIndex, Identity: true, Key: true, Required: true, }, true } else { for _, field := range self....
go
func (self *Collection) GetField(name string) (Field, bool) { if name == self.GetIdentityFieldName() { return Field{ Name: name, Type: self.IdentityFieldType, Index: self.IdentityFieldIndex, Identity: true, Key: true, Required: true, }, true } else { for _, field := range self....
[ "func", "(", "self", "*", "Collection", ")", "GetField", "(", "name", "string", ")", "(", "Field", ",", "bool", ")", "{", "if", "name", "==", "self", ".", "GetIdentityFieldName", "(", ")", "{", "return", "Field", "{", "Name", ":", "name", ",", "Type"...
// Retrieve a single field by name. The second return value will be false if the field does not // exist.
[ "Retrieve", "a", "single", "field", "by", "name", ".", "The", "second", "return", "value", "will", "be", "false", "if", "the", "field", "does", "not", "exist", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L371-L390
17,366
ghetzel/pivot
dal/collection.go
GetFieldByIndex
func (self *Collection) GetFieldByIndex(index int) (Field, bool) { if index == self.IdentityFieldIndex { return Field{ Name: self.GetIdentityFieldName(), Type: self.IdentityFieldType, Index: self.IdentityFieldIndex, Identity: true, Key: true, Required: true, }, true } else { fo...
go
func (self *Collection) GetFieldByIndex(index int) (Field, bool) { if index == self.IdentityFieldIndex { return Field{ Name: self.GetIdentityFieldName(), Type: self.IdentityFieldType, Index: self.IdentityFieldIndex, Identity: true, Key: true, Required: true, }, true } else { fo...
[ "func", "(", "self", "*", "Collection", ")", "GetFieldByIndex", "(", "index", "int", ")", "(", "Field", ",", "bool", ")", "{", "if", "index", "==", "self", ".", "IdentityFieldIndex", "{", "return", "Field", "{", "Name", ":", "self", ".", "GetIdentityFiel...
// Retrieve a single field by its index value. The second return value will be false if a field // at that index does not exist.
[ "Retrieve", "a", "single", "field", "by", "its", "index", "value", ".", "The", "second", "return", "value", "will", "be", "false", "if", "a", "field", "at", "that", "index", "does", "not", "exist", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L394-L413
17,367
ghetzel/pivot
dal/collection.go
IsKeyField
func (self *Collection) IsKeyField(name string) bool { if field, ok := self.GetField(name); ok { return (field.Key && !field.Identity) } return false }
go
func (self *Collection) IsKeyField(name string) bool { if field, ok := self.GetField(name); ok { return (field.Key && !field.Identity) } return false }
[ "func", "(", "self", "*", "Collection", ")", "IsKeyField", "(", "name", "string", ")", "bool", "{", "if", "field", ",", "ok", ":=", "self", ".", "GetField", "(", "name", ")", ";", "ok", "{", "return", "(", "field", ".", "Key", "&&", "!", "field", ...
// Return whether a given field name is a key on this Collection.
[ "Return", "whether", "a", "given", "field", "name", "is", "a", "key", "on", "this", "Collection", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L434-L440
17,368
ghetzel/pivot
dal/collection.go
KeyFields
func (self *Collection) KeyFields() []Field { keys := []Field{ Field{ Name: self.GetIdentityFieldName(), Type: self.IdentityFieldType, Identity: true, Key: true, Required: true, }, } // append additional key fields for _, field := range self.Fields { if field.Key { keys = appen...
go
func (self *Collection) KeyFields() []Field { keys := []Field{ Field{ Name: self.GetIdentityFieldName(), Type: self.IdentityFieldType, Identity: true, Key: true, Required: true, }, } // append additional key fields for _, field := range self.Fields { if field.Key { keys = appen...
[ "func", "(", "self", "*", "Collection", ")", "KeyFields", "(", ")", "[", "]", "Field", "{", "keys", ":=", "[", "]", "Field", "{", "Field", "{", "Name", ":", "self", ".", "GetIdentityFieldName", "(", ")", ",", "Type", ":", "self", ".", "IdentityFieldT...
// Retrieve all of the fields that comprise the primary key for this Collection. This will always include the identity // field at a minimum.
[ "Retrieve", "all", "of", "the", "fields", "that", "comprise", "the", "primary", "key", "for", "this", "Collection", ".", "This", "will", "always", "include", "the", "identity", "field", "at", "a", "minimum", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L444-L463
17,369
ghetzel/pivot
dal/collection.go
GetFirstNonIdentityKeyField
func (self *Collection) GetFirstNonIdentityKeyField() (Field, bool) { for _, field := range self.Fields { if field.Key && !field.Identity { return field, true } } return Field{}, false }
go
func (self *Collection) GetFirstNonIdentityKeyField() (Field, bool) { for _, field := range self.Fields { if field.Key && !field.Identity { return field, true } } return Field{}, false }
[ "func", "(", "self", "*", "Collection", ")", "GetFirstNonIdentityKeyField", "(", ")", "(", "Field", ",", "bool", ")", "{", "for", "_", ",", "field", ":=", "range", "self", ".", "Fields", "{", "if", "field", ".", "Key", "&&", "!", "field", ".", "Ident...
// Retrieve the first non-indentity key field, sometimes referred to as the "range", "sort", or "cluster" key.
[ "Retrieve", "the", "first", "non", "-", "indentity", "key", "field", "sometimes", "referred", "to", "as", "the", "range", "sort", "or", "cluster", "key", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L471-L479
17,370
ghetzel/pivot
dal/collection.go
ConvertValue
func (self *Collection) ConvertValue(name string, value interface{}) interface{} { if field, ok := self.GetField(name); ok { if v, err := field.ConvertValue(value); err == nil { return v } } return value }
go
func (self *Collection) ConvertValue(name string, value interface{}) interface{} { if field, ok := self.GetField(name); ok { if v, err := field.ConvertValue(value); err == nil { return v } } return value }
[ "func", "(", "self", "*", "Collection", ")", "ConvertValue", "(", "name", "string", ",", "value", "interface", "{", "}", ")", "interface", "{", "}", "{", "if", "field", ",", "ok", ":=", "self", ".", "GetField", "(", "name", ")", ";", "ok", "{", "if...
// Convert a given value according to the data type of a specific named field.
[ "Convert", "a", "given", "value", "according", "to", "the", "data", "type", "of", "a", "specific", "named", "field", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L482-L490
17,371
ghetzel/pivot
dal/collection.go
MapFromRecord
func (self *Collection) MapFromRecord(record *Record, fields ...string) (map[string]interface{}, error) { rv := make(map[string]interface{}) for _, field := range self.Fields { if len(fields) > 0 && !sliceutil.ContainsString(fields, field.Name) { continue } if dv := field.GetDefaultValue(); dv != nil { ...
go
func (self *Collection) MapFromRecord(record *Record, fields ...string) (map[string]interface{}, error) { rv := make(map[string]interface{}) for _, field := range self.Fields { if len(fields) > 0 && !sliceutil.ContainsString(fields, field.Name) { continue } if dv := field.GetDefaultValue(); dv != nil { ...
[ "func", "(", "self", "*", "Collection", ")", "MapFromRecord", "(", "record", "*", "Record", ",", "fields", "...", "string", ")", "(", "map", "[", "string", "]", "interface", "{", "}", ",", "error", ")", "{", "rv", ":=", "make", "(", "map", "[", "st...
// Convert the given record into a map.
[ "Convert", "the", "given", "record", "into", "a", "map", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L690-L730
17,372
ghetzel/pivot
dal/collection.go
ValidateRecord
func (self *Collection) ValidateRecord(record *Record, op FieldOperation) error { switch op { case PersistOperation: // validate whole record (if specified) if self.PreSaveValidator != nil { if err := self.PreSaveValidator(record); err != nil { return err } } } return nil }
go
func (self *Collection) ValidateRecord(record *Record, op FieldOperation) error { switch op { case PersistOperation: // validate whole record (if specified) if self.PreSaveValidator != nil { if err := self.PreSaveValidator(record); err != nil { return err } } } return nil }
[ "func", "(", "self", "*", "Collection", ")", "ValidateRecord", "(", "record", "*", "Record", ",", "op", "FieldOperation", ")", "error", "{", "switch", "op", "{", "case", "PersistOperation", ":", "// validate whole record (if specified)", "if", "self", ".", "PreS...
// Validate the given record against all Field and Collection validators.
[ "Validate", "the", "given", "record", "against", "all", "Field", "and", "Collection", "validators", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L733-L745
17,373
ghetzel/pivot
dal/collection.go
Check
func (self *Collection) Check() error { var merr error for i, field := range self.Fields { if field.Name == `` { merr = log.AppendError(merr, fmt.Errorf("collection[%s] field #%d cannot have an empty name", self.Name, i)) } if ParseFieldType(string(field.Type)) == `` { merr = log.AppendError(merr, fmt.E...
go
func (self *Collection) Check() error { var merr error for i, field := range self.Fields { if field.Name == `` { merr = log.AppendError(merr, fmt.Errorf("collection[%s] field #%d cannot have an empty name", self.Name, i)) } if ParseFieldType(string(field.Type)) == `` { merr = log.AppendError(merr, fmt.E...
[ "func", "(", "self", "*", "Collection", ")", "Check", "(", ")", "error", "{", "var", "merr", "error", "\n\n", "for", "i", ",", "field", ":=", "range", "self", ".", "Fields", "{", "if", "field", ".", "Name", "==", "``", "{", "merr", "=", "log", "....
// Verifies that the schema passes some basic sanity checks.
[ "Verifies", "that", "the", "schema", "passes", "some", "basic", "sanity", "checks", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/collection.go#L748-L762
17,374
ghetzel/pivot
mapper/model.go
Get
func (self *Model) Get(id interface{}, into interface{}) error { if record, err := self.db.Retrieve(self.collection.Name, id); err == nil { return record.Populate(into, self.collection) } else { return err } }
go
func (self *Model) Get(id interface{}, into interface{}) error { if record, err := self.db.Retrieve(self.collection.Name, id); err == nil { return record.Populate(into, self.collection) } else { return err } }
[ "func", "(", "self", "*", "Model", ")", "Get", "(", "id", "interface", "{", "}", ",", "into", "interface", "{", "}", ")", "error", "{", "if", "record", ",", "err", ":=", "self", ".", "db", ".", "Retrieve", "(", "self", ".", "collection", ".", "Na...
// Retrieves an instance of the model identified by the given ID and populates the value pointed to // by the into parameter. Structs and dal.Record instances can be populated. //
[ "Retrieves", "an", "instance", "of", "the", "model", "identified", "by", "the", "given", "ID", "and", "populates", "the", "value", "pointed", "to", "by", "the", "into", "parameter", ".", "Structs", "and", "dal", ".", "Record", "instances", "can", "be", "po...
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/mapper/model.go#L123-L129
17,375
ghetzel/pivot
mapper/model.go
Exists
func (self *Model) Exists(id interface{}) bool { return self.db.Exists(self.collection.Name, id) }
go
func (self *Model) Exists(id interface{}) bool { return self.db.Exists(self.collection.Name, id) }
[ "func", "(", "self", "*", "Model", ")", "Exists", "(", "id", "interface", "{", "}", ")", "bool", "{", "return", "self", ".", "db", ".", "Exists", "(", "self", ".", "collection", ".", "Name", ",", "id", ")", "\n", "}" ]
// Tests whether a record exists for the given ID. //
[ "Tests", "whether", "a", "record", "exists", "for", "the", "given", "ID", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/mapper/model.go#L133-L135
17,376
ghetzel/pivot
mapper/model.go
Update
func (self *Model) Update(from interface{}) error { if record, err := self.collection.MakeRecord(from); err == nil { return self.db.Update(self.collection.Name, dal.NewRecordSet(record)) } else { return err } }
go
func (self *Model) Update(from interface{}) error { if record, err := self.collection.MakeRecord(from); err == nil { return self.db.Update(self.collection.Name, dal.NewRecordSet(record)) } else { return err } }
[ "func", "(", "self", "*", "Model", ")", "Update", "(", "from", "interface", "{", "}", ")", "error", "{", "if", "record", ",", "err", ":=", "self", ".", "collection", ".", "MakeRecord", "(", "from", ")", ";", "err", "==", "nil", "{", "return", "self...
// Updates and saves an existing instance of the model from the given struct or dal.Record. //
[ "Updates", "and", "saves", "an", "existing", "instance", "of", "the", "model", "from", "the", "given", "struct", "or", "dal", ".", "Record", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/mapper/model.go#L139-L145
17,377
ghetzel/pivot
mapper/model.go
CreateOrUpdate
func (self *Model) CreateOrUpdate(id interface{}, from interface{}) error { if id == nil || !self.Exists(id) { return self.Create(from) } else { return self.Update(from) } }
go
func (self *Model) CreateOrUpdate(id interface{}, from interface{}) error { if id == nil || !self.Exists(id) { return self.Create(from) } else { return self.Update(from) } }
[ "func", "(", "self", "*", "Model", ")", "CreateOrUpdate", "(", "id", "interface", "{", "}", ",", "from", "interface", "{", "}", ")", "error", "{", "if", "id", "==", "nil", "||", "!", "self", ".", "Exists", "(", "id", ")", "{", "return", "self", "...
// Creates or updates an instance of the model depending on whether it exists or not. //
[ "Creates", "or", "updates", "an", "instance", "of", "the", "model", "depending", "on", "whether", "it", "exists", "or", "not", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/mapper/model.go#L149-L155
17,378
ghetzel/pivot
mapper/model.go
Delete
func (self *Model) Delete(ids ...interface{}) error { return self.db.Delete(self.collection.Name, ids...) }
go
func (self *Model) Delete(ids ...interface{}) error { return self.db.Delete(self.collection.Name, ids...) }
[ "func", "(", "self", "*", "Model", ")", "Delete", "(", "ids", "...", "interface", "{", "}", ")", "error", "{", "return", "self", ".", "db", ".", "Delete", "(", "self", ".", "collection", ".", "Name", ",", "ids", "...", ")", "\n", "}" ]
// Delete instances of the model identified by the given IDs //
[ "Delete", "instances", "of", "the", "model", "identified", "by", "the", "given", "IDs" ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/mapper/model.go#L159-L161
17,379
ghetzel/pivot
mapper/model.go
DeleteQuery
func (self *Model) DeleteQuery(flt interface{}) error { if f, err := self.filterFromInterface(flt); err == nil { f.IdentityField = self.collection.IdentityField if search := self.db.WithSearch(self.collection, f); search != nil { return search.DeleteQuery(self.collection, f) } else { return fmt.Errorf("ba...
go
func (self *Model) DeleteQuery(flt interface{}) error { if f, err := self.filterFromInterface(flt); err == nil { f.IdentityField = self.collection.IdentityField if search := self.db.WithSearch(self.collection, f); search != nil { return search.DeleteQuery(self.collection, f) } else { return fmt.Errorf("ba...
[ "func", "(", "self", "*", "Model", ")", "DeleteQuery", "(", "flt", "interface", "{", "}", ")", "error", "{", "if", "f", ",", "err", ":=", "self", ".", "filterFromInterface", "(", "flt", ")", ";", "err", "==", "nil", "{", "f", ".", "IdentityField", ...
// Delete all records matching the given query.
[ "Delete", "all", "records", "matching", "the", "given", "query", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/mapper/model.go#L164-L176
17,380
ghetzel/pivot
mapper/model.go
Find
func (self *Model) Find(flt interface{}, into interface{}) error { if f, err := self.filterFromInterface(flt); err == nil { f.IdentityField = self.collection.IdentityField if search := self.db.WithSearch(self.collection, f); search != nil { // perform query if recordset, err := search.Query(self.collection,...
go
func (self *Model) Find(flt interface{}, into interface{}) error { if f, err := self.filterFromInterface(flt); err == nil { f.IdentityField = self.collection.IdentityField if search := self.db.WithSearch(self.collection, f); search != nil { // perform query if recordset, err := search.Query(self.collection,...
[ "func", "(", "self", "*", "Model", ")", "Find", "(", "flt", "interface", "{", "}", ",", "into", "interface", "{", "}", ")", "error", "{", "if", "f", ",", "err", ":=", "self", ".", "filterFromInterface", "(", "flt", ")", ";", "err", "==", "nil", "...
// Perform a query for instances of the model that match the given filter.Filter. // Results will be returned in the slice or array pointed to by the into parameter, or // if into points to a dal.RecordSet, the RecordSet resulting from the query will be returned // as-is. //
[ "Perform", "a", "query", "for", "instances", "of", "the", "model", "that", "match", "the", "given", "filter", ".", "Filter", ".", "Results", "will", "be", "returned", "in", "the", "slice", "or", "array", "pointed", "to", "by", "the", "into", "parameter", ...
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/mapper/model.go#L183-L200
17,381
ghetzel/pivot
mapper/model.go
FindFunc
func (self *Model) FindFunc(flt interface{}, destZeroValue interface{}, resultFn ResultFunc) error { if f, err := self.filterFromInterface(flt); err == nil { f.IdentityField = self.collection.IdentityField if search := self.db.WithSearch(self.collection, f); search != nil { _, err := search.Query(self.collecti...
go
func (self *Model) FindFunc(flt interface{}, destZeroValue interface{}, resultFn ResultFunc) error { if f, err := self.filterFromInterface(flt); err == nil { f.IdentityField = self.collection.IdentityField if search := self.db.WithSearch(self.collection, f); search != nil { _, err := search.Query(self.collecti...
[ "func", "(", "self", "*", "Model", ")", "FindFunc", "(", "flt", "interface", "{", "}", ",", "destZeroValue", "interface", "{", "}", ",", "resultFn", "ResultFunc", ")", "error", "{", "if", "f", ",", "err", ":=", "self", ".", "filterFromInterface", "(", ...
// Perform a query for instances of the model that match the given filter.Filter. // The given callback function will be called once per result. //
[ "Perform", "a", "query", "for", "instances", "of", "the", "model", "that", "match", "the", "given", "filter", ".", "Filter", ".", "The", "given", "callback", "function", "will", "be", "called", "once", "per", "result", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/mapper/model.go#L205-L240
17,382
ghetzel/pivot
dal/formatters.go
GenerateUUID
func GenerateUUID(value interface{}, _ FieldOperation) (interface{}, error) { if record, ok := value.(*Record); ok { value = record.ID } if typeutil.IsZero(value) { value = stringutil.UUID().String() } return value, nil }
go
func GenerateUUID(value interface{}, _ FieldOperation) (interface{}, error) { if record, ok := value.(*Record); ok { value = record.ID } if typeutil.IsZero(value) { value = stringutil.UUID().String() } return value, nil }
[ "func", "GenerateUUID", "(", "value", "interface", "{", "}", ",", "_", "FieldOperation", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "record", ",", "ok", ":=", "value", ".", "(", "*", "Record", ")", ";", "ok", "{", "value", "=", ...
// Generates a V4 UUID value if the existing value is empty.
[ "Generates", "a", "V4", "UUID", "value", "if", "the", "existing", "value", "is", "empty", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/formatters.go#L191-L201
17,383
ghetzel/pivot
dal/formatters.go
GenerateEncodedUUID
func GenerateEncodedUUID(encoder EncoderFunc) FieldFormatterFunc { return func(value interface{}, _ FieldOperation) (interface{}, error) { if record, ok := value.(*Record); ok { value = record.ID } if typeutil.IsZero(value) { if v, err := encoder(stringutil.UUID().Bytes()); err == nil { if typeutil.Is...
go
func GenerateEncodedUUID(encoder EncoderFunc) FieldFormatterFunc { return func(value interface{}, _ FieldOperation) (interface{}, error) { if record, ok := value.(*Record); ok { value = record.ID } if typeutil.IsZero(value) { if v, err := encoder(stringutil.UUID().Bytes()); err == nil { if typeutil.Is...
[ "func", "GenerateEncodedUUID", "(", "encoder", "EncoderFunc", ")", "FieldFormatterFunc", "{", "return", "func", "(", "value", "interface", "{", "}", ",", "_", "FieldOperation", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "record", ",", "...
// Same as GenerateUUID, but allows for a custom representation of the underlying bytes.
[ "Same", "as", "GenerateUUID", "but", "allows", "for", "a", "custom", "representation", "of", "the", "underlying", "bytes", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/formatters.go#L204-L224
17,384
ghetzel/pivot
dal/formatters.go
IfUnset
func IfUnset(onlyIf FieldFormatterFunc) FieldFormatterFunc { return func(value interface{}, op FieldOperation) (interface{}, error) { if onlyIf != nil { if typeutil.IsZero(value) { return onlyIf(value, op) } } return value, nil } }
go
func IfUnset(onlyIf FieldFormatterFunc) FieldFormatterFunc { return func(value interface{}, op FieldOperation) (interface{}, error) { if onlyIf != nil { if typeutil.IsZero(value) { return onlyIf(value, op) } } return value, nil } }
[ "func", "IfUnset", "(", "onlyIf", "FieldFormatterFunc", ")", "FieldFormatterFunc", "{", "return", "func", "(", "value", "interface", "{", "}", ",", "op", "FieldOperation", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "onlyIf", "!=", "nil"...
// Only evaluates the given formatter if the current value of the field is empty.
[ "Only", "evaluates", "the", "given", "formatter", "if", "the", "current", "value", "of", "the", "field", "is", "empty", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/formatters.go#L227-L237
17,385
ghetzel/pivot
dal/formatters.go
DeriveFromFields
func DeriveFromFields(format string, fields ...string) FieldFormatterFunc { return func(input interface{}, _ FieldOperation) (interface{}, error) { if record, ok := input.(*Record); ok { values := make([]interface{}, len(fields)) for i, field := range fields { values[i] = record.Get(field) } return...
go
func DeriveFromFields(format string, fields ...string) FieldFormatterFunc { return func(input interface{}, _ FieldOperation) (interface{}, error) { if record, ok := input.(*Record); ok { values := make([]interface{}, len(fields)) for i, field := range fields { values[i] = record.Get(field) } return...
[ "func", "DeriveFromFields", "(", "format", "string", ",", "fields", "...", "string", ")", "FieldFormatterFunc", "{", "return", "func", "(", "input", "interface", "{", "}", ",", "_", "FieldOperation", ")", "(", "interface", "{", "}", ",", "error", ")", "{",...
// Extracts values from the given Record and generates a deterministic output based on those values.
[ "Extracts", "values", "from", "the", "given", "Record", "and", "generates", "a", "deterministic", "output", "based", "on", "those", "values", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/formatters.go#L240-L254
17,386
ghetzel/pivot
dal/formatters.go
CurrentTime
func CurrentTime(value interface{}, op FieldOperation) (interface{}, error) { if op == PersistOperation { return time.Now(), nil } else { return value, nil } }
go
func CurrentTime(value interface{}, op FieldOperation) (interface{}, error) { if op == PersistOperation { return time.Now(), nil } else { return value, nil } }
[ "func", "CurrentTime", "(", "value", "interface", "{", "}", ",", "op", "FieldOperation", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "op", "==", "PersistOperation", "{", "return", "time", ".", "Now", "(", ")", ",", "nil", "\n", "}"...
// Returns the current time every time the field is persisted.
[ "Returns", "the", "current", "time", "every", "time", "the", "field", "is", "persisted", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/formatters.go#L257-L263
17,387
ghetzel/pivot
dal/formatters.go
CurrentTimeIfUnset
func CurrentTimeIfUnset(value interface{}, op FieldOperation) (interface{}, error) { return IfUnset(func(v interface{}, o FieldOperation) (interface{}, error) { if o == PersistOperation { return time.Now(), nil } else { return v, nil } })(value, op) }
go
func CurrentTimeIfUnset(value interface{}, op FieldOperation) (interface{}, error) { return IfUnset(func(v interface{}, o FieldOperation) (interface{}, error) { if o == PersistOperation { return time.Now(), nil } else { return v, nil } })(value, op) }
[ "func", "CurrentTimeIfUnset", "(", "value", "interface", "{", "}", ",", "op", "FieldOperation", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "return", "IfUnset", "(", "func", "(", "v", "interface", "{", "}", ",", "o", "FieldOperation", ")", ...
// Returns the current time when the field is persisted if the current value is empty.
[ "Returns", "the", "current", "time", "when", "the", "field", "is", "persisted", "if", "the", "current", "value", "is", "empty", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/formatters.go#L266-L274
17,388
ghetzel/pivot
dal/formatters.go
NowPlusDuration
func NowPlusDuration(duration time.Duration) FieldFormatterFunc { return func(value interface{}, op FieldOperation) (interface{}, error) { if op == PersistOperation { if duration != 0 { return time.Now().Add(duration), nil } } return value, nil } }
go
func NowPlusDuration(duration time.Duration) FieldFormatterFunc { return func(value interface{}, op FieldOperation) (interface{}, error) { if op == PersistOperation { if duration != 0 { return time.Now().Add(duration), nil } } return value, nil } }
[ "func", "NowPlusDuration", "(", "duration", "time", ".", "Duration", ")", "FieldFormatterFunc", "{", "return", "func", "(", "value", "interface", "{", "}", ",", "op", "FieldOperation", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "op", ...
// Returns the current time with an added offset when the field is persisted.
[ "Returns", "the", "current", "time", "with", "an", "added", "offset", "when", "the", "field", "is", "persisted", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/formatters.go#L277-L287
17,389
ghetzel/pivot
dal/validators.go
ValidateMatchAll
func ValidateMatchAll(patterns ...string) FieldValidatorFunc { prx := make([]*regexp.Regexp, len(patterns)) for i, rxs := range patterns { prx[i] = regexp.MustCompile(rxs) } return func(value interface{}) error { for _, rx := range prx { if !rx.MatchString(typeutil.String(value)) { return fmt.Errorf("V...
go
func ValidateMatchAll(patterns ...string) FieldValidatorFunc { prx := make([]*regexp.Regexp, len(patterns)) for i, rxs := range patterns { prx[i] = regexp.MustCompile(rxs) } return func(value interface{}) error { for _, rx := range prx { if !rx.MatchString(typeutil.String(value)) { return fmt.Errorf("V...
[ "func", "ValidateMatchAll", "(", "patterns", "...", "string", ")", "FieldValidatorFunc", "{", "prx", ":=", "make", "(", "[", "]", "*", "regexp", ".", "Regexp", ",", "len", "(", "patterns", ")", ")", "\n\n", "for", "i", ",", "rxs", ":=", "range", "patte...
// Validate that the given value matches all of the given regular expressions.
[ "Validate", "that", "the", "given", "value", "matches", "all", "of", "the", "given", "regular", "expressions", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/validators.go#L73-L89
17,390
ghetzel/pivot
dal/validators.go
ValidateAll
func ValidateAll(validators ...FieldValidatorFunc) FieldValidatorFunc { return func(value interface{}) error { for _, validator := range validators { if err := validator(value); err != nil { return err } } return nil } }
go
func ValidateAll(validators ...FieldValidatorFunc) FieldValidatorFunc { return func(value interface{}) error { for _, validator := range validators { if err := validator(value); err != nil { return err } } return nil } }
[ "func", "ValidateAll", "(", "validators", "...", "FieldValidatorFunc", ")", "FieldValidatorFunc", "{", "return", "func", "(", "value", "interface", "{", "}", ")", "error", "{", "for", "_", ",", "validator", ":=", "range", "validators", "{", "if", "err", ":="...
// Validate that all of the given validator functions pass.
[ "Validate", "that", "all", "of", "the", "given", "validator", "functions", "pass", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/validators.go#L111-L121
17,391
ghetzel/pivot
dal/validators.go
ValidateIsOneOf
func ValidateIsOneOf(choices ...interface{}) FieldValidatorFunc { return func(value interface{}) error { for _, choice := range choices { if ok, err := stringutil.RelaxedEqual(choice, value); err == nil && ok { return nil } } return fmt.Errorf("value must be one of: %+v", choices) } }
go
func ValidateIsOneOf(choices ...interface{}) FieldValidatorFunc { return func(value interface{}) error { for _, choice := range choices { if ok, err := stringutil.RelaxedEqual(choice, value); err == nil && ok { return nil } } return fmt.Errorf("value must be one of: %+v", choices) } }
[ "func", "ValidateIsOneOf", "(", "choices", "...", "interface", "{", "}", ")", "FieldValidatorFunc", "{", "return", "func", "(", "value", "interface", "{", "}", ")", "error", "{", "for", "_", ",", "choice", ":=", "range", "choices", "{", "if", "ok", ",", ...
// Validate that the given value is among the given choices.
[ "Validate", "that", "the", "given", "value", "is", "among", "the", "given", "choices", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/validators.go#L124-L134
17,392
ghetzel/pivot
dal/validators.go
ValidateNotEmpty
func ValidateNotEmpty(value interface{}) error { if typeutil.IsEmpty(value) { return fmt.Errorf("expected non-empty value, got: %v", value) } return nil }
go
func ValidateNotEmpty(value interface{}) error { if typeutil.IsEmpty(value) { return fmt.Errorf("expected non-empty value, got: %v", value) } return nil }
[ "func", "ValidateNotEmpty", "(", "value", "interface", "{", "}", ")", "error", "{", "if", "typeutil", ".", "IsEmpty", "(", "value", ")", "{", "return", "fmt", ".", "Errorf", "(", "\"", "\"", ",", "value", ")", "\n", "}", "\n\n", "return", "nil", "\n"...
// Validate that the given value is not a zero value, and if it's a string, that the string // does not contain only whitespace.
[ "Validate", "that", "the", "given", "value", "is", "not", "a", "zero", "value", "and", "if", "it", "s", "a", "string", "that", "the", "string", "does", "not", "contain", "only", "whitespace", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/validators.go#L147-L153
17,393
ghetzel/pivot
dal/validators.go
ValidatePositiveInteger
func ValidatePositiveInteger(value interface{}) error { if v, err := stringutil.ConvertToInteger(value); err == nil { if v <= 0 { return fmt.Errorf("expected value > 0, got: %v", v) } } else { return err } return nil }
go
func ValidatePositiveInteger(value interface{}) error { if v, err := stringutil.ConvertToInteger(value); err == nil { if v <= 0 { return fmt.Errorf("expected value > 0, got: %v", v) } } else { return err } return nil }
[ "func", "ValidatePositiveInteger", "(", "value", "interface", "{", "}", ")", "error", "{", "if", "v", ",", "err", ":=", "stringutil", ".", "ConvertToInteger", "(", "value", ")", ";", "err", "==", "nil", "{", "if", "v", "<=", "0", "{", "return", "fmt", ...
// Validate that the given value is an integer > 0.
[ "Validate", "that", "the", "given", "value", "is", "an", "integer", ">", "0", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/validators.go#L156-L166
17,394
ghetzel/pivot
dal/validators.go
ValidateIsURL
func ValidateIsURL(value interface{}) error { if u, err := url.Parse(typeutil.String(value)); err == nil { if u.Scheme == `` || u.Host == `` || u.Path == `` { return fmt.Errorf("Invalid URL") } } else { return err } return nil }
go
func ValidateIsURL(value interface{}) error { if u, err := url.Parse(typeutil.String(value)); err == nil { if u.Scheme == `` || u.Host == `` || u.Path == `` { return fmt.Errorf("Invalid URL") } } else { return err } return nil }
[ "func", "ValidateIsURL", "(", "value", "interface", "{", "}", ")", "error", "{", "if", "u", ",", "err", ":=", "url", ".", "Parse", "(", "typeutil", ".", "String", "(", "value", ")", ")", ";", "err", "==", "nil", "{", "if", "u", ".", "Scheme", "==...
// Validate that the value is a URL with a non-empty scheme and host component.
[ "Validate", "that", "the", "value", "is", "a", "URL", "with", "a", "non", "-", "empty", "scheme", "and", "host", "component", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/validators.go#L182-L192
17,395
ghetzel/pivot
backends/redis.go
run
func (self *RedisBackend) run(cmd string, args ...interface{}) (interface{}, error) { if conn := self.pool.Get(); conn != nil { defer conn.Close() // debug := strings.Join(sliceutil.Stringify(args), ` `) // querylog.Debugf("[%v] %v %v", self, cmd, debug) return redis.DoWithTimeout(conn, self.cmdTimeout, cmd, ...
go
func (self *RedisBackend) run(cmd string, args ...interface{}) (interface{}, error) { if conn := self.pool.Get(); conn != nil { defer conn.Close() // debug := strings.Join(sliceutil.Stringify(args), ` `) // querylog.Debugf("[%v] %v %v", self, cmd, debug) return redis.DoWithTimeout(conn, self.cmdTimeout, cmd, ...
[ "func", "(", "self", "*", "RedisBackend", ")", "run", "(", "cmd", "string", ",", "args", "...", "interface", "{", "}", ")", "(", "interface", "{", "}", ",", "error", ")", "{", "if", "conn", ":=", "self", ".", "pool", ".", "Get", "(", ")", ";", ...
// wraps the process of borrowing a connection from the pool and running a command
[ "wraps", "the", "process", "of", "borrowing", "a", "connection", "from", "the", "pool", "and", "running", "a", "command" ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/backends/redis.go#L461-L471
17,396
ghetzel/pivot
backends/sql-indexer.go
DeleteQuery
func (self *SqlBackend) DeleteQuery(collection *dal.Collection, f *filter.Filter) error { if tx, err := self.db.Begin(); err == nil { queryGen := self.makeQueryGen(collection) queryGen.Type = generators.SqlDeleteStatement // generate SQL if stmt, err := filter.Render(queryGen, collection.Name, f); err == nil ...
go
func (self *SqlBackend) DeleteQuery(collection *dal.Collection, f *filter.Filter) error { if tx, err := self.db.Begin(); err == nil { queryGen := self.makeQueryGen(collection) queryGen.Type = generators.SqlDeleteStatement // generate SQL if stmt, err := filter.Render(queryGen, collection.Name, f); err == nil ...
[ "func", "(", "self", "*", "SqlBackend", ")", "DeleteQuery", "(", "collection", "*", "dal", ".", "Collection", ",", "f", "*", "filter", ".", "Filter", ")", "error", "{", "if", "tx", ",", "err", ":=", "self", ".", "db", ".", "Begin", "(", ")", ";", ...
// DeleteQuery removes records using a filter
[ "DeleteQuery", "removes", "records", "using", "a", "filter" ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/backends/sql-indexer.go#L240-L267
17,397
ghetzel/pivot
dal/recordset.go
PopulateFromRecords
func (self *RecordSet) PopulateFromRecords(into interface{}, schema *Collection) error { vInto := reflect.ValueOf(into) // get value pointed to if we were given a pointer if vInto.Kind() == reflect.Ptr { vInto = vInto.Elem() } else { return fmt.Errorf("Output argument must be a pointer") } // we're going to...
go
func (self *RecordSet) PopulateFromRecords(into interface{}, schema *Collection) error { vInto := reflect.ValueOf(into) // get value pointed to if we were given a pointer if vInto.Kind() == reflect.Ptr { vInto = vInto.Elem() } else { return fmt.Errorf("Output argument must be a pointer") } // we're going to...
[ "func", "(", "self", "*", "RecordSet", ")", "PopulateFromRecords", "(", "into", "interface", "{", "}", ",", "schema", "*", "Collection", ")", "error", "{", "vInto", ":=", "reflect", ".", "ValueOf", "(", "into", ")", "\n\n", "// get value pointed to if we were ...
// Takes a slice of structs or maps and fills it with instances populated by the records in this RecordSet // in accordance with the types specified in the given collection definition, as well as which // fields are available in the given struct.
[ "Takes", "a", "slice", "of", "structs", "or", "maps", "and", "fills", "it", "with", "instances", "populated", "by", "the", "records", "in", "this", "RecordSet", "in", "accordance", "with", "the", "types", "specified", "in", "the", "given", "collection", "def...
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/recordset.go#L80-L138
17,398
ghetzel/pivot
dal/record.go
Populate
func (self *Record) Populate(into interface{}, collection *Collection) error { // special case for what is essentially copying another record into this one if record, ok := into.(*Record); ok { return self.Copy(record, collection) } else { if err := validatePtrToStructType(into); err != nil { return err } ...
go
func (self *Record) Populate(into interface{}, collection *Collection) error { // special case for what is essentially copying another record into this one if record, ok := into.(*Record); ok { return self.Copy(record, collection) } else { if err := validatePtrToStructType(into); err != nil { return err } ...
[ "func", "(", "self", "*", "Record", ")", "Populate", "(", "into", "interface", "{", "}", ",", "collection", "*", "Collection", ")", "error", "{", "// special case for what is essentially copying another record into this one", "if", "record", ",", "ok", ":=", "into",...
// Populates a given struct with with the values in this record.
[ "Populates", "a", "given", "struct", "with", "with", "the", "values", "in", "this", "record", "." ]
29df2462a60d3752a1218e3b6736c5fdb1e77c2d
https://github.com/ghetzel/pivot/blob/29df2462a60d3752a1218e3b6736c5fdb1e77c2d/dal/record.go#L242-L284
17,399
cloudfoundry/lager
lagerctx/context.go
NewContext
func NewContext(parent context.Context, logger lager.Logger) context.Context { return context.WithValue(parent, contextKey{}, logger) }
go
func NewContext(parent context.Context, logger lager.Logger) context.Context { return context.WithValue(parent, contextKey{}, logger) }
[ "func", "NewContext", "(", "parent", "context", ".", "Context", ",", "logger", "lager", ".", "Logger", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "parent", ",", "contextKey", "{", "}", ",", "logger", ")", "\n", "}" ]
// NewContext returns a derived context containing the logger.
[ "NewContext", "returns", "a", "derived", "context", "containing", "the", "logger", "." ]
54c4f2530ddeb742ce9c9ee26f5fa758d6c1b3b6
https://github.com/cloudfoundry/lager/blob/54c4f2530ddeb742ce9c9ee26f5fa758d6c1b3b6/lagerctx/context.go#L12-L14