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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
153,800 | brankas/envcfg | opts.go | KeyFilter | func KeyFilter(key string, f Filter) Option {
return func(ec *Envcfg) {
ec.filters[key] = f
}
} | go | func KeyFilter(key string, f Filter) Option {
return func(ec *Envcfg) {
ec.filters[key] = f
}
} | [
"func",
"KeyFilter",
"(",
"key",
"string",
",",
"f",
"Filter",
")",
"Option",
"{",
"return",
"func",
"(",
"ec",
"*",
"Envcfg",
")",
"{",
"ec",
".",
"filters",
"[",
"key",
"]",
"=",
"f",
"\n",
"}",
"\n",
"}"
] | // KeyFilter is an option that adds a key filter. | [
"KeyFilter",
"is",
"an",
"option",
"that",
"adds",
"a",
"key",
"filter",
"."
] | 11e4db35a7fbbc24210c5b24d548f404cc88f491 | https://github.com/brankas/envcfg/blob/11e4db35a7fbbc24210c5b24d548f404cc88f491/opts.go#L22-L26 |
153,801 | ArchCI/archci | controllers/hooks.go | TriggerGithubPushHook | func (c *ApiController) TriggerGithubPushHook() {
log.Info("Trigger github push hook")
/*
{
"zen": "Mind your words, they are important.",
"hook_id": 5371014,
"hook": {
"url": "https://api.github.com/repos/ArchCI/success-test/hooks/5371014",
"test_url": "https://api.github.com/repos/ArchCI/success-test/hooks/5371014/test",
"ping_url": "https://api.github.com/repos/ArchCI/success-test/hooks/5371014/pings",
"id": 5371014,
"name": "web",
"active": true,
"events": [
"push"
],
"config": {
"url": "http://192.168.1.113:10010/v1/hook/github/push",
"content_type": "json",
"insecure_ssl": "0",
"secret": "********"
},
"last_response": {
"code": null,
"status": "unused",
"message": null
},
"updated_at": "2015-07-22T14:48:22Z",
"created_at": "2015-07-22T14:48:22Z"
},
"repository": {
"id": 39022734,
"name": "success-test",
"full_name": "ArchCI/success-test",
"owner": {
"login": "ArchCI",
"id": 12673804,
"avatar_url": "https://avatars.githubusercontent.com/u/12673804?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/ArchCI",
"html_url": "https://github.com/ArchCI",
"followers_url": "https://api.github.com/users/ArchCI/followers",
"following_url": "https://api.github.com/users/ArchCI/following{/other_user}",
"gists_url": "https://api.github.com/users/ArchCI/gists{/gist_id}",
"starred_url": "https://api.github.com/users/ArchCI/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ArchCI/subscriptions",
"organizations_url": "https://api.github.com/users/ArchCI/orgs",
"repos_url": "https://api.github.com/users/ArchCI/repos",
"events_url": "https://api.github.com/users/ArchCI/events{/privacy}",
"received_events_url": "https://api.github.com/users/ArchCI/received_events",
"type": "Organization",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/ArchCI/success-test",
"description": "Success test project for ArchCI",
"fork": false,
"url": "https://api.github.com/repos/ArchCI/success-test",
"forks_url": "https://api.github.com/repos/ArchCI/success-test/forks",
"keys_url": "https://api.github.com/repos/ArchCI/success-test/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/ArchCI/success-test/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/ArchCI/success-test/teams",
"hooks_url": "https://api.github.com/repos/ArchCI/success-test/hooks",
"issue_events_url": "https://api.github.com/repos/ArchCI/success-test/issues/events{/number}",
"events_url": "https://api.github.com/repos/ArchCI/success-test/events",
"assignees_url": "https://api.github.com/repos/ArchCI/success-test/assignees{/user}",
"branches_url": "https://api.github.com/repos/ArchCI/success-test/branches{/branch}",
"tags_url": "https://api.github.com/repos/ArchCI/success-test/tags",
"blobs_url": "https://api.github.com/repos/ArchCI/success-test/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/ArchCI/success-test/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/ArchCI/success-test/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/ArchCI/success-test/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/ArchCI/success-test/statuses/{sha}",
"languages_url": "https://api.github.com/repos/ArchCI/success-test/languages",
"stargazers_url": "https://api.github.com/repos/ArchCI/success-test/stargazers",
"contributors_url": "https://api.github.com/repos/ArchCI/success-test/contributors",
"subscribers_url": "https://api.github.com/repos/ArchCI/success-test/subscribers",
"subscription_url": "https://api.github.com/repos/ArchCI/success-test/subscription",
"commits_url": "https://api.github.com/repos/ArchCI/success-test/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/ArchCI/success-test/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/ArchCI/success-test/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/ArchCI/success-test/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/ArchCI/success-test/contents/{+path}",
"compare_url": "https://api.github.com/repos/ArchCI/success-test/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/ArchCI/success-test/merges",
"archive_url": "https://api.github.com/repos/ArchCI/success-test/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/ArchCI/success-test/downloads",
"issues_url": "https://api.github.com/repos/ArchCI/success-test/issues{/number}",
"pulls_url": "https://api.github.com/repos/ArchCI/success-test/pulls{/number}",
"milestones_url": "https://api.github.com/repos/ArchCI/success-test/milestones{/number}",
"notifications_url": "https://api.github.com/repos/ArchCI/success-test/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/ArchCI/success-test/labels{/name}",
"releases_url": "https://api.github.com/repos/ArchCI/success-test/releases{/id}",
"created_at": "2015-07-13T16:06:28Z",
"updated_at": "2015-07-22T02:12:02Z",
"pushed_at": "2015-07-22T02:12:02Z",
"git_url": "git://github.com/ArchCI/success-test.git",
"ssh_url": "git@github.com:ArchCI/success-test.git",
"clone_url": "https://github.com/ArchCI/success-test.git",
"svn_url": "https://github.com/ArchCI/success-test",
"homepage": null,
"size": 120,
"stargazers_count": 0,
"watchers_count": 0,
"language": "Go",
"has_issues": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 0,
"mirror_url": null,
"open_issues_count": 0,
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master"
},
"sender": {
"login": "tobegit3hub",
"id": 2715000,
"avatar_url": "https://avatars.githubusercontent.com/u/2715000?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/tobegit3hub",
"html_url": "https://github.com/tobegit3hub",
"followers_url": "https://api.github.com/users/tobegit3hub/followers",
"following_url": "https://api.github.com/users/tobegit3hub/following{/other_user}",
"gists_url": "https://api.github.com/users/tobegit3hub/gists{/gist_id}",
"starred_url": "https://api.github.com/users/tobegit3hub/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/tobegit3hub/subscriptions",
"organizations_url": "https://api.github.com/users/tobegit3hub/orgs",
"repos_url": "https://api.github.com/users/tobegit3hub/repos",
"events_url": "https://api.github.com/users/tobegit3hub/events{/privacy}",
"received_events_url": "https://api.github.com/users/tobegit3hub/received_events",
"type": "User",
"site_admin": false
}
}
*/
hook := githubutil.GithubPushHook{}
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &hook); err != nil {
c.Ctx.Output.SetStatus(400)
c.Ctx.Output.Body([]byte("empty title"))
fmt.Println(err)
}
projectId, _ := models.ReadOrCreateProject(hook.Repository.Owner.Login, hook.Repository.Name, hook.Repository.URL)
models.AddGithubBuild(projectId, hook)
return
} | go | func (c *ApiController) TriggerGithubPushHook() {
log.Info("Trigger github push hook")
/*
{
"zen": "Mind your words, they are important.",
"hook_id": 5371014,
"hook": {
"url": "https://api.github.com/repos/ArchCI/success-test/hooks/5371014",
"test_url": "https://api.github.com/repos/ArchCI/success-test/hooks/5371014/test",
"ping_url": "https://api.github.com/repos/ArchCI/success-test/hooks/5371014/pings",
"id": 5371014,
"name": "web",
"active": true,
"events": [
"push"
],
"config": {
"url": "http://192.168.1.113:10010/v1/hook/github/push",
"content_type": "json",
"insecure_ssl": "0",
"secret": "********"
},
"last_response": {
"code": null,
"status": "unused",
"message": null
},
"updated_at": "2015-07-22T14:48:22Z",
"created_at": "2015-07-22T14:48:22Z"
},
"repository": {
"id": 39022734,
"name": "success-test",
"full_name": "ArchCI/success-test",
"owner": {
"login": "ArchCI",
"id": 12673804,
"avatar_url": "https://avatars.githubusercontent.com/u/12673804?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/ArchCI",
"html_url": "https://github.com/ArchCI",
"followers_url": "https://api.github.com/users/ArchCI/followers",
"following_url": "https://api.github.com/users/ArchCI/following{/other_user}",
"gists_url": "https://api.github.com/users/ArchCI/gists{/gist_id}",
"starred_url": "https://api.github.com/users/ArchCI/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ArchCI/subscriptions",
"organizations_url": "https://api.github.com/users/ArchCI/orgs",
"repos_url": "https://api.github.com/users/ArchCI/repos",
"events_url": "https://api.github.com/users/ArchCI/events{/privacy}",
"received_events_url": "https://api.github.com/users/ArchCI/received_events",
"type": "Organization",
"site_admin": false
},
"private": false,
"html_url": "https://github.com/ArchCI/success-test",
"description": "Success test project for ArchCI",
"fork": false,
"url": "https://api.github.com/repos/ArchCI/success-test",
"forks_url": "https://api.github.com/repos/ArchCI/success-test/forks",
"keys_url": "https://api.github.com/repos/ArchCI/success-test/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/ArchCI/success-test/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/ArchCI/success-test/teams",
"hooks_url": "https://api.github.com/repos/ArchCI/success-test/hooks",
"issue_events_url": "https://api.github.com/repos/ArchCI/success-test/issues/events{/number}",
"events_url": "https://api.github.com/repos/ArchCI/success-test/events",
"assignees_url": "https://api.github.com/repos/ArchCI/success-test/assignees{/user}",
"branches_url": "https://api.github.com/repos/ArchCI/success-test/branches{/branch}",
"tags_url": "https://api.github.com/repos/ArchCI/success-test/tags",
"blobs_url": "https://api.github.com/repos/ArchCI/success-test/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/ArchCI/success-test/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/ArchCI/success-test/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/ArchCI/success-test/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/ArchCI/success-test/statuses/{sha}",
"languages_url": "https://api.github.com/repos/ArchCI/success-test/languages",
"stargazers_url": "https://api.github.com/repos/ArchCI/success-test/stargazers",
"contributors_url": "https://api.github.com/repos/ArchCI/success-test/contributors",
"subscribers_url": "https://api.github.com/repos/ArchCI/success-test/subscribers",
"subscription_url": "https://api.github.com/repos/ArchCI/success-test/subscription",
"commits_url": "https://api.github.com/repos/ArchCI/success-test/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/ArchCI/success-test/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/ArchCI/success-test/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/ArchCI/success-test/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/ArchCI/success-test/contents/{+path}",
"compare_url": "https://api.github.com/repos/ArchCI/success-test/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/ArchCI/success-test/merges",
"archive_url": "https://api.github.com/repos/ArchCI/success-test/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/ArchCI/success-test/downloads",
"issues_url": "https://api.github.com/repos/ArchCI/success-test/issues{/number}",
"pulls_url": "https://api.github.com/repos/ArchCI/success-test/pulls{/number}",
"milestones_url": "https://api.github.com/repos/ArchCI/success-test/milestones{/number}",
"notifications_url": "https://api.github.com/repos/ArchCI/success-test/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/ArchCI/success-test/labels{/name}",
"releases_url": "https://api.github.com/repos/ArchCI/success-test/releases{/id}",
"created_at": "2015-07-13T16:06:28Z",
"updated_at": "2015-07-22T02:12:02Z",
"pushed_at": "2015-07-22T02:12:02Z",
"git_url": "git://github.com/ArchCI/success-test.git",
"ssh_url": "git@github.com:ArchCI/success-test.git",
"clone_url": "https://github.com/ArchCI/success-test.git",
"svn_url": "https://github.com/ArchCI/success-test",
"homepage": null,
"size": 120,
"stargazers_count": 0,
"watchers_count": 0,
"language": "Go",
"has_issues": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 0,
"mirror_url": null,
"open_issues_count": 0,
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master"
},
"sender": {
"login": "tobegit3hub",
"id": 2715000,
"avatar_url": "https://avatars.githubusercontent.com/u/2715000?v=3",
"gravatar_id": "",
"url": "https://api.github.com/users/tobegit3hub",
"html_url": "https://github.com/tobegit3hub",
"followers_url": "https://api.github.com/users/tobegit3hub/followers",
"following_url": "https://api.github.com/users/tobegit3hub/following{/other_user}",
"gists_url": "https://api.github.com/users/tobegit3hub/gists{/gist_id}",
"starred_url": "https://api.github.com/users/tobegit3hub/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/tobegit3hub/subscriptions",
"organizations_url": "https://api.github.com/users/tobegit3hub/orgs",
"repos_url": "https://api.github.com/users/tobegit3hub/repos",
"events_url": "https://api.github.com/users/tobegit3hub/events{/privacy}",
"received_events_url": "https://api.github.com/users/tobegit3hub/received_events",
"type": "User",
"site_admin": false
}
}
*/
hook := githubutil.GithubPushHook{}
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &hook); err != nil {
c.Ctx.Output.SetStatus(400)
c.Ctx.Output.Body([]byte("empty title"))
fmt.Println(err)
}
projectId, _ := models.ReadOrCreateProject(hook.Repository.Owner.Login, hook.Repository.Name, hook.Repository.URL)
models.AddGithubBuild(projectId, hook)
return
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"TriggerGithubPushHook",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"/*\n\t\t{\n\t\t \"zen\": \"Mind your words, they are important.\",\n\t\t \"hook_id\": 5371014,\n\t\t \"hook\": {\n\t\t\t\"url\": \"https://ap... | // TriggerGithubPushHook processes github push hook to trigger build. | [
"TriggerGithubPushHook",
"processes",
"github",
"push",
"hook",
"to",
"trigger",
"build",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/hooks.go#L15-L169 |
153,802 | ArchCI/archci | controllers/hooks.go | TriggerGitlabPushHook | func (c *ApiController) TriggerGitlabPushHook() {
log.Info("Trigger gitlab push hook")
/*
{
"before":"dd80657a63bf284fc1b62c5242addac10c8ee68b",
"after":"f9ccf83322e36793a244cf2da379e358154bdd62",
"ref":"refs/heads/master",
"user_id":72,
"user_name":"chendihao",
"project_id":412,
"repository":{
"name":"gitlab_hook",
"url":"git@git.ustack.com:chendihao/gitlab_hook.git",
"description":"","homepage":"http://git.ustack.com/chendihao/gitlab_hook"
},
"commits":[
{
"id":"f9ccf83322e36793a244cf2da379e358154bdd62",
"message":"Add introduction in readme",
"timestamp":"2015-07-24T02:00:34+00:00",
"url":"http://git.ustack.com/chendihao/gitlab_hook/commit/f9ccf83322e36793a244cf2da379e358154bdd62",
"author":{
"name":"tobe",
"email":"tobeg3oogle@gmail.com"
}
},{
"id":"dd80657a63bf284fc1b62c5242addac10c8ee68b",
"message":"Add readme",
"timestamp":"2015-07-23T02:47:30+00:00",
"url":"http://git.ustack.com/chendihao/gitlab_hook/commit/dd80657a63bf284fc1b62c5242addac10c8ee68b",
"author":{
"name":"tobe",
"email":"tobeg3oogle@gmail.com"
}
}
],
"total_commits_count":2
}
*/
hook := gitlabutil.GitlabPushHook{}
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &hook); err != nil {
c.Ctx.Output.SetStatus(400)
c.Ctx.Output.Body([]byte("empty title"))
fmt.Println(err)
}
projectId, _ := models.ReadOrCreateProject(hook.UserName, hook.Repository.Name, hook.Repository.URL)
models.AddGitlabBuild(projectId, hook)
return
} | go | func (c *ApiController) TriggerGitlabPushHook() {
log.Info("Trigger gitlab push hook")
/*
{
"before":"dd80657a63bf284fc1b62c5242addac10c8ee68b",
"after":"f9ccf83322e36793a244cf2da379e358154bdd62",
"ref":"refs/heads/master",
"user_id":72,
"user_name":"chendihao",
"project_id":412,
"repository":{
"name":"gitlab_hook",
"url":"git@git.ustack.com:chendihao/gitlab_hook.git",
"description":"","homepage":"http://git.ustack.com/chendihao/gitlab_hook"
},
"commits":[
{
"id":"f9ccf83322e36793a244cf2da379e358154bdd62",
"message":"Add introduction in readme",
"timestamp":"2015-07-24T02:00:34+00:00",
"url":"http://git.ustack.com/chendihao/gitlab_hook/commit/f9ccf83322e36793a244cf2da379e358154bdd62",
"author":{
"name":"tobe",
"email":"tobeg3oogle@gmail.com"
}
},{
"id":"dd80657a63bf284fc1b62c5242addac10c8ee68b",
"message":"Add readme",
"timestamp":"2015-07-23T02:47:30+00:00",
"url":"http://git.ustack.com/chendihao/gitlab_hook/commit/dd80657a63bf284fc1b62c5242addac10c8ee68b",
"author":{
"name":"tobe",
"email":"tobeg3oogle@gmail.com"
}
}
],
"total_commits_count":2
}
*/
hook := gitlabutil.GitlabPushHook{}
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &hook); err != nil {
c.Ctx.Output.SetStatus(400)
c.Ctx.Output.Body([]byte("empty title"))
fmt.Println(err)
}
projectId, _ := models.ReadOrCreateProject(hook.UserName, hook.Repository.Name, hook.Repository.URL)
models.AddGitlabBuild(projectId, hook)
return
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"TriggerGitlabPushHook",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"/*\n\t\t{\n\t\t\"before\":\"dd80657a63bf284fc1b62c5242addac10c8ee68b\",\n\t\t\"after\":\"f9ccf83322e36793a244cf2da379e358154bdd62\",\n\t\t\"ref\... | // TriggerGitlabPushHook processes gitlab push hook to trigger build. | [
"TriggerGitlabPushHook",
"processes",
"gitlab",
"push",
"hook",
"to",
"trigger",
"build",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/hooks.go#L172-L226 |
153,803 | ArchCI/archci | controllers/projects.go | GetProjectsAll | func (c *ApiController) GetProjectsAll() {
log.Info("Get all projects")
projects := models.GetAllProjects()
c.Data["json"] = projects
c.ServeJson()
} | go | func (c *ApiController) GetProjectsAll() {
log.Info("Get all projects")
projects := models.GetAllProjects()
c.Data["json"] = projects
c.ServeJson()
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetProjectsAll",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"projects",
":=",
"models",
".",
"GetAllProjects",
"(",
")",
"\n\n",
"c",
".",
"Data",
"[",
"\"",
"\"",
"]",
"=",
"proje... | // GetProjectsAll return all projects from database. | [
"GetProjectsAll",
"return",
"all",
"projects",
"from",
"database",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/projects.go#L30-L37 |
153,804 | ArchCI/archci | controllers/projects.go | GetProject | func (c *ApiController) GetProject() {
log.Info("Get project")
projectId, _ := c.GetInt64(":projectId")
project := models.GetProjectWithId(projectId)
c.Data["json"] = project
c.ServeJson()
} | go | func (c *ApiController) GetProject() {
log.Info("Get project")
projectId, _ := c.GetInt64(":projectId")
project := models.GetProjectWithId(projectId)
c.Data["json"] = project
c.ServeJson()
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetProject",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"projectId",
",",
"_",
":=",
"c",
".",
"GetInt64",
"(",
"\"",
"\"",
")",
"\n",
"project",
":=",
"models",
".",
"GetProjectWi... | // GetProject take project id and return the project. | [
"GetProject",
"take",
"project",
"id",
"and",
"return",
"the",
"project",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/projects.go#L40-L48 |
153,805 | ArchCI/archci | controllers/projects.go | DeleteProjectAndBuilds | func (c *ApiController) DeleteProjectAndBuilds() {
log.Info("Delete project and the builds")
projectId, _ := c.GetInt64(":projectId")
models.DeleteProject(projectId)
models.DeleteBuildsWithProjectId(projectId)
return
} | go | func (c *ApiController) DeleteProjectAndBuilds() {
log.Info("Delete project and the builds")
projectId, _ := c.GetInt64(":projectId")
models.DeleteProject(projectId)
models.DeleteBuildsWithProjectId(projectId)
return
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"DeleteProjectAndBuilds",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"projectId",
",",
"_",
":=",
"c",
".",
"GetInt64",
"(",
"\"",
"\"",
")",
"\n",
"models",
".",
"DeleteProject",
"("... | // DeleteProjectAndBuilds deletes the project and the relative builds. | [
"DeleteProjectAndBuilds",
"deletes",
"the",
"project",
"and",
"the",
"relative",
"builds",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/projects.go#L51-L59 |
153,806 | davidminor/gorand | pcg/pcg64.go | NextN | func (pcg *Pcg128x64) NextN(bounds uint64) uint64 {
threshold := (0 - bounds) % bounds
for {
result := pcg.Next()
if result >= threshold {
return result % bounds;
}
}
} | go | func (pcg *Pcg128x64) NextN(bounds uint64) uint64 {
threshold := (0 - bounds) % bounds
for {
result := pcg.Next()
if result >= threshold {
return result % bounds;
}
}
} | [
"func",
"(",
"pcg",
"*",
"Pcg128x64",
")",
"NextN",
"(",
"bounds",
"uint64",
")",
"uint64",
"{",
"threshold",
":=",
"(",
"0",
"-",
"bounds",
")",
"%",
"bounds",
"\n",
"for",
"{",
"result",
":=",
"pcg",
".",
"Next",
"(",
")",
"\n",
"if",
"result",
... | // Get a random uint64 value evenly distributed in [0,bounds) | [
"Get",
"a",
"random",
"uint64",
"value",
"evenly",
"distributed",
"in",
"[",
"0",
"bounds",
")"
] | 283446f2caf531f8b71b3a766b6d5a4b198825f7 | https://github.com/davidminor/gorand/blob/283446f2caf531f8b71b3a766b6d5a4b198825f7/pcg/pcg64.go#L34-L42 |
153,807 | davidminor/gorand | pcg/pcg64.go | Stream | func (rng *Pcg128x64) Stream(streamH, streamL uint64) {
// stream must be odd for LCG, so shift left 1 and turn on the 1 bit
rng.lcg.Stream = Uint128{streamH,streamL}.ShiftLeft(1)
rng.lcg.Stream.L |= 1
} | go | func (rng *Pcg128x64) Stream(streamH, streamL uint64) {
// stream must be odd for LCG, so shift left 1 and turn on the 1 bit
rng.lcg.Stream = Uint128{streamH,streamL}.ShiftLeft(1)
rng.lcg.Stream.L |= 1
} | [
"func",
"(",
"rng",
"*",
"Pcg128x64",
")",
"Stream",
"(",
"streamH",
",",
"streamL",
"uint64",
")",
"{",
"// stream must be odd for LCG, so shift left 1 and turn on the 1 bit",
"rng",
".",
"lcg",
".",
"Stream",
"=",
"Uint128",
"{",
"streamH",
",",
"streamL",
"}",
... | // Set the stream of this PCG | [
"Set",
"the",
"stream",
"of",
"this",
"PCG"
] | 283446f2caf531f8b71b3a766b6d5a4b198825f7 | https://github.com/davidminor/gorand/blob/283446f2caf531f8b71b3a766b6d5a4b198825f7/pcg/pcg64.go#L45-L49 |
153,808 | davidminor/gorand | pcg/pcg64.go | NewPcg64 | func NewPcg64(seedH, seedL uint64) Pcg64 {
lcg := lcglib.NewLcg128(Uint128{seedH, seedL})
return Pcg64{NewPcg128x64(lcg, XslRr)}
} | go | func NewPcg64(seedH, seedL uint64) Pcg64 {
lcg := lcglib.NewLcg128(Uint128{seedH, seedL})
return Pcg64{NewPcg128x64(lcg, XslRr)}
} | [
"func",
"NewPcg64",
"(",
"seedH",
",",
"seedL",
"uint64",
")",
"Pcg64",
"{",
"lcg",
":=",
"lcglib",
".",
"NewLcg128",
"(",
"Uint128",
"{",
"seedH",
",",
"seedL",
"}",
")",
"\n",
"return",
"Pcg64",
"{",
"NewPcg128x64",
"(",
"lcg",
",",
"XslRr",
")",
"... | // Create a new Pcg64 with the given high and low bits of seed | [
"Create",
"a",
"new",
"Pcg64",
"with",
"the",
"given",
"high",
"and",
"low",
"bits",
"of",
"seed"
] | 283446f2caf531f8b71b3a766b6d5a4b198825f7 | https://github.com/davidminor/gorand/blob/283446f2caf531f8b71b3a766b6d5a4b198825f7/pcg/pcg64.go#L57-L60 |
153,809 | davidminor/gorand | pcg/pcg64.go | NewPcg64Stream | func NewPcg64Stream(seedH, seedL, streamH, streamL uint64) Pcg64 {
lcg := lcglib.NewLcg128Stream(Uint128{seedH, seedL},
Uint128{streamH, streamL})
return Pcg64{NewPcg128x64(lcg, XslRr)}
} | go | func NewPcg64Stream(seedH, seedL, streamH, streamL uint64) Pcg64 {
lcg := lcglib.NewLcg128Stream(Uint128{seedH, seedL},
Uint128{streamH, streamL})
return Pcg64{NewPcg128x64(lcg, XslRr)}
} | [
"func",
"NewPcg64Stream",
"(",
"seedH",
",",
"seedL",
",",
"streamH",
",",
"streamL",
"uint64",
")",
"Pcg64",
"{",
"lcg",
":=",
"lcglib",
".",
"NewLcg128Stream",
"(",
"Uint128",
"{",
"seedH",
",",
"seedL",
"}",
",",
"Uint128",
"{",
"streamH",
",",
"strea... | // Create a new Pcg64 with the given high and low bits of seed and stream | [
"Create",
"a",
"new",
"Pcg64",
"with",
"the",
"given",
"high",
"and",
"low",
"bits",
"of",
"seed",
"and",
"stream"
] | 283446f2caf531f8b71b3a766b6d5a4b198825f7 | https://github.com/davidminor/gorand/blob/283446f2caf531f8b71b3a766b6d5a4b198825f7/pcg/pcg64.go#L63-L67 |
153,810 | davidminor/gorand | pcg/pcg64.go | XslRr | func XslRr(state Uint128) uint64 {
h, l := state.H, state.L
shift := l ^ h;
rot := h >> 58;
return (shift >> rot) | (shift << (64 - rot));
} | go | func XslRr(state Uint128) uint64 {
h, l := state.H, state.L
shift := l ^ h;
rot := h >> 58;
return (shift >> rot) | (shift << (64 - rot));
} | [
"func",
"XslRr",
"(",
"state",
"Uint128",
")",
"uint64",
"{",
"h",
",",
"l",
":=",
"state",
".",
"H",
",",
"state",
".",
"L",
"\n",
"shift",
":=",
"l",
"^",
"h",
";",
"rot",
":=",
"h",
">>",
"58",
";",
"return",
"(",
"shift",
">>",
"rot",
")"... | // Permute functions
// Xor the state's top bits with the bottom and randomly rotate them
// based on the highest 6 bits. | [
"Permute",
"functions",
"Xor",
"the",
"state",
"s",
"top",
"bits",
"with",
"the",
"bottom",
"and",
"randomly",
"rotate",
"them",
"based",
"on",
"the",
"highest",
"6",
"bits",
"."
] | 283446f2caf531f8b71b3a766b6d5a4b198825f7 | https://github.com/davidminor/gorand/blob/283446f2caf531f8b71b3a766b6d5a4b198825f7/pcg/pcg64.go#L73-L78 |
153,811 | ArchCI/archci | redisutil/util.go | GetString | func GetString(key string) string {
c, err := redis.Dial("tcp", GetRedisServer())
if err != nil {
panic(err)
}
defer c.Close()
value, err := redis.String(c.Do("GET", key))
if err != nil {
fmt.Println("key not found")
}
return value
} | go | func GetString(key string) string {
c, err := redis.Dial("tcp", GetRedisServer())
if err != nil {
panic(err)
}
defer c.Close()
value, err := redis.String(c.Do("GET", key))
if err != nil {
fmt.Println("key not found")
}
return value
} | [
"func",
"GetString",
"(",
"key",
"string",
")",
"string",
"{",
"c",
",",
"err",
":=",
"redis",
".",
"Dial",
"(",
"\"",
"\"",
",",
"GetRedisServer",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",
"\n",
"}",
"\n",
"... | // GetString performs the get command to return string. | [
"GetString",
"performs",
"the",
"get",
"command",
"to",
"return",
"string",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/redisutil/util.go#L28-L41 |
153,812 | ArchCI/archci | redisutil/util.go | HgetString | func HgetString(key string, field int) string {
c, err := redis.Dial("tcp", GetRedisServer())
if err != nil {
panic(err)
}
defer c.Close()
value, err := redis.String(c.Do("HGET", key, field))
if err != nil {
fmt.Println("key not found")
}
return value
} | go | func HgetString(key string, field int) string {
c, err := redis.Dial("tcp", GetRedisServer())
if err != nil {
panic(err)
}
defer c.Close()
value, err := redis.String(c.Do("HGET", key, field))
if err != nil {
fmt.Println("key not found")
}
return value
} | [
"func",
"HgetString",
"(",
"key",
"string",
",",
"field",
"int",
")",
"string",
"{",
"c",
",",
"err",
":=",
"redis",
".",
"Dial",
"(",
"\"",
"\"",
",",
"GetRedisServer",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")"... | // HgetString performs the hget command to return string. | [
"HgetString",
"performs",
"the",
"hget",
"command",
"to",
"return",
"string",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/redisutil/util.go#L44-L57 |
153,813 | ArchCI/archci | redisutil/util.go | HgetBool | func HgetBool(key string, field string) bool {
c, err := redis.Dial("tcp", GetRedisServer())
if err != nil {
panic(err)
}
defer c.Close()
value, err := redis.Bool(c.Do("HGET", key, field))
if err != nil {
fmt.Println("key not found")
}
return value
} | go | func HgetBool(key string, field string) bool {
c, err := redis.Dial("tcp", GetRedisServer())
if err != nil {
panic(err)
}
defer c.Close()
value, err := redis.Bool(c.Do("HGET", key, field))
if err != nil {
fmt.Println("key not found")
}
return value
} | [
"func",
"HgetBool",
"(",
"key",
"string",
",",
"field",
"string",
")",
"bool",
"{",
"c",
",",
"err",
":=",
"redis",
".",
"Dial",
"(",
"\"",
"\"",
",",
"GetRedisServer",
"(",
")",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"err",
")",... | // HgetBool performs hget command to return boolean. | [
"HgetBool",
"performs",
"hget",
"command",
"to",
"return",
"boolean",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/redisutil/util.go#L76-L89 |
153,814 | notnil/chessimg | chessimg.go | SVG | func SVG(w io.Writer, b *chess.Board, opts ...func(*encoder)) error {
e := new(w, opts)
return e.EncodeSVG(b)
} | go | func SVG(w io.Writer, b *chess.Board, opts ...func(*encoder)) error {
e := new(w, opts)
return e.EncodeSVG(b)
} | [
"func",
"SVG",
"(",
"w",
"io",
".",
"Writer",
",",
"b",
"*",
"chess",
".",
"Board",
",",
"opts",
"...",
"func",
"(",
"*",
"encoder",
")",
")",
"error",
"{",
"e",
":=",
"new",
"(",
"w",
",",
"opts",
")",
"\n",
"return",
"e",
".",
"EncodeSVG",
... | // SVG writes the board SVG representation into the writer.
// An error is returned if there is there is an error writing data.
// SVG also takes options which can customize the image output. | [
"SVG",
"writes",
"the",
"board",
"SVG",
"representation",
"into",
"the",
"writer",
".",
"An",
"error",
"is",
"returned",
"if",
"there",
"is",
"there",
"is",
"an",
"error",
"writing",
"data",
".",
"SVG",
"also",
"takes",
"options",
"which",
"can",
"customiz... | a9086548a15a9d16aec524d9d19458741a782ac3 | https://github.com/notnil/chessimg/blob/a9086548a15a9d16aec524d9d19458741a782ac3/chessimg.go#L18-L21 |
153,815 | notnil/chessimg | chessimg.go | SquareColors | func SquareColors(light, dark color.Color) func(*encoder) {
return func(e *encoder) {
e.light = light
e.dark = dark
}
} | go | func SquareColors(light, dark color.Color) func(*encoder) {
return func(e *encoder) {
e.light = light
e.dark = dark
}
} | [
"func",
"SquareColors",
"(",
"light",
",",
"dark",
"color",
".",
"Color",
")",
"func",
"(",
"*",
"encoder",
")",
"{",
"return",
"func",
"(",
"e",
"*",
"encoder",
")",
"{",
"e",
".",
"light",
"=",
"light",
"\n",
"e",
".",
"dark",
"=",
"dark",
"\n"... | // SquareColors is designed to be used as an optional argument
// to the SVG function. It changes the default light and
// dark square colors to the colors given. | [
"SquareColors",
"is",
"designed",
"to",
"be",
"used",
"as",
"an",
"optional",
"argument",
"to",
"the",
"SVG",
"function",
".",
"It",
"changes",
"the",
"default",
"light",
"and",
"dark",
"square",
"colors",
"to",
"the",
"colors",
"given",
"."
] | a9086548a15a9d16aec524d9d19458741a782ac3 | https://github.com/notnil/chessimg/blob/a9086548a15a9d16aec524d9d19458741a782ac3/chessimg.go#L26-L31 |
153,816 | notnil/chessimg | chessimg.go | MarkSquares | func MarkSquares(c color.Color, sqs ...chess.Square) func(*encoder) {
return func(e *encoder) {
for _, sq := range sqs {
e.marks[sq] = c
}
}
} | go | func MarkSquares(c color.Color, sqs ...chess.Square) func(*encoder) {
return func(e *encoder) {
for _, sq := range sqs {
e.marks[sq] = c
}
}
} | [
"func",
"MarkSquares",
"(",
"c",
"color",
".",
"Color",
",",
"sqs",
"...",
"chess",
".",
"Square",
")",
"func",
"(",
"*",
"encoder",
")",
"{",
"return",
"func",
"(",
"e",
"*",
"encoder",
")",
"{",
"for",
"_",
",",
"sq",
":=",
"range",
"sqs",
"{",... | // MarkSquares is designed to be used as an optional argument
// to the SVG function. It marks the given squares with the
// color. A possible usage includes marking squares of the
// previous move. | [
"MarkSquares",
"is",
"designed",
"to",
"be",
"used",
"as",
"an",
"optional",
"argument",
"to",
"the",
"SVG",
"function",
".",
"It",
"marks",
"the",
"given",
"squares",
"with",
"the",
"color",
".",
"A",
"possible",
"usage",
"includes",
"marking",
"squares",
... | a9086548a15a9d16aec524d9d19458741a782ac3 | https://github.com/notnil/chessimg/blob/a9086548a15a9d16aec524d9d19458741a782ac3/chessimg.go#L37-L43 |
153,817 | notnil/chessimg | chessimg.go | new | func new(w io.Writer, options []func(*encoder)) *encoder {
e := &encoder{
w: w,
light: color.RGBA{235, 209, 166, 1},
dark: color.RGBA{165, 117, 81, 1},
marks: map[chess.Square]color.Color{},
}
for _, op := range options {
op(e)
}
return e
} | go | func new(w io.Writer, options []func(*encoder)) *encoder {
e := &encoder{
w: w,
light: color.RGBA{235, 209, 166, 1},
dark: color.RGBA{165, 117, 81, 1},
marks: map[chess.Square]color.Color{},
}
for _, op := range options {
op(e)
}
return e
} | [
"func",
"new",
"(",
"w",
"io",
".",
"Writer",
",",
"options",
"[",
"]",
"func",
"(",
"*",
"encoder",
")",
")",
"*",
"encoder",
"{",
"e",
":=",
"&",
"encoder",
"{",
"w",
":",
"w",
",",
"light",
":",
"color",
".",
"RGBA",
"{",
"235",
",",
"209"... | // New returns an encoder that writes to the given writer.
// New also takes options which can customize the image
// output. | [
"New",
"returns",
"an",
"encoder",
"that",
"writes",
"to",
"the",
"given",
"writer",
".",
"New",
"also",
"takes",
"options",
"which",
"can",
"customize",
"the",
"image",
"output",
"."
] | a9086548a15a9d16aec524d9d19458741a782ac3 | https://github.com/notnil/chessimg/blob/a9086548a15a9d16aec524d9d19458741a782ac3/chessimg.go#L56-L67 |
153,818 | notnil/chessimg | chessimg.go | EncodeSVG | func (e *encoder) EncodeSVG(b *chess.Board) error {
boardMap := b.SquareMap()
canvas := svg.New(e.w)
canvas.Start(boardWidth, boardHeight)
canvas.Rect(0, 0, boardWidth, boardHeight)
for i := 0; i < 64; i++ {
sq := chess.Square(i)
x, y := xyForSquare(sq)
// draw square
c := e.colorForSquare(sq)
canvas.Rect(x, y, sqWidth, sqHeight, "fill: "+colorToHex(c))
markColor, ok := e.marks[sq]
if ok {
canvas.Rect(x, y, sqWidth, sqHeight, "fill-opacity:0.2;fill: "+colorToHex(markColor))
}
// draw piece
p := boardMap[sq]
if p != chess.NoPiece {
xml := pieceXML(x, y, p)
if _, err := io.WriteString(canvas.Writer, xml); err != nil {
return err
}
}
// draw rank text on file A
txtColor := e.colorForText(sq)
if sq.File() == chess.FileA {
style := "font-size:11px;fill: " + colorToHex(txtColor)
canvas.Text(x+(sqWidth*1/20), y+(sqHeight*5/20), sq.Rank().String(), style)
}
// draw file text on rank 1
if sq.Rank() == chess.Rank1 {
style := "text-anchor:end;font-size:11px;fill: " + colorToHex(txtColor)
canvas.Text(x+(sqWidth*19/20), y+sqHeight-(sqHeight*1/15), sq.File().String(), style)
}
}
canvas.End()
return nil
} | go | func (e *encoder) EncodeSVG(b *chess.Board) error {
boardMap := b.SquareMap()
canvas := svg.New(e.w)
canvas.Start(boardWidth, boardHeight)
canvas.Rect(0, 0, boardWidth, boardHeight)
for i := 0; i < 64; i++ {
sq := chess.Square(i)
x, y := xyForSquare(sq)
// draw square
c := e.colorForSquare(sq)
canvas.Rect(x, y, sqWidth, sqHeight, "fill: "+colorToHex(c))
markColor, ok := e.marks[sq]
if ok {
canvas.Rect(x, y, sqWidth, sqHeight, "fill-opacity:0.2;fill: "+colorToHex(markColor))
}
// draw piece
p := boardMap[sq]
if p != chess.NoPiece {
xml := pieceXML(x, y, p)
if _, err := io.WriteString(canvas.Writer, xml); err != nil {
return err
}
}
// draw rank text on file A
txtColor := e.colorForText(sq)
if sq.File() == chess.FileA {
style := "font-size:11px;fill: " + colorToHex(txtColor)
canvas.Text(x+(sqWidth*1/20), y+(sqHeight*5/20), sq.Rank().String(), style)
}
// draw file text on rank 1
if sq.Rank() == chess.Rank1 {
style := "text-anchor:end;font-size:11px;fill: " + colorToHex(txtColor)
canvas.Text(x+(sqWidth*19/20), y+sqHeight-(sqHeight*1/15), sq.File().String(), style)
}
}
canvas.End()
return nil
} | [
"func",
"(",
"e",
"*",
"encoder",
")",
"EncodeSVG",
"(",
"b",
"*",
"chess",
".",
"Board",
")",
"error",
"{",
"boardMap",
":=",
"b",
".",
"SquareMap",
"(",
")",
"\n",
"canvas",
":=",
"svg",
".",
"New",
"(",
"e",
".",
"w",
")",
"\n",
"canvas",
".... | // EncodeSVG writes the board SVG representation into
// the Encoder's writer. An error is returned if there
// is there is an error writing data. | [
"EncodeSVG",
"writes",
"the",
"board",
"SVG",
"representation",
"into",
"the",
"Encoder",
"s",
"writer",
".",
"An",
"error",
"is",
"returned",
"if",
"there",
"is",
"there",
"is",
"an",
"error",
"writing",
"data",
"."
] | a9086548a15a9d16aec524d9d19458741a782ac3 | https://github.com/notnil/chessimg/blob/a9086548a15a9d16aec524d9d19458741a782ac3/chessimg.go#L84-L122 |
153,819 | ArchCI/archci | main.go | init | func init() {
// Registry archci database models.
models.RegisterModels()
// Initialize database with environment variables.
server := ""
username := "root"
password := "root"
database := "mysql"
if os.Getenv(ENV_MYSQL_SERVER) != "" {
server = os.Getenv(ENV_MYSQL_SERVER)
}
if os.Getenv(ENV_MYSQL_USERNAME) != "" {
username = os.Getenv(ENV_MYSQL_USERNAME)
}
if os.Getenv(ENV_MYSQL_PASSWORD) != "" {
password = os.Getenv(ENV_MYSQL_PASSWORD)
}
if os.Getenv(ENV_MYSQL_DATABASE) != "" {
database = os.Getenv(ENV_MYSQL_DATABASE)
}
// The datasource looks like "root:root@/archci?charset=utf8".
DATASOURCE := username + ":" + password + "@" + server + "/" + database + "?charset=utf8"
fmt.Println("Connect to database with " + DATASOURCE)
orm.RegisterDriver(MYSQL_DRIVER, orm.DR_MySQL)
orm.RegisterDataBase("default", MYSQL_DRIVER, DATASOURCE, 30)
orm.RunSyncdb("default", false, true)
} | go | func init() {
// Registry archci database models.
models.RegisterModels()
// Initialize database with environment variables.
server := ""
username := "root"
password := "root"
database := "mysql"
if os.Getenv(ENV_MYSQL_SERVER) != "" {
server = os.Getenv(ENV_MYSQL_SERVER)
}
if os.Getenv(ENV_MYSQL_USERNAME) != "" {
username = os.Getenv(ENV_MYSQL_USERNAME)
}
if os.Getenv(ENV_MYSQL_PASSWORD) != "" {
password = os.Getenv(ENV_MYSQL_PASSWORD)
}
if os.Getenv(ENV_MYSQL_DATABASE) != "" {
database = os.Getenv(ENV_MYSQL_DATABASE)
}
// The datasource looks like "root:root@/archci?charset=utf8".
DATASOURCE := username + ":" + password + "@" + server + "/" + database + "?charset=utf8"
fmt.Println("Connect to database with " + DATASOURCE)
orm.RegisterDriver(MYSQL_DRIVER, orm.DR_MySQL)
orm.RegisterDataBase("default", MYSQL_DRIVER, DATASOURCE, 30)
orm.RunSyncdb("default", false, true)
} | [
"func",
"init",
"(",
")",
"{",
"// Registry archci database models.",
"models",
".",
"RegisterModels",
"(",
")",
"\n\n",
"// Initialize database with environment variables.",
"server",
":=",
"\"",
"\"",
"\n",
"username",
":=",
"\"",
"\"",
"\n",
"password",
":=",
"\"... | // Init will initialize database to create tables automatically. | [
"Init",
"will",
"initialize",
"database",
"to",
"create",
"tables",
"automatically",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/main.go#L30-L60 |
153,820 | davidminor/gorand | pcg/pcg32.go | NextN | func (pcg *Pcg64x32) NextN(bounds uint32) uint32 {
threshold := (0 - bounds) % bounds
for {
result := pcg.Next()
if result >= threshold {
return result % bounds;
}
}
} | go | func (pcg *Pcg64x32) NextN(bounds uint32) uint32 {
threshold := (0 - bounds) % bounds
for {
result := pcg.Next()
if result >= threshold {
return result % bounds;
}
}
} | [
"func",
"(",
"pcg",
"*",
"Pcg64x32",
")",
"NextN",
"(",
"bounds",
"uint32",
")",
"uint32",
"{",
"threshold",
":=",
"(",
"0",
"-",
"bounds",
")",
"%",
"bounds",
"\n",
"for",
"{",
"result",
":=",
"pcg",
".",
"Next",
"(",
")",
"\n",
"if",
"result",
... | // Get a random uint32 value evenly distributed in [0,bounds) | [
"Get",
"a",
"random",
"uint32",
"value",
"evenly",
"distributed",
"in",
"[",
"0",
"bounds",
")"
] | 283446f2caf531f8b71b3a766b6d5a4b198825f7 | https://github.com/davidminor/gorand/blob/283446f2caf531f8b71b3a766b6d5a4b198825f7/pcg/pcg32.go#L30-L38 |
153,821 | davidminor/gorand | pcg/pcg32.go | NewPcg32 | func NewPcg32(seed uint64) Pcg32 {
lcg := lcglib.NewLcg64(seed)
return Pcg32{NewPcg64x32(lcg, XshRr)}
} | go | func NewPcg32(seed uint64) Pcg32 {
lcg := lcglib.NewLcg64(seed)
return Pcg32{NewPcg64x32(lcg, XshRr)}
} | [
"func",
"NewPcg32",
"(",
"seed",
"uint64",
")",
"Pcg32",
"{",
"lcg",
":=",
"lcglib",
".",
"NewLcg64",
"(",
"seed",
")",
"\n",
"return",
"Pcg32",
"{",
"NewPcg64x32",
"(",
"lcg",
",",
"XshRr",
")",
"}",
"\n",
"}"
] | // Create a new Pcg32 with the given seed | [
"Create",
"a",
"new",
"Pcg32",
"with",
"the",
"given",
"seed"
] | 283446f2caf531f8b71b3a766b6d5a4b198825f7 | https://github.com/davidminor/gorand/blob/283446f2caf531f8b71b3a766b6d5a4b198825f7/pcg/pcg32.go#L54-L57 |
153,822 | davidminor/gorand | pcg/pcg32.go | NewPcg32Stream | func NewPcg32Stream(seed, stream uint64) Pcg32 {
lcg := lcglib.NewLcg64Stream(seed, stream)
return Pcg32{NewPcg64x32(lcg, XshRr)}
} | go | func NewPcg32Stream(seed, stream uint64) Pcg32 {
lcg := lcglib.NewLcg64Stream(seed, stream)
return Pcg32{NewPcg64x32(lcg, XshRr)}
} | [
"func",
"NewPcg32Stream",
"(",
"seed",
",",
"stream",
"uint64",
")",
"Pcg32",
"{",
"lcg",
":=",
"lcglib",
".",
"NewLcg64Stream",
"(",
"seed",
",",
"stream",
")",
"\n",
"return",
"Pcg32",
"{",
"NewPcg64x32",
"(",
"lcg",
",",
"XshRr",
")",
"}",
"\n",
"}"... | // Create a new Pcg32 with the given seed and stream | [
"Create",
"a",
"new",
"Pcg32",
"with",
"the",
"given",
"seed",
"and",
"stream"
] | 283446f2caf531f8b71b3a766b6d5a4b198825f7 | https://github.com/davidminor/gorand/blob/283446f2caf531f8b71b3a766b6d5a4b198825f7/pcg/pcg32.go#L60-L63 |
153,823 | ArchCI/archci | controllers/badge.go | GetProjectBadge | func (c *ApiController) GetProjectBadge() {
log.Info("Get project badge")
// TODO(tobe): need more svg images.
success_svg := []byte(`<svg xmlns="http://www.w3.org/2000/svg" width="104" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="104" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h54v20H0z"/><path fill="#4c1" d="M54 0h50v20H54z"/><path fill="url(#b)" d="M0 0h104v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="28" y="15" fill="#010101" fill-opacity=".3">solution</text><text x="28" y="14">solution</text><text x="78" y="15" fill="#010101" fill-opacity=".3">correct</text><text x="78" y="14">correct</text></g></svg>`)
fail_svg := []byte(`<svg xmlns="http://www.w3.org/2000/svg" width="99" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="99" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h54v20H0z"/><path fill="#e05d44" d="M54 0h45v20H54z"/><path fill="url(#b)" d="M0 0h99v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="28" y="15" fill="#010101" fill-opacity=".3">solution</text><text x="28" y="14">solution</text><text x="75.5" y="15" fill="#010101" fill-opacity=".3">wrong</text><text x="75.5" y="14">wrong</text></g></svg>`)
var badge []byte
projectId, _ := c.GetInt64(":projectId")
project := models.GetProjectWithId(projectId)
if project.Status == models.PROJECT_STATUS_NEED_TEST {
badge = success_svg
} else if project.Status == models.PROJECT_STATUS_TESTING {
badge = success_svg
} else if project.Status == models.PROJECT_STATUS_SUCCESS {
badge = success_svg
} else {
badge = fail_svg
}
header := c.Ctx.ResponseWriter.Header()
header.Set("Content-Type", "image/svg+xml")
header.Set("Cache-Control", "no-cache, no-store, must-revalidate")
c.Ctx.ResponseWriter.Write(badge)
} | go | func (c *ApiController) GetProjectBadge() {
log.Info("Get project badge")
// TODO(tobe): need more svg images.
success_svg := []byte(`<svg xmlns="http://www.w3.org/2000/svg" width="104" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="104" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h54v20H0z"/><path fill="#4c1" d="M54 0h50v20H54z"/><path fill="url(#b)" d="M0 0h104v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="28" y="15" fill="#010101" fill-opacity=".3">solution</text><text x="28" y="14">solution</text><text x="78" y="15" fill="#010101" fill-opacity=".3">correct</text><text x="78" y="14">correct</text></g></svg>`)
fail_svg := []byte(`<svg xmlns="http://www.w3.org/2000/svg" width="99" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><mask id="a"><rect width="99" height="20" rx="3" fill="#fff"/></mask><g mask="url(#a)"><path fill="#555" d="M0 0h54v20H0z"/><path fill="#e05d44" d="M54 0h45v20H54z"/><path fill="url(#b)" d="M0 0h99v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"><text x="28" y="15" fill="#010101" fill-opacity=".3">solution</text><text x="28" y="14">solution</text><text x="75.5" y="15" fill="#010101" fill-opacity=".3">wrong</text><text x="75.5" y="14">wrong</text></g></svg>`)
var badge []byte
projectId, _ := c.GetInt64(":projectId")
project := models.GetProjectWithId(projectId)
if project.Status == models.PROJECT_STATUS_NEED_TEST {
badge = success_svg
} else if project.Status == models.PROJECT_STATUS_TESTING {
badge = success_svg
} else if project.Status == models.PROJECT_STATUS_SUCCESS {
badge = success_svg
} else {
badge = fail_svg
}
header := c.Ctx.ResponseWriter.Header()
header.Set("Content-Type", "image/svg+xml")
header.Set("Cache-Control", "no-cache, no-store, must-revalidate")
c.Ctx.ResponseWriter.Write(badge)
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetProjectBadge",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"// TODO(tobe): need more svg images.",
"success_svg",
":=",
"[",
"]",
"byte",
"(",
"`<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"1... | // GetProjectBadge takes project id and return the badge image of its status. | [
"GetProjectBadge",
"takes",
"project",
"id",
"and",
"return",
"the",
"badge",
"image",
"of",
"its",
"status",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/badge.go#L10-L37 |
153,824 | ArchCI/archci | controllers/badge.go | GetProjectBadgeUrl | func (c *ApiController) GetProjectBadgeUrl() {
log.Debug("Get project badge url")
// TODO(tobe): use the address of server instead of 127.0.0.1
// The link should look like "http://127.0.0.1:10010/v1/badge/1)"
projectId, _ := c.GetInt64(":projectId")
link := fmt.Sprintf("http://127.0.0.1:10010/v1/badge/%d", projectId)
c.Ctx.WriteString(link)
} | go | func (c *ApiController) GetProjectBadgeUrl() {
log.Debug("Get project badge url")
// TODO(tobe): use the address of server instead of 127.0.0.1
// The link should look like "http://127.0.0.1:10010/v1/badge/1)"
projectId, _ := c.GetInt64(":projectId")
link := fmt.Sprintf("http://127.0.0.1:10010/v1/badge/%d", projectId)
c.Ctx.WriteString(link)
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetProjectBadgeUrl",
"(",
")",
"{",
"log",
".",
"Debug",
"(",
"\"",
"\"",
")",
"\n\n",
"// TODO(tobe): use the address of server instead of 127.0.0.1",
"// The link should look like \"http://127.0.0.1:10010/v1/badge/1)\"",
"projec... | // GetProjectBadgeUrl returns the url of the status badge. | [
"GetProjectBadgeUrl",
"returns",
"the",
"url",
"of",
"the",
"status",
"badge",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/badge.go#L40-L49 |
153,825 | ArchCI/archci | controllers/builds.go | NewBuild | func (c *ApiController) NewBuild() {
log.Info("New build record")
project := models.Project{}
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &project); err != nil {
c.Ctx.Output.SetStatus(400)
c.Ctx.Output.Body([]byte("empty title"))
fmt.Println(err)
return
}
models.AddBuildWithProject(project)
} | go | func (c *ApiController) NewBuild() {
log.Info("New build record")
project := models.Project{}
if err := json.Unmarshal(c.Ctx.Input.RequestBody, &project); err != nil {
c.Ctx.Output.SetStatus(400)
c.Ctx.Output.Body([]byte("empty title"))
fmt.Println(err)
return
}
models.AddBuildWithProject(project)
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"NewBuild",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"project",
":=",
"models",
".",
"Project",
"{",
"}",
"\n\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"c",
".",
"Ct... | // Newbuild processes POST data to build record and add it in database. | [
"Newbuild",
"processes",
"POST",
"data",
"to",
"build",
"record",
"and",
"add",
"it",
"in",
"database",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/builds.go#L20-L33 |
153,826 | ArchCI/archci | controllers/builds.go | GetBuildsAll | func (c *ApiController) GetBuildsAll() {
log.Info("Get all builds")
builds := models.GetAllBuilds()
c.Data["json"] = builds
c.ServeJson()
} | go | func (c *ApiController) GetBuildsAll() {
log.Info("Get all builds")
builds := models.GetAllBuilds()
c.Data["json"] = builds
c.ServeJson()
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetBuildsAll",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"builds",
":=",
"models",
".",
"GetAllBuilds",
"(",
")",
"\n\n",
"c",
".",
"Data",
"[",
"\"",
"\"",
"]",
"=",
"builds",
... | // GetBuildsAll read all builds from database. | [
"GetBuildsAll",
"read",
"all",
"builds",
"from",
"database",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/builds.go#L36-L43 |
153,827 | ArchCI/archci | controllers/builds.go | GetBuildsWithProjectName | func (c *ApiController) GetBuildsWithProjectName() {
log.Info("Get builds with project name")
projectName := c.GetString(":projectName")
builds := models.GetBuildsWithProjectName(projectName)
c.Data["json"] = builds
c.ServeJson()
} | go | func (c *ApiController) GetBuildsWithProjectName() {
log.Info("Get builds with project name")
projectName := c.GetString(":projectName")
builds := models.GetBuildsWithProjectName(projectName)
c.Data["json"] = builds
c.ServeJson()
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetBuildsWithProjectName",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"projectName",
":=",
"c",
".",
"GetString",
"(",
"\"",
"\"",
")",
"\n\n",
"builds",
":=",
"models",
".",
"GetBuild... | // GetBuildsWithProjectName gets project name in url and return the project object. | [
"GetBuildsWithProjectName",
"gets",
"project",
"name",
"in",
"url",
"and",
"return",
"the",
"project",
"object",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/builds.go#L46-L55 |
153,828 | ArchCI/archci | controllers/builds.go | GetBuild | func (c *ApiController) GetBuild() {
log.Info("Get build")
buildId, _ := c.GetInt64(":buildId")
build := models.GetBuildWithId(buildId)
c.Data["json"] = build
c.ServeJson()
} | go | func (c *ApiController) GetBuild() {
log.Info("Get build")
buildId, _ := c.GetInt64(":buildId")
build := models.GetBuildWithId(buildId)
c.Data["json"] = build
c.ServeJson()
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetBuild",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"buildId",
",",
"_",
":=",
"c",
".",
"GetInt64",
"(",
"\"",
"\"",
")",
"\n\n",
"build",
":=",
"models",
".",
"GetBuildWithId",... | // GetBuild gets the build id and return the build object. | [
"GetBuild",
"gets",
"the",
"build",
"id",
"and",
"return",
"the",
"build",
"object",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/builds.go#L58-L67 |
153,829 | ArchCI/archci | controllers/builds.go | GetActiveBuilds | func (c *ApiController) GetActiveBuilds() {
// TODO(tobe): this is not implemented because nobody uses it yet.
log.Info("Get active builds")
result := "Not implemented"
c.Ctx.WriteString(result)
} | go | func (c *ApiController) GetActiveBuilds() {
// TODO(tobe): this is not implemented because nobody uses it yet.
log.Info("Get active builds")
result := "Not implemented"
c.Ctx.WriteString(result)
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetActiveBuilds",
"(",
")",
"{",
"// TODO(tobe): this is not implemented because nobody uses it yet.",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"result",
":=",
"\"",
"\"",
"\n",
"c",
".",
"Ctx",
".",
"Writ... | // GetActiveBuilds get build data from database. | [
"GetActiveBuilds",
"get",
"build",
"data",
"from",
"database",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/builds.go#L70-L76 |
153,830 | ArchCI/archci | controllers/builds.go | GetSearchBuilds | func (c *ApiController) GetSearchBuilds() {
log.Info("Get search builds")
result := "Not implemented"
c.Ctx.WriteString(result)
} | go | func (c *ApiController) GetSearchBuilds() {
log.Info("Get search builds")
result := "Not implemented"
c.Ctx.WriteString(result)
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetSearchBuilds",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"result",
":=",
"\"",
"\"",
"\n",
"c",
".",
"Ctx",
".",
"WriteString",
"(",
"result",
")",
"\n",
"}"
] | // GetSearchBuilds get search string and return related builds. | [
"GetSearchBuilds",
"get",
"search",
"string",
"and",
"return",
"related",
"builds",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/builds.go#L79-L84 |
153,831 | ArchCI/archci | controllers/builds.go | GetBuildLogsIndex | func (c *ApiController) GetBuildLogsIndex() {
log.Info("Get build log with index")
buildId := c.GetString(":buildId")
index, _ := c.GetInt(":index")
log := redisutil.HgetString(buildId, index)
next := false
finish := redisutil.HgetBool(buildId, "finish")
if finish == false {
next = true
fmt.Println("finish == false")
}
current := redisutil.HgetInt(buildId, "current")
if index < current {
next = true
fmt.Println("index != current")
}
// TODO(tobe): throw error if index is larger than current
// TODO(tobe): handle when get the index is more than current but it's not total
response := &GetBuildLogsIndexResponse{
Log: log,
Next: next}
c.Data["json"] = response
c.ServeJson()
} | go | func (c *ApiController) GetBuildLogsIndex() {
log.Info("Get build log with index")
buildId := c.GetString(":buildId")
index, _ := c.GetInt(":index")
log := redisutil.HgetString(buildId, index)
next := false
finish := redisutil.HgetBool(buildId, "finish")
if finish == false {
next = true
fmt.Println("finish == false")
}
current := redisutil.HgetInt(buildId, "current")
if index < current {
next = true
fmt.Println("index != current")
}
// TODO(tobe): throw error if index is larger than current
// TODO(tobe): handle when get the index is more than current but it's not total
response := &GetBuildLogsIndexResponse{
Log: log,
Next: next}
c.Data["json"] = response
c.ServeJson()
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetBuildLogsIndex",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"buildId",
":=",
"c",
".",
"GetString",
"(",
"\"",
"\"",
")",
"\n",
"index",
",",
"_",
":=",
"c",
".",
"GetInt",
"(... | // GetBuildLogsIndex return the single build log with the index. | [
"GetBuildLogsIndex",
"return",
"the",
"single",
"build",
"log",
"with",
"the",
"index",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/builds.go#L87-L119 |
153,832 | ArchCI/archci | controllers/builds.go | GetBuildLogsAll | func (c *ApiController) GetBuildLogsAll() {
log.Info("Get all build logs")
//buildId := c.GetString(":buildId")
//field := 0
//result := redisutil.HgetString(buildId, field)
//c.Ctx.WriteString(result)
// TODO(tobe): change to hgetall from redis
mystruct := `{0: "apt-get install", 1: "go test"}`
c.Data["json"] = &mystruct
c.ServeJson()
} | go | func (c *ApiController) GetBuildLogsAll() {
log.Info("Get all build logs")
//buildId := c.GetString(":buildId")
//field := 0
//result := redisutil.HgetString(buildId, field)
//c.Ctx.WriteString(result)
// TODO(tobe): change to hgetall from redis
mystruct := `{0: "apt-get install", 1: "go test"}`
c.Data["json"] = &mystruct
c.ServeJson()
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetBuildLogsAll",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"//buildId := c.GetString(\":buildId\")",
"//field := 0",
"//result := redisutil.HgetString(buildId, field)",
"//c.Ctx.WriteString(result)",
"/... | // GetBuildLogsAll return all logs of the build. | [
"GetBuildLogsAll",
"return",
"all",
"logs",
"of",
"the",
"build",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/builds.go#L122-L135 |
153,833 | ArchCI/archci | controllers/api.go | GetAccountInfo | func (c *ApiController) GetAccountInfo() {
fmt.Println("Start get account info")
//user := GithubOauthUser{Name:"tobe", HTMLURL: "https://github.com/tobegit3hub", Company: "UnitedStack Inc"}
client := github.NewClient(oauthCfg.Client(oauth2.NoContext, tkn))
user, _, err := client.Users.Get("")
if err != nil {
fmt.Println("error getting name")
//return
}
/*
{
"login": "tobegit3hub",
"id": 2715000,
"avatar_url": "https://avatars.githubusercontent.com/u/2715000?v=3",
"html_url": "https://github.com/tobegit3hub",
"gravatar_id": "",
"name": "tobe",
"company": "UnitedStack Inc",
"blog": "http://chendihao.cn",
"location": "Beijing",
"email": "tobeg3oogle@gmail.com",
"hireable": false,
"public_repos": 161,
"public_gists": 1,
"followers": 155,
"following": 68,
"created_at": "2012-11-03T13:17:18Z",
"updated_at": "2015-08-04T19:01:39Z",
"type": "User",
"site_admin": false,
"url": "https://api.github.com/users/tobegit3hub",
"events_url": "https://api.github.com/users/tobegit3hub/events{/privacy}",
"following_url": "https://api.github.com/users/tobegit3hub/following{/other_user}",
"followers_url": "https://api.github.com/users/tobegit3hub/followers",
"gists_url": "https://api.github.com/users/tobegit3hub/gists{/gist_id}",
"organizations_url": "https://api.github.com/users/tobegit3hub/orgs",
"received_events_url": "https://api.github.com/users/tobegit3hub/received_events",
"repos_url": "https://api.github.com/users/tobegit3hub/repos",
"starred_url": "https://api.github.com/users/tobegit3hub/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/tobegit3hub/subscriptions"
}
*/
c.Data["json"] = user
c.ServeJson()
} | go | func (c *ApiController) GetAccountInfo() {
fmt.Println("Start get account info")
//user := GithubOauthUser{Name:"tobe", HTMLURL: "https://github.com/tobegit3hub", Company: "UnitedStack Inc"}
client := github.NewClient(oauthCfg.Client(oauth2.NoContext, tkn))
user, _, err := client.Users.Get("")
if err != nil {
fmt.Println("error getting name")
//return
}
/*
{
"login": "tobegit3hub",
"id": 2715000,
"avatar_url": "https://avatars.githubusercontent.com/u/2715000?v=3",
"html_url": "https://github.com/tobegit3hub",
"gravatar_id": "",
"name": "tobe",
"company": "UnitedStack Inc",
"blog": "http://chendihao.cn",
"location": "Beijing",
"email": "tobeg3oogle@gmail.com",
"hireable": false,
"public_repos": 161,
"public_gists": 1,
"followers": 155,
"following": 68,
"created_at": "2012-11-03T13:17:18Z",
"updated_at": "2015-08-04T19:01:39Z",
"type": "User",
"site_admin": false,
"url": "https://api.github.com/users/tobegit3hub",
"events_url": "https://api.github.com/users/tobegit3hub/events{/privacy}",
"following_url": "https://api.github.com/users/tobegit3hub/following{/other_user}",
"followers_url": "https://api.github.com/users/tobegit3hub/followers",
"gists_url": "https://api.github.com/users/tobegit3hub/gists{/gist_id}",
"organizations_url": "https://api.github.com/users/tobegit3hub/orgs",
"received_events_url": "https://api.github.com/users/tobegit3hub/received_events",
"repos_url": "https://api.github.com/users/tobegit3hub/repos",
"starred_url": "https://api.github.com/users/tobegit3hub/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/tobegit3hub/subscriptions"
}
*/
c.Data["json"] = user
c.ServeJson()
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetAccountInfo",
"(",
")",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n\n",
"//user := GithubOauthUser{Name:\"tobe\", HTMLURL: \"https://github.com/tobegit3hub\", Company: \"UnitedStack Inc\"}",
"client",
":=",
"github"... | // GetAccountInfo return the info of github user. | [
"GetAccountInfo",
"return",
"the",
"info",
"of",
"github",
"user",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/api.go#L242-L292 |
153,834 | ArchCI/archci | controllers/api.go | GetAccountOrganizations | func (c *ApiController) GetAccountOrganizations() {
fmt.Println("Start get account organizations")
client := github.NewClient(oauthCfg.Client(oauth2.NoContext, tkn))
organizations, _, err := client.Organizations.List("", nil)
if err != nil {
fmt.Println("error getting organizations")
fmt.Println(nil)
}
c.Data["json"] = organizations
c.ServeJson()
} | go | func (c *ApiController) GetAccountOrganizations() {
fmt.Println("Start get account organizations")
client := github.NewClient(oauthCfg.Client(oauth2.NoContext, tkn))
organizations, _, err := client.Organizations.List("", nil)
if err != nil {
fmt.Println("error getting organizations")
fmt.Println(nil)
}
c.Data["json"] = organizations
c.ServeJson()
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetAccountOrganizations",
"(",
")",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n\n",
"client",
":=",
"github",
".",
"NewClient",
"(",
"oauthCfg",
".",
"Client",
"(",
"oauth2",
".",
"NoContext",
",",
... | // GetAccountOrganizations return the organizations of github user. | [
"GetAccountOrganizations",
"return",
"the",
"organizations",
"of",
"github",
"user",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/api.go#L295-L308 |
153,835 | ArchCI/archci | controllers/api.go | GetAccountProjects | func (c *ApiController) GetAccountProjects() {
//projects := GithubOauthRepositories{{FullName:"ArchCI/archci", HTMLURL:"https://github.com/ArchCI/archci", Language: "Go", Description: "The best CI system"}, {FullName:"ArchCI/simple-worker", Homepage:"https://github.com/ArchCI/simple-worker", Language:"Go", Description: "The client of ArchCI"}}
/*
r := c.Ctx.Request
w := c.Ctx.ResponseWriter
token := tkn
sess, _ := globalSessions.SessionStart(w, r)
defer sess.SessionRelease(w)
if sess.Get("token") == nil {
token = sess.Get("token").(*oauth2.Token)
fmt.Println("hit token")
}
*/
client := github.NewClient(oauthCfg.Client(oauth2.NoContext, tkn))
projects, _, err := client.Repositories.List("", nil)
if err != nil {
fmt.Println("error getting repos")
//return
}
/*
[
{
"id": 36988569,
"owner": {
"login": "ArchCI",
"id": 12673804,
"avatar_url": "https://avatars.githubusercontent.com/u/12673804?v=3",
"html_url": "https://github.com/ArchCI",
"gravatar_id": "",
"type": "Organization",
"site_admin": false,
"url": "https://api.github.com/users/ArchCI",
"events_url": "https://api.github.com/users/ArchCI/events{/privacy}",
"following_url": "https://api.github.com/users/ArchCI/following{/other_user}",
"followers_url": "https://api.github.com/users/ArchCI/followers",
"gists_url": "https://api.github.com/users/ArchCI/gists{/gist_id}",
"organizations_url": "https://api.github.com/users/ArchCI/orgs",
"received_events_url": "https://api.github.com/users/ArchCI/received_events",
"repos_url": "https://api.github.com/users/ArchCI/repos",
"starred_url": "https://api.github.com/users/ArchCI/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ArchCI/subscriptions"
},
"name": "aci",
"full_name": "ArchCI/aci",
"description": "Command-line client for ArchCI",
"homepage": "http://archci.com",
"default_branch": "master",
"created_at": "2015-06-06T17:21:16Z",
"pushed_at": "2015-06-14T01:00:11Z",
"updated_at": "2015-06-28T13:58:55Z",
"html_url": "https://github.com/ArchCI/aci",
"clone_url": "https://github.com/ArchCI/aci.git",
"git_url": "git://github.com/ArchCI/aci.git",
"ssh_url": "git@github.com:ArchCI/aci.git",
"svn_url": "https://github.com/ArchCI/aci",
"language": "Go",
"fork": false,
"forks_count": 0,
"open_issues_count": 0,
"stargazers_count": 1,
"watchers_count": 1,
"size": 168,
"permissions": {
"admin": true,
"pull": true,
"push": true
},
"private": false,
"has_issues": true,
"has_wiki": true,
"has_downloads": true,
"team_id": null,
"url": "https://api.github.com/repos/ArchCI/aci",
"archive_url": "https://api.github.com/repos/ArchCI/aci/{archive_format}{/ref}",
"assignees_url": "https://api.github.com/repos/ArchCI/aci/assignees{/user}",
"blobs_url": "https://api.github.com/repos/ArchCI/aci/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/ArchCI/aci/branches{/branch}",
"collaborators_url": "https://api.github.com/repos/ArchCI/aci/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/ArchCI/aci/comments{/number}",
"commits_url": "https://api.github.com/repos/ArchCI/aci/commits{/sha}",
"compare_url": "https://api.github.com/repos/ArchCI/aci/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/ArchCI/aci/contents/{+path}",
"contributors_url": "https://api.github.com/repos/ArchCI/aci/contributors",
"downloads_url": "https://api.github.com/repos/ArchCI/aci/downloads",
"events_url": "https://api.github.com/repos/ArchCI/aci/events",
"forks_url": "https://api.github.com/repos/ArchCI/aci/forks",
"git_commits_url": "https://api.github.com/repos/ArchCI/aci/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/ArchCI/aci/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/ArchCI/aci/git/tags{/sha}",
"hooks_url": "https://api.github.com/repos/ArchCI/aci/hooks",
"issue_comment_url": "https://api.github.com/repos/ArchCI/aci/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/ArchCI/aci/issues/events{/number}",
"issues_url": "https://api.github.com/repos/ArchCI/aci/issues{/number}",
"keys_url": "https://api.github.com/repos/ArchCI/aci/keys{/key_id}",
"labels_url": "https://api.github.com/repos/ArchCI/aci/labels{/name}",
"languages_url": "https://api.github.com/repos/ArchCI/aci/languages",
"merges_url": "https://api.github.com/repos/ArchCI/aci/merges",
"milestones_url": "https://api.github.com/repos/ArchCI/aci/milestones{/number}",
"notifications_url": "https://api.github.com/repos/ArchCI/aci/notifications{?since,all,participating}",
"pulls_url": "https://api.github.com/repos/ArchCI/aci/pulls{/number}",
"releases_url": "https://api.github.com/repos/ArchCI/aci/releases{/id}",
"stargazers_url": "https://api.github.com/repos/ArchCI/aci/stargazers",
"statuses_url": "https://api.github.com/repos/ArchCI/aci/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/ArchCI/aci/subscribers",
"subscription_url": "https://api.github.com/repos/ArchCI/aci/subscription",
"tags_url": "https://api.github.com/repos/ArchCI/aci/tags",
"trees_url": "https://api.github.com/repos/ArchCI/aci/git/trees{/sha}",
"teams_url": "https://api.github.com/repos/ArchCI/aci/teams"
}
]
*/
c.Data["json"] = projects
c.ServeJson()
} | go | func (c *ApiController) GetAccountProjects() {
//projects := GithubOauthRepositories{{FullName:"ArchCI/archci", HTMLURL:"https://github.com/ArchCI/archci", Language: "Go", Description: "The best CI system"}, {FullName:"ArchCI/simple-worker", Homepage:"https://github.com/ArchCI/simple-worker", Language:"Go", Description: "The client of ArchCI"}}
/*
r := c.Ctx.Request
w := c.Ctx.ResponseWriter
token := tkn
sess, _ := globalSessions.SessionStart(w, r)
defer sess.SessionRelease(w)
if sess.Get("token") == nil {
token = sess.Get("token").(*oauth2.Token)
fmt.Println("hit token")
}
*/
client := github.NewClient(oauthCfg.Client(oauth2.NoContext, tkn))
projects, _, err := client.Repositories.List("", nil)
if err != nil {
fmt.Println("error getting repos")
//return
}
/*
[
{
"id": 36988569,
"owner": {
"login": "ArchCI",
"id": 12673804,
"avatar_url": "https://avatars.githubusercontent.com/u/12673804?v=3",
"html_url": "https://github.com/ArchCI",
"gravatar_id": "",
"type": "Organization",
"site_admin": false,
"url": "https://api.github.com/users/ArchCI",
"events_url": "https://api.github.com/users/ArchCI/events{/privacy}",
"following_url": "https://api.github.com/users/ArchCI/following{/other_user}",
"followers_url": "https://api.github.com/users/ArchCI/followers",
"gists_url": "https://api.github.com/users/ArchCI/gists{/gist_id}",
"organizations_url": "https://api.github.com/users/ArchCI/orgs",
"received_events_url": "https://api.github.com/users/ArchCI/received_events",
"repos_url": "https://api.github.com/users/ArchCI/repos",
"starred_url": "https://api.github.com/users/ArchCI/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/ArchCI/subscriptions"
},
"name": "aci",
"full_name": "ArchCI/aci",
"description": "Command-line client for ArchCI",
"homepage": "http://archci.com",
"default_branch": "master",
"created_at": "2015-06-06T17:21:16Z",
"pushed_at": "2015-06-14T01:00:11Z",
"updated_at": "2015-06-28T13:58:55Z",
"html_url": "https://github.com/ArchCI/aci",
"clone_url": "https://github.com/ArchCI/aci.git",
"git_url": "git://github.com/ArchCI/aci.git",
"ssh_url": "git@github.com:ArchCI/aci.git",
"svn_url": "https://github.com/ArchCI/aci",
"language": "Go",
"fork": false,
"forks_count": 0,
"open_issues_count": 0,
"stargazers_count": 1,
"watchers_count": 1,
"size": 168,
"permissions": {
"admin": true,
"pull": true,
"push": true
},
"private": false,
"has_issues": true,
"has_wiki": true,
"has_downloads": true,
"team_id": null,
"url": "https://api.github.com/repos/ArchCI/aci",
"archive_url": "https://api.github.com/repos/ArchCI/aci/{archive_format}{/ref}",
"assignees_url": "https://api.github.com/repos/ArchCI/aci/assignees{/user}",
"blobs_url": "https://api.github.com/repos/ArchCI/aci/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/ArchCI/aci/branches{/branch}",
"collaborators_url": "https://api.github.com/repos/ArchCI/aci/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/ArchCI/aci/comments{/number}",
"commits_url": "https://api.github.com/repos/ArchCI/aci/commits{/sha}",
"compare_url": "https://api.github.com/repos/ArchCI/aci/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/ArchCI/aci/contents/{+path}",
"contributors_url": "https://api.github.com/repos/ArchCI/aci/contributors",
"downloads_url": "https://api.github.com/repos/ArchCI/aci/downloads",
"events_url": "https://api.github.com/repos/ArchCI/aci/events",
"forks_url": "https://api.github.com/repos/ArchCI/aci/forks",
"git_commits_url": "https://api.github.com/repos/ArchCI/aci/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/ArchCI/aci/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/ArchCI/aci/git/tags{/sha}",
"hooks_url": "https://api.github.com/repos/ArchCI/aci/hooks",
"issue_comment_url": "https://api.github.com/repos/ArchCI/aci/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/ArchCI/aci/issues/events{/number}",
"issues_url": "https://api.github.com/repos/ArchCI/aci/issues{/number}",
"keys_url": "https://api.github.com/repos/ArchCI/aci/keys{/key_id}",
"labels_url": "https://api.github.com/repos/ArchCI/aci/labels{/name}",
"languages_url": "https://api.github.com/repos/ArchCI/aci/languages",
"merges_url": "https://api.github.com/repos/ArchCI/aci/merges",
"milestones_url": "https://api.github.com/repos/ArchCI/aci/milestones{/number}",
"notifications_url": "https://api.github.com/repos/ArchCI/aci/notifications{?since,all,participating}",
"pulls_url": "https://api.github.com/repos/ArchCI/aci/pulls{/number}",
"releases_url": "https://api.github.com/repos/ArchCI/aci/releases{/id}",
"stargazers_url": "https://api.github.com/repos/ArchCI/aci/stargazers",
"statuses_url": "https://api.github.com/repos/ArchCI/aci/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/ArchCI/aci/subscribers",
"subscription_url": "https://api.github.com/repos/ArchCI/aci/subscription",
"tags_url": "https://api.github.com/repos/ArchCI/aci/tags",
"trees_url": "https://api.github.com/repos/ArchCI/aci/git/trees{/sha}",
"teams_url": "https://api.github.com/repos/ArchCI/aci/teams"
}
]
*/
c.Data["json"] = projects
c.ServeJson()
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetAccountProjects",
"(",
")",
"{",
"//projects := GithubOauthRepositories{{FullName:\"ArchCI/archci\", HTMLURL:\"https://github.com/ArchCI/archci\", Language: \"Go\", Description: \"The best CI system\"}, {FullName:\"ArchCI/simple-worker\", Homepage... | // GetAccountProjects returns the projects of github user. | [
"GetAccountProjects",
"returns",
"the",
"projects",
"of",
"github",
"user",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/api.go#L311-L436 |
153,836 | ArchCI/archci | controllers/api.go | GetAccountToken | func (c *ApiController) GetAccountToken() {
result := tkn.AccessToken
c.Ctx.WriteString(result)
} | go | func (c *ApiController) GetAccountToken() {
result := tkn.AccessToken
c.Ctx.WriteString(result)
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetAccountToken",
"(",
")",
"{",
"result",
":=",
"tkn",
".",
"AccessToken",
"\n",
"c",
".",
"Ctx",
".",
"WriteString",
"(",
"result",
")",
"\n",
"}"
] | // GetAccountToken returns github oauth token as string. | [
"GetAccountToken",
"returns",
"github",
"oauth",
"token",
"as",
"string",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/api.go#L439-L442 |
153,837 | ArchCI/archci | models/projects.go | GetAllProjects | func GetAllProjects() []*Project {
o := orm.NewOrm()
var projects []*Project
num, err := o.QueryTable("project").All(&projects)
fmt.Printf("Returned Rows Num: %s, %s", num, err)
return projects
} | go | func GetAllProjects() []*Project {
o := orm.NewOrm()
var projects []*Project
num, err := o.QueryTable("project").All(&projects)
fmt.Printf("Returned Rows Num: %s, %s", num, err)
return projects
} | [
"func",
"GetAllProjects",
"(",
")",
"[",
"]",
"*",
"Project",
"{",
"o",
":=",
"orm",
".",
"NewOrm",
"(",
")",
"\n\n",
"var",
"projects",
"[",
"]",
"*",
"Project",
"\n",
"num",
",",
"err",
":=",
"o",
".",
"QueryTable",
"(",
"\"",
"\"",
")",
".",
... | // GetAllProjects return all projects from database. | [
"GetAllProjects",
"return",
"all",
"projects",
"from",
"database",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/models/projects.go#L29-L36 |
153,838 | ArchCI/archci | models/projects.go | GetProjectWithId | func GetProjectWithId(projectId int64) Project {
o := orm.NewOrm()
project := Project{Id: projectId}
err := o.Read(&project)
fmt.Printf("ERR: %v\n", err)
return project
} | go | func GetProjectWithId(projectId int64) Project {
o := orm.NewOrm()
project := Project{Id: projectId}
err := o.Read(&project)
fmt.Printf("ERR: %v\n", err)
return project
} | [
"func",
"GetProjectWithId",
"(",
"projectId",
"int64",
")",
"Project",
"{",
"o",
":=",
"orm",
".",
"NewOrm",
"(",
")",
"\n\n",
"project",
":=",
"Project",
"{",
"Id",
":",
"projectId",
"}",
"\n",
"err",
":=",
"o",
".",
"Read",
"(",
"&",
"project",
")"... | // GetProjectWithId takes id to return the project. | [
"GetProjectWithId",
"takes",
"id",
"to",
"return",
"the",
"project",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/models/projects.go#L39-L46 |
153,839 | ArchCI/archci | models/projects.go | ReadOrCreateProject | func ReadOrCreateProject(userName string, projectName string, repoUrl string) (int64, error) {
o := orm.NewOrm()
project := Project{
UserName: userName,
ProjectName: projectName,
RepoUrl: repoUrl,
}
created, id, err := o.ReadOrCreate(&project, "UserName", "ProjectName", "RepoUrl")
if err == nil {
if created {
fmt.Println("New Insert an object. Id:", id)
return id, nil
} else {
fmt.Println("Get an object. Id:", id)
return id, nil
}
} else {
return 0, err
}
} | go | func ReadOrCreateProject(userName string, projectName string, repoUrl string) (int64, error) {
o := orm.NewOrm()
project := Project{
UserName: userName,
ProjectName: projectName,
RepoUrl: repoUrl,
}
created, id, err := o.ReadOrCreate(&project, "UserName", "ProjectName", "RepoUrl")
if err == nil {
if created {
fmt.Println("New Insert an object. Id:", id)
return id, nil
} else {
fmt.Println("Get an object. Id:", id)
return id, nil
}
} else {
return 0, err
}
} | [
"func",
"ReadOrCreateProject",
"(",
"userName",
"string",
",",
"projectName",
"string",
",",
"repoUrl",
"string",
")",
"(",
"int64",
",",
"error",
")",
"{",
"o",
":=",
"orm",
".",
"NewOrm",
"(",
")",
"\n\n",
"project",
":=",
"Project",
"{",
"UserName",
"... | // ReadOrCreateProject tries to get the project and create it if it doesn't exist. | [
"ReadOrCreateProject",
"tries",
"to",
"get",
"the",
"project",
"and",
"create",
"it",
"if",
"it",
"doesn",
"t",
"exist",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/models/projects.go#L49-L70 |
153,840 | ArchCI/archci | models/projects.go | AddProject | func AddProject(project Project) error {
o := orm.NewOrm()
_, err := o.Insert(&project)
return err
} | go | func AddProject(project Project) error {
o := orm.NewOrm()
_, err := o.Insert(&project)
return err
} | [
"func",
"AddProject",
"(",
"project",
"Project",
")",
"error",
"{",
"o",
":=",
"orm",
".",
"NewOrm",
"(",
")",
"\n\n",
"_",
",",
"err",
":=",
"o",
".",
"Insert",
"(",
"&",
"project",
")",
"\n\n",
"return",
"err",
"\n",
"}"
] | // AddProject adds the project in database. | [
"AddProject",
"adds",
"the",
"project",
"in",
"database",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/models/projects.go#L73-L79 |
153,841 | ArchCI/archci | models/projects.go | DeleteProject | func DeleteProject(projectId int64) error {
o := orm.NewOrm()
_, err := o.Delete(&Project{Id: projectId})
return err
} | go | func DeleteProject(projectId int64) error {
o := orm.NewOrm()
_, err := o.Delete(&Project{Id: projectId})
return err
} | [
"func",
"DeleteProject",
"(",
"projectId",
"int64",
")",
"error",
"{",
"o",
":=",
"orm",
".",
"NewOrm",
"(",
")",
"\n\n",
"_",
",",
"err",
":=",
"o",
".",
"Delete",
"(",
"&",
"Project",
"{",
"Id",
":",
"projectId",
"}",
")",
"\n\n",
"return",
"err"... | // DeleteProject delete the project in database. | [
"DeleteProject",
"delete",
"the",
"project",
"in",
"database",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/models/projects.go#L82-L88 |
153,842 | ArchCI/archci | models/builds.go | GetAllBuilds | func GetAllBuilds() []*Build {
o := orm.NewOrm()
var builds []*Build
// o.QueryTable("build").Filter("name", "slene").All(&builds) to filter with build status
num, err := o.QueryTable("build").All(&builds)
fmt.Printf("Returned Rows Num: %s, %s", num, err)
return builds
} | go | func GetAllBuilds() []*Build {
o := orm.NewOrm()
var builds []*Build
// o.QueryTable("build").Filter("name", "slene").All(&builds) to filter with build status
num, err := o.QueryTable("build").All(&builds)
fmt.Printf("Returned Rows Num: %s, %s", num, err)
return builds
} | [
"func",
"GetAllBuilds",
"(",
")",
"[",
"]",
"*",
"Build",
"{",
"o",
":=",
"orm",
".",
"NewOrm",
"(",
")",
"\n\n",
"var",
"builds",
"[",
"]",
"*",
"Build",
"\n",
"// o.QueryTable(\"build\").Filter(\"name\", \"slene\").All(&builds) to filter with build status",
"num",... | // GetAllBuilds return all builds from database. | [
"GetAllBuilds",
"return",
"all",
"builds",
"from",
"database",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/models/builds.go#L40-L48 |
153,843 | ArchCI/archci | models/builds.go | GetBuildsWithProjectName | func GetBuildsWithProjectName(projectName string) []*Build {
o := orm.NewOrm()
var builds []*Build
num, err := o.QueryTable("build").Filter("project_name", projectName).All(&builds)
fmt.Printf("Returned Rows Num: %s, %s", num, err)
return builds
} | go | func GetBuildsWithProjectName(projectName string) []*Build {
o := orm.NewOrm()
var builds []*Build
num, err := o.QueryTable("build").Filter("project_name", projectName).All(&builds)
fmt.Printf("Returned Rows Num: %s, %s", num, err)
return builds
} | [
"func",
"GetBuildsWithProjectName",
"(",
"projectName",
"string",
")",
"[",
"]",
"*",
"Build",
"{",
"o",
":=",
"orm",
".",
"NewOrm",
"(",
")",
"\n\n",
"var",
"builds",
"[",
"]",
"*",
"Build",
"\n",
"num",
",",
"err",
":=",
"o",
".",
"QueryTable",
"("... | // GetBuildsWithProjectName takes project name and return its builds. | [
"GetBuildsWithProjectName",
"takes",
"project",
"name",
"and",
"return",
"its",
"builds",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/models/builds.go#L51-L58 |
153,844 | ArchCI/archci | models/builds.go | GetBuildWithId | func GetBuildWithId(buildId int64) Build {
o := orm.NewOrm()
build := Build{Id: buildId}
err := o.Read(&build)
fmt.Printf("ERR: %v\n", err)
return build
} | go | func GetBuildWithId(buildId int64) Build {
o := orm.NewOrm()
build := Build{Id: buildId}
err := o.Read(&build)
fmt.Printf("ERR: %v\n", err)
return build
} | [
"func",
"GetBuildWithId",
"(",
"buildId",
"int64",
")",
"Build",
"{",
"o",
":=",
"orm",
".",
"NewOrm",
"(",
")",
"\n\n",
"build",
":=",
"Build",
"{",
"Id",
":",
"buildId",
"}",
"\n",
"err",
":=",
"o",
".",
"Read",
"(",
"&",
"build",
")",
"\n",
"f... | // GetBuildWithId takes build is and return the build. | [
"GetBuildWithId",
"takes",
"build",
"is",
"and",
"return",
"the",
"build",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/models/builds.go#L61-L68 |
153,845 | ArchCI/archci | models/builds.go | AddBuildWithProject | func AddBuildWithProject(project Project) error {
o := orm.NewOrm()
build := Build{UserName: project.UserName, ProjectName: project.ProjectName, RepoUrl: project.RepoUrl, Branch: "master", BuildTime: time.Now(), CommitTime: time.Now()}
_, err := o.Insert(&build)
fmt.Printf("ERR: %v\n", err)
return err
} | go | func AddBuildWithProject(project Project) error {
o := orm.NewOrm()
build := Build{UserName: project.UserName, ProjectName: project.ProjectName, RepoUrl: project.RepoUrl, Branch: "master", BuildTime: time.Now(), CommitTime: time.Now()}
_, err := o.Insert(&build)
fmt.Printf("ERR: %v\n", err)
return err
} | [
"func",
"AddBuildWithProject",
"(",
"project",
"Project",
")",
"error",
"{",
"o",
":=",
"orm",
".",
"NewOrm",
"(",
")",
"\n\n",
"build",
":=",
"Build",
"{",
"UserName",
":",
"project",
".",
"UserName",
",",
"ProjectName",
":",
"project",
".",
"ProjectName"... | // AddBuildWithProject take project object to create build. | [
"AddBuildWithProject",
"take",
"project",
"object",
"to",
"create",
"build",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/models/builds.go#L71-L78 |
153,846 | ArchCI/archci | models/builds.go | AddGithubBuild | func AddGithubBuild(projectId int64, data githubutil.GithubPushHook) error {
o := orm.NewOrm()
// TODO(tobe): could not get commit id, commit time and committer
build := Build{
UserName: data.Repository.Owner.Login,
ProjectId: projectId,
ProjectName: data.Repository.Name,
RepoUrl: data.Repository.URL,
Branch: data.Repository.DefaultBranch,
Commit: "ffffffffff",
CommitTime: time.Now(),
Committer: "unknown",
BuildTime: time.Now(),
FinishTime: time.Now(),
Status: BUILD_STATUS_NOT_START}
_, err := o.Insert(&build)
fmt.Println("ERR: %v\n", err)
return err
} | go | func AddGithubBuild(projectId int64, data githubutil.GithubPushHook) error {
o := orm.NewOrm()
// TODO(tobe): could not get commit id, commit time and committer
build := Build{
UserName: data.Repository.Owner.Login,
ProjectId: projectId,
ProjectName: data.Repository.Name,
RepoUrl: data.Repository.URL,
Branch: data.Repository.DefaultBranch,
Commit: "ffffffffff",
CommitTime: time.Now(),
Committer: "unknown",
BuildTime: time.Now(),
FinishTime: time.Now(),
Status: BUILD_STATUS_NOT_START}
_, err := o.Insert(&build)
fmt.Println("ERR: %v\n", err)
return err
} | [
"func",
"AddGithubBuild",
"(",
"projectId",
"int64",
",",
"data",
"githubutil",
".",
"GithubPushHook",
")",
"error",
"{",
"o",
":=",
"orm",
".",
"NewOrm",
"(",
")",
"\n\n",
"// TODO(tobe): could not get commit id, commit time and committer",
"build",
":=",
"Build",
... | // AddGithubBuild takes github webhook to create build. | [
"AddGithubBuild",
"takes",
"github",
"webhook",
"to",
"create",
"build",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/models/builds.go#L81-L102 |
153,847 | ArchCI/archci | models/builds.go | AddGitlabBuild | func AddGitlabBuild(projectId int64, data gitlabutil.GitlabPushHook) error {
o := orm.NewOrm()
// TODO(tobe): need to find project id by user name and project name
// TODO(tobe): no branch data from gitlab webhook
// TODO(tobe): should choose the latest commit
// TODO(tobe): build time and finish time should be null
build := Build{
UserName: data.UserName,
ProjectId: projectId,
ProjectName: data.Repository.Name,
RepoUrl: data.Repository.URL,
Branch: "master",
Commit: data.Commits[0].ID,
CommitTime: data.Commits[0].Timestamp,
Committer: data.Commits[0].Author.Name,
BuildTime: time.Now(),
FinishTime: time.Now(),
Status: BUILD_STATUS_NOT_START}
_, err := o.Insert(&build)
fmt.Println("ERR: %v\n", err)
return err
} | go | func AddGitlabBuild(projectId int64, data gitlabutil.GitlabPushHook) error {
o := orm.NewOrm()
// TODO(tobe): need to find project id by user name and project name
// TODO(tobe): no branch data from gitlab webhook
// TODO(tobe): should choose the latest commit
// TODO(tobe): build time and finish time should be null
build := Build{
UserName: data.UserName,
ProjectId: projectId,
ProjectName: data.Repository.Name,
RepoUrl: data.Repository.URL,
Branch: "master",
Commit: data.Commits[0].ID,
CommitTime: data.Commits[0].Timestamp,
Committer: data.Commits[0].Author.Name,
BuildTime: time.Now(),
FinishTime: time.Now(),
Status: BUILD_STATUS_NOT_START}
_, err := o.Insert(&build)
fmt.Println("ERR: %v\n", err)
return err
} | [
"func",
"AddGitlabBuild",
"(",
"projectId",
"int64",
",",
"data",
"gitlabutil",
".",
"GitlabPushHook",
")",
"error",
"{",
"o",
":=",
"orm",
".",
"NewOrm",
"(",
")",
"\n\n",
"// TODO(tobe): need to find project id by user name and project name",
"// TODO(tobe): no branch d... | // AddGitlabBuild takes gitlab webhook to create build. | [
"AddGitlabBuild",
"takes",
"gitlab",
"webhook",
"to",
"create",
"build",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/models/builds.go#L105-L129 |
153,848 | ArchCI/archci | models/builds.go | AddBuild | func AddBuild(projectName string, branch string, commit string, commitTime time.Time, committer string) error {
o := orm.NewOrm()
build := Build{ProjectName: projectName, Branch: branch, Commit: commit, CommitTime: commitTime, Committer: committer}
_, err := o.Insert(&build)
return err
} | go | func AddBuild(projectName string, branch string, commit string, commitTime time.Time, committer string) error {
o := orm.NewOrm()
build := Build{ProjectName: projectName, Branch: branch, Commit: commit, CommitTime: commitTime, Committer: committer}
_, err := o.Insert(&build)
return err
} | [
"func",
"AddBuild",
"(",
"projectName",
"string",
",",
"branch",
"string",
",",
"commit",
"string",
",",
"commitTime",
"time",
".",
"Time",
",",
"committer",
"string",
")",
"error",
"{",
"o",
":=",
"orm",
".",
"NewOrm",
"(",
")",
"\n\n",
"build",
":=",
... | // AddBuild takes basic information to create build. | [
"AddBuild",
"takes",
"basic",
"information",
"to",
"create",
"build",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/models/builds.go#L132-L138 |
153,849 | ArchCI/archci | models/builds.go | DeleteBuildsWithProjectId | func DeleteBuildsWithProjectId(projectId int64) error {
o := orm.NewOrm()
_, err := o.Delete(&Build{ProjectId: projectId})
return err
} | go | func DeleteBuildsWithProjectId(projectId int64) error {
o := orm.NewOrm()
_, err := o.Delete(&Build{ProjectId: projectId})
return err
} | [
"func",
"DeleteBuildsWithProjectId",
"(",
"projectId",
"int64",
")",
"error",
"{",
"o",
":=",
"orm",
".",
"NewOrm",
"(",
")",
"\n\n",
"_",
",",
"err",
":=",
"o",
".",
"Delete",
"(",
"&",
"Build",
"{",
"ProjectId",
":",
"projectId",
"}",
")",
"\n\n",
... | // DeleteBuildsWithProjectId deletes all the builds from the project. | [
"DeleteBuildsWithProjectId",
"deletes",
"all",
"the",
"builds",
"from",
"the",
"project",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/models/builds.go#L141-L147 |
153,850 | ArchCI/archci | models/workers.go | GetAllWorkers | func GetAllWorkers() []*Worker {
o := orm.NewOrm()
var workers []*Worker
num, err := o.QueryTable("worker").All(&workers)
fmt.Printf("Returned Rows Num: %s, %s", num, err)
return workers
} | go | func GetAllWorkers() []*Worker {
o := orm.NewOrm()
var workers []*Worker
num, err := o.QueryTable("worker").All(&workers)
fmt.Printf("Returned Rows Num: %s, %s", num, err)
return workers
} | [
"func",
"GetAllWorkers",
"(",
")",
"[",
"]",
"*",
"Worker",
"{",
"o",
":=",
"orm",
".",
"NewOrm",
"(",
")",
"\n\n",
"var",
"workers",
"[",
"]",
"*",
"Worker",
"\n",
"num",
",",
"err",
":=",
"o",
".",
"QueryTable",
"(",
"\"",
"\"",
")",
".",
"Al... | // GetAllWorkers return all the workers from database. | [
"GetAllWorkers",
"return",
"all",
"the",
"workers",
"from",
"database",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/models/workers.go#L26-L33 |
153,851 | ArchCI/archci | models/workers.go | GetAllWorkersWithStatus | func GetAllWorkersWithStatus(status int) []*Worker {
o := orm.NewOrm()
var workers []*Worker
num, err := o.QueryTable("worker").Filter("status", status).All(&workers)
fmt.Printf("Returned Rows Num: %s, %s", num, err)
return workers
} | go | func GetAllWorkersWithStatus(status int) []*Worker {
o := orm.NewOrm()
var workers []*Worker
num, err := o.QueryTable("worker").Filter("status", status).All(&workers)
fmt.Printf("Returned Rows Num: %s, %s", num, err)
return workers
} | [
"func",
"GetAllWorkersWithStatus",
"(",
"status",
"int",
")",
"[",
"]",
"*",
"Worker",
"{",
"o",
":=",
"orm",
".",
"NewOrm",
"(",
")",
"\n\n",
"var",
"workers",
"[",
"]",
"*",
"Worker",
"\n",
"num",
",",
"err",
":=",
"o",
".",
"QueryTable",
"(",
"\... | // GetAllWorkersWithStatus takes the status and return the workers. | [
"GetAllWorkersWithStatus",
"takes",
"the",
"status",
"and",
"return",
"the",
"workers",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/models/workers.go#L36-L43 |
153,852 | ArchCI/archci | routers/router.go | init | func init() {
// ArchCI web pages.
beego.Router("/", &controllers.MainController{})
beego.Router("/builds", &controllers.MainController{})
beego.Router("/builds/:buildId", &controllers.MainController{})
beego.Router("/projects", &controllers.MainController{})
beego.Router("/projects/:projectId", &controllers.MainController{})
beego.Router("/workers", &controllers.MainController{})
beego.Router("/account", &controllers.MainController{})
// Login api.
beego.Router("/v1/login/github", &controllers.ApiController{}, "get:LoginGithub")
beego.Router("/v1/login/github/callback", &controllers.ApiController{}, "get:LoginGithubCallback")
// Builds api.
beego.Router("/v1/builds/new", &controllers.ApiController{}, "post:NewBuild")
beego.Router("/v1/builds/all", &controllers.ApiController{}, "get:GetBuildsAll")
beego.Router("/v1/builds/all/project/:projectName", &controllers.ApiController{}, "get:GetBuildsWithProjectName")
beego.Router("/v1/builds/:buildId", &controllers.ApiController{}, "get:GetBuild")
beego.Router("/v1/builds/active", &controllers.ApiController{}, "get:GetActiveBuilds")
beego.Router("/v1/builds/search", &controllers.ApiController{}, "get:GetSearchBuilds")
beego.Router("/v1/builds/:buildId/logs/:index", &controllers.ApiController{}, "get:GetBuildLogsIndex")
beego.Router("/v1/builds/:buildId/logs/all", &controllers.ApiController{}, "get:GetBuildLogsAll")
// Projects api.
beego.Router("/v1/projects/new", &controllers.ApiController{}, "post:NewProject")
beego.Router("/v1/projects/all", &controllers.ApiController{}, "get:GetProjectsAll")
beego.Router("/v1/projects/:projectId", &controllers.ApiController{}, "get:GetProject")
beego.Router("/v1/projects/:projectId", &controllers.ApiController{}, "delete:DeleteProjectAndBuilds")
// Workers api.
beego.Router("/v1/workers/all", &controllers.ApiController{}, "get:GetWorkersAll")
// TODO(tobe): this is not really RESTful
beego.Router("/v1/workers/all/status/:status", &controllers.ApiController{}, "get:GetWorkersAllStatus")
// account api.
beego.Router("/v1/account/info", &controllers.ApiController{}, "get:GetAccountInfo")
beego.Router("/v1/account/projects", &controllers.ApiController{}, "get:GetAccountProjects")
beego.Router("/v1/account/token", &controllers.ApiController{}, "get:GetAccountToken")
beego.Router("/v1/account/organizations", &controllers.ApiController{}, "get:GetAccountOrganizations")
// Hooks api.
beego.Router("/v1/hook/github/push", &controllers.ApiController{}, "post:TriggerGithubPushHook")
beego.Router("/v1/hook/gitlab/push", &controllers.ApiController{}, "post:TriggerGitlabPushHook")
// Badge api.
beego.Router("/v1/badge/:projectId", &controllers.ApiController{}, "get:GetProjectBadge")
beego.Router("/v1/badge/:projectId/url", &controllers.ApiController{}, "get:GetProjectBadgeUrl")
beego.Router("/v1/badge/:projectId/markdown", &controllers.ApiController{}, "get:GetProjectBadgeMarkdown")
} | go | func init() {
// ArchCI web pages.
beego.Router("/", &controllers.MainController{})
beego.Router("/builds", &controllers.MainController{})
beego.Router("/builds/:buildId", &controllers.MainController{})
beego.Router("/projects", &controllers.MainController{})
beego.Router("/projects/:projectId", &controllers.MainController{})
beego.Router("/workers", &controllers.MainController{})
beego.Router("/account", &controllers.MainController{})
// Login api.
beego.Router("/v1/login/github", &controllers.ApiController{}, "get:LoginGithub")
beego.Router("/v1/login/github/callback", &controllers.ApiController{}, "get:LoginGithubCallback")
// Builds api.
beego.Router("/v1/builds/new", &controllers.ApiController{}, "post:NewBuild")
beego.Router("/v1/builds/all", &controllers.ApiController{}, "get:GetBuildsAll")
beego.Router("/v1/builds/all/project/:projectName", &controllers.ApiController{}, "get:GetBuildsWithProjectName")
beego.Router("/v1/builds/:buildId", &controllers.ApiController{}, "get:GetBuild")
beego.Router("/v1/builds/active", &controllers.ApiController{}, "get:GetActiveBuilds")
beego.Router("/v1/builds/search", &controllers.ApiController{}, "get:GetSearchBuilds")
beego.Router("/v1/builds/:buildId/logs/:index", &controllers.ApiController{}, "get:GetBuildLogsIndex")
beego.Router("/v1/builds/:buildId/logs/all", &controllers.ApiController{}, "get:GetBuildLogsAll")
// Projects api.
beego.Router("/v1/projects/new", &controllers.ApiController{}, "post:NewProject")
beego.Router("/v1/projects/all", &controllers.ApiController{}, "get:GetProjectsAll")
beego.Router("/v1/projects/:projectId", &controllers.ApiController{}, "get:GetProject")
beego.Router("/v1/projects/:projectId", &controllers.ApiController{}, "delete:DeleteProjectAndBuilds")
// Workers api.
beego.Router("/v1/workers/all", &controllers.ApiController{}, "get:GetWorkersAll")
// TODO(tobe): this is not really RESTful
beego.Router("/v1/workers/all/status/:status", &controllers.ApiController{}, "get:GetWorkersAllStatus")
// account api.
beego.Router("/v1/account/info", &controllers.ApiController{}, "get:GetAccountInfo")
beego.Router("/v1/account/projects", &controllers.ApiController{}, "get:GetAccountProjects")
beego.Router("/v1/account/token", &controllers.ApiController{}, "get:GetAccountToken")
beego.Router("/v1/account/organizations", &controllers.ApiController{}, "get:GetAccountOrganizations")
// Hooks api.
beego.Router("/v1/hook/github/push", &controllers.ApiController{}, "post:TriggerGithubPushHook")
beego.Router("/v1/hook/gitlab/push", &controllers.ApiController{}, "post:TriggerGitlabPushHook")
// Badge api.
beego.Router("/v1/badge/:projectId", &controllers.ApiController{}, "get:GetProjectBadge")
beego.Router("/v1/badge/:projectId/url", &controllers.ApiController{}, "get:GetProjectBadgeUrl")
beego.Router("/v1/badge/:projectId/markdown", &controllers.ApiController{}, "get:GetProjectBadgeMarkdown")
} | [
"func",
"init",
"(",
")",
"{",
"// ArchCI web pages.",
"beego",
".",
"Router",
"(",
"\"",
"\"",
",",
"&",
"controllers",
".",
"MainController",
"{",
"}",
")",
"\n",
"beego",
".",
"Router",
"(",
"\"",
"\"",
",",
"&",
"controllers",
".",
"MainController",
... | // Init registries all the APIs when startup. | [
"Init",
"registries",
"all",
"the",
"APIs",
"when",
"startup",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/routers/router.go#L9-L58 |
153,853 | ArchCI/archci | controllers/workers.go | GetWorkersAll | func (c *ApiController) GetWorkersAll() {
log.Info("Get all workers")
workers := models.GetAllWorkers()
c.Data["json"] = workers
c.ServeJson()
} | go | func (c *ApiController) GetWorkersAll() {
log.Info("Get all workers")
workers := models.GetAllWorkers()
c.Data["json"] = workers
c.ServeJson()
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetWorkersAll",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"workers",
":=",
"models",
".",
"GetAllWorkers",
"(",
")",
"\n\n",
"c",
".",
"Data",
"[",
"\"",
"\"",
"]",
"=",
"workers"... | // GetWorkerAll returns all workers from database. | [
"GetWorkerAll",
"returns",
"all",
"workers",
"from",
"database",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/workers.go#L10-L17 |
153,854 | ArchCI/archci | controllers/workers.go | GetWorkersAllStatus | func (c *ApiController) GetWorkersAllStatus() {
log.Info("Get all workers with status")
status, _ := c.GetInt(":status")
workers := models.GetAllWorkersWithStatus(status)
c.Data["json"] = workers
c.ServeJson()
} | go | func (c *ApiController) GetWorkersAllStatus() {
log.Info("Get all workers with status")
status, _ := c.GetInt(":status")
workers := models.GetAllWorkersWithStatus(status)
c.Data["json"] = workers
c.ServeJson()
} | [
"func",
"(",
"c",
"*",
"ApiController",
")",
"GetWorkersAllStatus",
"(",
")",
"{",
"log",
".",
"Info",
"(",
"\"",
"\"",
")",
"\n\n",
"status",
",",
"_",
":=",
"c",
".",
"GetInt",
"(",
"\"",
"\"",
")",
"\n",
"workers",
":=",
"models",
".",
"GetAllWo... | // GetWorkersAllStatus take the parameter of status and return the workers. | [
"GetWorkersAllStatus",
"take",
"the",
"parameter",
"of",
"status",
"and",
"return",
"the",
"workers",
"."
] | 20171d715f6ae0e3fcbfd22354087f1b50460a05 | https://github.com/ArchCI/archci/blob/20171d715f6ae0e3fcbfd22354087f1b50460a05/controllers/workers.go#L20-L28 |
153,855 | johngb/langreg | language.go | IsValidLanguageCode | func IsValidLanguageCode(s string) bool {
_, _, err := LangCodeInfo(s)
if err != nil {
return false
}
return true
} | go | func IsValidLanguageCode(s string) bool {
_, _, err := LangCodeInfo(s)
if err != nil {
return false
}
return true
} | [
"func",
"IsValidLanguageCode",
"(",
"s",
"string",
")",
"bool",
"{",
"_",
",",
"_",
",",
"err",
":=",
"LangCodeInfo",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] | // IsValidLanguageCode returns true if s is a valid ISO 639-1 language code | [
"IsValidLanguageCode",
"returns",
"true",
"if",
"s",
"is",
"a",
"valid",
"ISO",
"639",
"-",
"1",
"language",
"code"
] | 5c6abc6d19d2a39ff139e0b234177b0508d69ea4 | https://github.com/johngb/langreg/blob/5c6abc6d19d2a39ff139e0b234177b0508d69ea4/language.go#L6-L12 |
153,856 | johngb/langreg | langreg.go | IsValidLangRegCode | func IsValidLangRegCode(s string) bool {
// all valid codes are 5 characters long
if len(s) != 5 {
return false
}
// the middle (third) character must be a '_' char
if s[2] != '_' {
return false
}
// check the language code, which should be the first two characters in s
if !IsValidLanguageCode(s[:2]) {
return false
}
// check the region code, which should be the last two characters in s
if !IsValidRegionCode(s[3:]) {
return false
}
return true
} | go | func IsValidLangRegCode(s string) bool {
// all valid codes are 5 characters long
if len(s) != 5 {
return false
}
// the middle (third) character must be a '_' char
if s[2] != '_' {
return false
}
// check the language code, which should be the first two characters in s
if !IsValidLanguageCode(s[:2]) {
return false
}
// check the region code, which should be the last two characters in s
if !IsValidRegionCode(s[3:]) {
return false
}
return true
} | [
"func",
"IsValidLangRegCode",
"(",
"s",
"string",
")",
"bool",
"{",
"// all valid codes are 5 characters long",
"if",
"len",
"(",
"s",
")",
"!=",
"5",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"// the middle (third) character must be a '_' char",
"if",
"s",
"[",
... | // IsValidLangRegCode returns true if the string s is a valid ISO 639-1 language
// and ISO1366-1_alpa-2 region code separated by an underscore. E.g. "en_US". | [
"IsValidLangRegCode",
"returns",
"true",
"if",
"the",
"string",
"s",
"is",
"a",
"valid",
"ISO",
"639",
"-",
"1",
"language",
"and",
"ISO1366",
"-",
"1_alpa",
"-",
"2",
"region",
"code",
"separated",
"by",
"an",
"underscore",
".",
"E",
".",
"g",
".",
"e... | 5c6abc6d19d2a39ff139e0b234177b0508d69ea4 | https://github.com/johngb/langreg/blob/5c6abc6d19d2a39ff139e0b234177b0508d69ea4/langreg.go#L28-L50 |
153,857 | johngb/langreg | region.go | IsValidRegionCode | func IsValidRegionCode(s string) bool {
_, err := RegionCodeInfo(s)
if err != nil {
return false
}
return true
} | go | func IsValidRegionCode(s string) bool {
_, err := RegionCodeInfo(s)
if err != nil {
return false
}
return true
} | [
"func",
"IsValidRegionCode",
"(",
"s",
"string",
")",
"bool",
"{",
"_",
",",
"err",
":=",
"RegionCodeInfo",
"(",
"s",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"return",
"true",
"\n",
"}"
] | // IsValidRegionCode returns true if s is a valid ISO1366-1_alpa-2 region code. | [
"IsValidRegionCode",
"returns",
"true",
"if",
"s",
"is",
"a",
"valid",
"ISO1366",
"-",
"1_alpa",
"-",
"2",
"region",
"code",
"."
] | 5c6abc6d19d2a39ff139e0b234177b0508d69ea4 | https://github.com/johngb/langreg/blob/5c6abc6d19d2a39ff139e0b234177b0508d69ea4/region.go#L6-L12 |
153,858 | johngb/langreg | region.go | RegionName | func RegionName(s string) (string, error) {
name, err := RegionCodeInfo(s)
return name, err
} | go | func RegionName(s string) (string, error) {
name, err := RegionCodeInfo(s)
return name, err
} | [
"func",
"RegionName",
"(",
"s",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"name",
",",
"err",
":=",
"RegionCodeInfo",
"(",
"s",
")",
"\n",
"return",
"name",
",",
"err",
"\n",
"}"
] | // RegionName returns the English name of the ISO1366-1_alpa-2 region code s. | [
"RegionName",
"returns",
"the",
"English",
"name",
"of",
"the",
"ISO1366",
"-",
"1_alpa",
"-",
"2",
"region",
"code",
"s",
"."
] | 5c6abc6d19d2a39ff139e0b234177b0508d69ea4 | https://github.com/johngb/langreg/blob/5c6abc6d19d2a39ff139e0b234177b0508d69ea4/region.go#L15-L18 |
153,859 | uhoh-itsmaciek/femebe | buf/reader.go | Len | func (r *Reader) Len() int {
if r.i >= len(r.s) {
return 0
}
return len(r.s) - r.i
} | go | func (r *Reader) Len() int {
if r.i >= len(r.s) {
return 0
}
return len(r.s) - r.i
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"Len",
"(",
")",
"int",
"{",
"if",
"r",
".",
"i",
">=",
"len",
"(",
"r",
".",
"s",
")",
"{",
"return",
"0",
"\n",
"}",
"\n",
"return",
"len",
"(",
"r",
".",
"s",
")",
"-",
"r",
".",
"i",
"\n",
"}"
] | // Len returns the number of bytes of the unread portion of the
// slice. | [
"Len",
"returns",
"the",
"number",
"of",
"bytes",
"of",
"the",
"unread",
"portion",
"of",
"the",
"slice",
"."
] | 78f00f2ef7b41255fe56120e95887461adb2aa38 | https://github.com/uhoh-itsmaciek/femebe/blob/78f00f2ef7b41255fe56120e95887461adb2aa38/buf/reader.go#L48-L53 |
153,860 | uhoh-itsmaciek/femebe | buf/reader.go | Seek | func (r *Reader) Seek(offset int64, whence int) (int64, error) {
var abs int64
switch whence {
case 0:
abs = offset
case 1:
abs = int64(r.i) + offset
case 2:
abs = int64(len(r.s)) + offset
default:
return 0, errors.New("bytes: invalid whence")
}
if abs < 0 {
return 0, errors.New("bytes: negative position")
}
if abs >= 1<<31 {
return 0, errors.New("bytes: position out of range")
}
r.i = int(abs)
return abs, nil
} | go | func (r *Reader) Seek(offset int64, whence int) (int64, error) {
var abs int64
switch whence {
case 0:
abs = offset
case 1:
abs = int64(r.i) + offset
case 2:
abs = int64(len(r.s)) + offset
default:
return 0, errors.New("bytes: invalid whence")
}
if abs < 0 {
return 0, errors.New("bytes: negative position")
}
if abs >= 1<<31 {
return 0, errors.New("bytes: position out of range")
}
r.i = int(abs)
return abs, nil
} | [
"func",
"(",
"r",
"*",
"Reader",
")",
"Seek",
"(",
"offset",
"int64",
",",
"whence",
"int",
")",
"(",
"int64",
",",
"error",
")",
"{",
"var",
"abs",
"int64",
"\n",
"switch",
"whence",
"{",
"case",
"0",
":",
"abs",
"=",
"offset",
"\n",
"case",
"1"... | // Seek implements the io.Seeker interface. | [
"Seek",
"implements",
"the",
"io",
".",
"Seeker",
"interface",
"."
] | 78f00f2ef7b41255fe56120e95887461adb2aa38 | https://github.com/uhoh-itsmaciek/femebe/blob/78f00f2ef7b41255fe56120e95887461adb2aa38/buf/reader.go#L99-L119 |
153,861 | gyuho/dataframe | dataframe.go | NewFromRows | func NewFromRows(header []string, rows [][]string) (Frame, error) {
if len(rows) < 1 {
return nil, fmt.Errorf("empty row %q", rows)
}
fr := New()
headerN := len(header)
if headerN > 0 { // use this as header
// assume no header string at top
cols := make([]Column, headerN)
for i := range cols {
cols[i] = NewColumn(header[i])
}
for _, row := range rows {
rowN := len(row)
if rowN > headerN {
return nil, fmt.Errorf("header %q is not specified correctly for %q", header, row)
}
for j, v := range row {
cols[j].PushBack(NewStringValue(v))
}
if rowN < headerN { // fill in empty values
for k := rowN; k < headerN; k++ {
cols[k].PushBack(NewStringValue(""))
}
}
}
for _, c := range cols {
if err := fr.AddColumn(c); err != nil {
return nil, err
}
}
return fr, nil
}
// use first row as header
// assume header string at top
header = rows[0]
headerN = len(header)
cols := make([]Column, headerN)
for i := range cols {
cols[i] = NewColumn(header[i])
}
for i, row := range rows {
if i == 0 {
continue
}
rowN := len(row)
if rowN > headerN {
return nil, fmt.Errorf("header %q is not specified correctly for %q", header, row)
}
for j, v := range row {
cols[j].PushBack(NewStringValue(v))
}
if rowN < headerN { // fill in empty values
for k := rowN; k < headerN; k++ {
cols[k].PushBack(NewStringValue(""))
}
}
}
for _, c := range cols {
if err := fr.AddColumn(c); err != nil {
return nil, err
}
}
return fr, nil
} | go | func NewFromRows(header []string, rows [][]string) (Frame, error) {
if len(rows) < 1 {
return nil, fmt.Errorf("empty row %q", rows)
}
fr := New()
headerN := len(header)
if headerN > 0 { // use this as header
// assume no header string at top
cols := make([]Column, headerN)
for i := range cols {
cols[i] = NewColumn(header[i])
}
for _, row := range rows {
rowN := len(row)
if rowN > headerN {
return nil, fmt.Errorf("header %q is not specified correctly for %q", header, row)
}
for j, v := range row {
cols[j].PushBack(NewStringValue(v))
}
if rowN < headerN { // fill in empty values
for k := rowN; k < headerN; k++ {
cols[k].PushBack(NewStringValue(""))
}
}
}
for _, c := range cols {
if err := fr.AddColumn(c); err != nil {
return nil, err
}
}
return fr, nil
}
// use first row as header
// assume header string at top
header = rows[0]
headerN = len(header)
cols := make([]Column, headerN)
for i := range cols {
cols[i] = NewColumn(header[i])
}
for i, row := range rows {
if i == 0 {
continue
}
rowN := len(row)
if rowN > headerN {
return nil, fmt.Errorf("header %q is not specified correctly for %q", header, row)
}
for j, v := range row {
cols[j].PushBack(NewStringValue(v))
}
if rowN < headerN { // fill in empty values
for k := rowN; k < headerN; k++ {
cols[k].PushBack(NewStringValue(""))
}
}
}
for _, c := range cols {
if err := fr.AddColumn(c); err != nil {
return nil, err
}
}
return fr, nil
} | [
"func",
"NewFromRows",
"(",
"header",
"[",
"]",
"string",
",",
"rows",
"[",
"]",
"[",
"]",
"string",
")",
"(",
"Frame",
",",
"error",
")",
"{",
"if",
"len",
"(",
"rows",
")",
"<",
"1",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",... | // NewFromRows creates Frame from rows.
// Pass 'nil' header if first row is used as header strings.
// Pass 'non-nil' header if the data starts from the first row, without header strings. | [
"NewFromRows",
"creates",
"Frame",
"from",
"rows",
".",
"Pass",
"nil",
"header",
"if",
"first",
"row",
"is",
"used",
"as",
"header",
"strings",
".",
"Pass",
"non",
"-",
"nil",
"header",
"if",
"the",
"data",
"starts",
"from",
"the",
"first",
"row",
"witho... | 008fc241adc41d4bd5c54b9f6564ef16407c030e | https://github.com/gyuho/dataframe/blob/008fc241adc41d4bd5c54b9f6564ef16407c030e/dataframe.go#L67-L131 |
153,862 | gyuho/dataframe | dataframe.go | NewFromCSV | func NewFromCSV(header []string, fpath string) (Frame, error) {
f, err := openToRead(fpath)
if err != nil {
return nil, err
}
defer f.Close()
rd := csv.NewReader(f)
// FieldsPerRecord is the number of expected fields per record.
// If FieldsPerRecord is positive, Read requires each record to
// have the given number of fields. If FieldsPerRecord is 0, Read sets it to
// the number of fields in the first record, so that future records must
// have the same field count. If FieldsPerRecord is negative, no check is
// made and records may have a variable number of fields.
rd.FieldsPerRecord = -1
rows, err := rd.ReadAll()
if err != nil {
return nil, err
}
return NewFromRows(header, rows)
} | go | func NewFromCSV(header []string, fpath string) (Frame, error) {
f, err := openToRead(fpath)
if err != nil {
return nil, err
}
defer f.Close()
rd := csv.NewReader(f)
// FieldsPerRecord is the number of expected fields per record.
// If FieldsPerRecord is positive, Read requires each record to
// have the given number of fields. If FieldsPerRecord is 0, Read sets it to
// the number of fields in the first record, so that future records must
// have the same field count. If FieldsPerRecord is negative, no check is
// made and records may have a variable number of fields.
rd.FieldsPerRecord = -1
rows, err := rd.ReadAll()
if err != nil {
return nil, err
}
return NewFromRows(header, rows)
} | [
"func",
"NewFromCSV",
"(",
"header",
"[",
"]",
"string",
",",
"fpath",
"string",
")",
"(",
"Frame",
",",
"error",
")",
"{",
"f",
",",
"err",
":=",
"openToRead",
"(",
"fpath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
... | // NewFromCSV creates a new Frame from CSV.
// Pass 'nil' header if first row is used as header strings.
// Pass 'non-nil' header if the data starts from the first row, without header strings. | [
"NewFromCSV",
"creates",
"a",
"new",
"Frame",
"from",
"CSV",
".",
"Pass",
"nil",
"header",
"if",
"first",
"row",
"is",
"used",
"as",
"header",
"strings",
".",
"Pass",
"non",
"-",
"nil",
"header",
"if",
"the",
"data",
"starts",
"from",
"the",
"first",
"... | 008fc241adc41d4bd5c54b9f6564ef16407c030e | https://github.com/gyuho/dataframe/blob/008fc241adc41d4bd5c54b9f6564ef16407c030e/dataframe.go#L136-L159 |
153,863 | gyuho/dataframe | dataframe.go | NewFromColumns | func NewFromColumns(zero Value, cols ...Column) (Frame, error) {
maxEndIndex := 0
columns := make([]Column, len(cols))
for i, col := range cols {
columns[i] = col.Copy()
if i == 0 {
maxEndIndex = col.Count()
}
if maxEndIndex < col.Count() {
maxEndIndex = col.Count()
}
}
// this is index, so decrement by 1 to make it as valid index
maxEndIndex--
maxSize := maxEndIndex + 1
if zero != nil {
// make all columns have same row number
for _, col := range columns {
rNum := col.Count()
if rNum < maxSize { // fill-in with zero values
for i := 0; i < maxSize-rNum; i++ {
col.PushBack(zero)
}
}
if rNum > maxSize {
return nil, fmt.Errorf("something wrong with minimum end index %d (%q has %d rows)", maxEndIndex, col.Header(), rNum)
}
}
// double-check
rNum := columns[0].Count()
for _, col := range columns {
if rNum != col.Count() {
return nil, fmt.Errorf("%q has %d rows (expected %d rows as %q)", col.Header(), col.Count(), rNum, columns[0].Header())
}
}
}
combined := New()
for _, col := range columns {
if err := combined.AddColumn(col); err != nil {
return nil, err
}
}
return combined, nil
} | go | func NewFromColumns(zero Value, cols ...Column) (Frame, error) {
maxEndIndex := 0
columns := make([]Column, len(cols))
for i, col := range cols {
columns[i] = col.Copy()
if i == 0 {
maxEndIndex = col.Count()
}
if maxEndIndex < col.Count() {
maxEndIndex = col.Count()
}
}
// this is index, so decrement by 1 to make it as valid index
maxEndIndex--
maxSize := maxEndIndex + 1
if zero != nil {
// make all columns have same row number
for _, col := range columns {
rNum := col.Count()
if rNum < maxSize { // fill-in with zero values
for i := 0; i < maxSize-rNum; i++ {
col.PushBack(zero)
}
}
if rNum > maxSize {
return nil, fmt.Errorf("something wrong with minimum end index %d (%q has %d rows)", maxEndIndex, col.Header(), rNum)
}
}
// double-check
rNum := columns[0].Count()
for _, col := range columns {
if rNum != col.Count() {
return nil, fmt.Errorf("%q has %d rows (expected %d rows as %q)", col.Header(), col.Count(), rNum, columns[0].Header())
}
}
}
combined := New()
for _, col := range columns {
if err := combined.AddColumn(col); err != nil {
return nil, err
}
}
return combined, nil
} | [
"func",
"NewFromColumns",
"(",
"zero",
"Value",
",",
"cols",
"...",
"Column",
")",
"(",
"Frame",
",",
"error",
")",
"{",
"maxEndIndex",
":=",
"0",
"\n",
"columns",
":=",
"make",
"(",
"[",
"]",
"Column",
",",
"len",
"(",
"cols",
")",
")",
"\n",
"for... | // NewFromColumns combines multiple columns into one data frame.
// If zero Value is not nil, it makes all columns have the same row number
// by inserting zero values where the row number is short compared to the
// one with the msot row number. The columns are deep-copied to the Frame. | [
"NewFromColumns",
"combines",
"multiple",
"columns",
"into",
"one",
"data",
"frame",
".",
"If",
"zero",
"Value",
"is",
"not",
"nil",
"it",
"makes",
"all",
"columns",
"have",
"the",
"same",
"row",
"number",
"by",
"inserting",
"zero",
"values",
"where",
"the",... | 008fc241adc41d4bd5c54b9f6564ef16407c030e | https://github.com/gyuho/dataframe/blob/008fc241adc41d4bd5c54b9f6564ef16407c030e/dataframe.go#L165-L211 |
153,864 | cenkalti/hub | hub.go | Subscribe | func (h *Hub) Subscribe(kind Kind, f func(Event)) (cancel func()) {
var cancelled bool
h.m.Lock()
h.seq++
id := h.seq
if h.subscribers == nil {
h.subscribers = make(map[Kind][]handler)
}
h.subscribers[kind] = append(h.subscribers[kind], handler{id: id, f: f})
h.m.Unlock()
return func() {
h.m.Lock()
if cancelled {
h.m.Unlock()
return
}
cancelled = true
a := h.subscribers[kind]
for i, f := range a {
if f.id == id {
a[i], h.subscribers[kind] = a[len(a)-1], a[:len(a)-1]
break
}
}
if len(a) == 0 {
delete(h.subscribers, kind)
}
h.m.Unlock()
}
} | go | func (h *Hub) Subscribe(kind Kind, f func(Event)) (cancel func()) {
var cancelled bool
h.m.Lock()
h.seq++
id := h.seq
if h.subscribers == nil {
h.subscribers = make(map[Kind][]handler)
}
h.subscribers[kind] = append(h.subscribers[kind], handler{id: id, f: f})
h.m.Unlock()
return func() {
h.m.Lock()
if cancelled {
h.m.Unlock()
return
}
cancelled = true
a := h.subscribers[kind]
for i, f := range a {
if f.id == id {
a[i], h.subscribers[kind] = a[len(a)-1], a[:len(a)-1]
break
}
}
if len(a) == 0 {
delete(h.subscribers, kind)
}
h.m.Unlock()
}
} | [
"func",
"(",
"h",
"*",
"Hub",
")",
"Subscribe",
"(",
"kind",
"Kind",
",",
"f",
"func",
"(",
"Event",
")",
")",
"(",
"cancel",
"func",
"(",
")",
")",
"{",
"var",
"cancelled",
"bool",
"\n",
"h",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"h",
".",
... | // Subscribe registers f for the event of a specific kind. | [
"Subscribe",
"registers",
"f",
"for",
"the",
"event",
"of",
"a",
"specific",
"kind",
"."
] | 11382a9960d39b0ecda16fd01c424c11ff765a34 | https://github.com/cenkalti/hub/blob/11382a9960d39b0ecda16fd01c424c11ff765a34/hub.go#L29-L58 |
153,865 | cenkalti/hub | hub.go | Publish | func (h *Hub) Publish(e Event) {
h.m.RLock()
if handlers, ok := h.subscribers[e.Kind()]; ok {
for _, h := range handlers {
h.f(e)
}
}
h.m.RUnlock()
} | go | func (h *Hub) Publish(e Event) {
h.m.RLock()
if handlers, ok := h.subscribers[e.Kind()]; ok {
for _, h := range handlers {
h.f(e)
}
}
h.m.RUnlock()
} | [
"func",
"(",
"h",
"*",
"Hub",
")",
"Publish",
"(",
"e",
"Event",
")",
"{",
"h",
".",
"m",
".",
"RLock",
"(",
")",
"\n",
"if",
"handlers",
",",
"ok",
":=",
"h",
".",
"subscribers",
"[",
"e",
".",
"Kind",
"(",
")",
"]",
";",
"ok",
"{",
"for",... | // Publish an event to the subscribers. | [
"Publish",
"an",
"event",
"to",
"the",
"subscribers",
"."
] | 11382a9960d39b0ecda16fd01c424c11ff765a34 | https://github.com/cenkalti/hub/blob/11382a9960d39b0ecda16fd01c424c11ff765a34/hub.go#L61-L69 |
153,866 | cenkalti/hub | hub.go | Subscribe | func Subscribe(kind Kind, f func(Event)) (cancel func()) {
return DefaultHub.Subscribe(kind, f)
} | go | func Subscribe(kind Kind, f func(Event)) (cancel func()) {
return DefaultHub.Subscribe(kind, f)
} | [
"func",
"Subscribe",
"(",
"kind",
"Kind",
",",
"f",
"func",
"(",
"Event",
")",
")",
"(",
"cancel",
"func",
"(",
")",
")",
"{",
"return",
"DefaultHub",
".",
"Subscribe",
"(",
"kind",
",",
"f",
")",
"\n",
"}"
] | // Subscribe registers f for the event of a specific kind in the DefaultHub. | [
"Subscribe",
"registers",
"f",
"for",
"the",
"event",
"of",
"a",
"specific",
"kind",
"in",
"the",
"DefaultHub",
"."
] | 11382a9960d39b0ecda16fd01c424c11ff765a34 | https://github.com/cenkalti/hub/blob/11382a9960d39b0ecda16fd01c424c11ff765a34/hub.go#L75-L77 |
153,867 | acoshift/middleware | compress.go | Compress | func Compress(config CompressConfig) Middleware {
// fill default config
if config.Skipper == nil {
config.Skipper = DefaultSkipper
}
mapTypes := make(map[string]struct{})
for _, t := range strings.Split(config.Types, " ") {
mapTypes[t] = struct{}{}
}
pool := &sync.Pool{
New: func() interface{} {
return config.New()
},
}
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if config.Skipper(r) {
h.ServeHTTP(w, r)
return
}
// skip if client not support
if !strings.Contains(r.Header.Get("Accept-Encoding"), config.Encoding) {
h.ServeHTTP(w, r)
return
}
// skip if web socket
if r.Header.Get("Sec-WebSocket-Key") != "" {
h.ServeHTTP(w, r)
return
}
hh := w.Header()
// skip if already encode
if hh.Get("Content-Encoding") != "" {
h.ServeHTTP(w, r)
return
}
if config.Vary {
addHeaderIfNotExists(hh, "Vary", "Accept-Encoding")
}
gw := &compressWriter{
ResponseWriter: w,
pool: pool,
encoding: config.Encoding,
types: mapTypes,
minLength: config.MinLength,
}
defer gw.Close()
h.ServeHTTP(gw, r)
})
}
} | go | func Compress(config CompressConfig) Middleware {
// fill default config
if config.Skipper == nil {
config.Skipper = DefaultSkipper
}
mapTypes := make(map[string]struct{})
for _, t := range strings.Split(config.Types, " ") {
mapTypes[t] = struct{}{}
}
pool := &sync.Pool{
New: func() interface{} {
return config.New()
},
}
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if config.Skipper(r) {
h.ServeHTTP(w, r)
return
}
// skip if client not support
if !strings.Contains(r.Header.Get("Accept-Encoding"), config.Encoding) {
h.ServeHTTP(w, r)
return
}
// skip if web socket
if r.Header.Get("Sec-WebSocket-Key") != "" {
h.ServeHTTP(w, r)
return
}
hh := w.Header()
// skip if already encode
if hh.Get("Content-Encoding") != "" {
h.ServeHTTP(w, r)
return
}
if config.Vary {
addHeaderIfNotExists(hh, "Vary", "Accept-Encoding")
}
gw := &compressWriter{
ResponseWriter: w,
pool: pool,
encoding: config.Encoding,
types: mapTypes,
minLength: config.MinLength,
}
defer gw.Close()
h.ServeHTTP(gw, r)
})
}
} | [
"func",
"Compress",
"(",
"config",
"CompressConfig",
")",
"Middleware",
"{",
"// fill default config",
"if",
"config",
".",
"Skipper",
"==",
"nil",
"{",
"config",
".",
"Skipper",
"=",
"DefaultSkipper",
"\n",
"}",
"\n\n",
"mapTypes",
":=",
"make",
"(",
"map",
... | // Compress creates new compress middleware | [
"Compress",
"creates",
"new",
"compress",
"middleware"
] | 72ef9c385871dd1964bcdf6170ce9aefeff90fd8 | https://github.com/acoshift/middleware/blob/72ef9c385871dd1964bcdf6170ce9aefeff90fd8/compress.go#L68-L128 |
153,868 | acoshift/middleware | compress.go | Push | func (w *compressWriter) Push(target string, opts *http.PushOptions) error {
if w, ok := w.ResponseWriter.(http.Pusher); ok {
return w.Push(target, opts)
}
return http.ErrNotSupported
} | go | func (w *compressWriter) Push(target string, opts *http.PushOptions) error {
if w, ok := w.ResponseWriter.(http.Pusher); ok {
return w.Push(target, opts)
}
return http.ErrNotSupported
} | [
"func",
"(",
"w",
"*",
"compressWriter",
")",
"Push",
"(",
"target",
"string",
",",
"opts",
"*",
"http",
".",
"PushOptions",
")",
"error",
"{",
"if",
"w",
",",
"ok",
":=",
"w",
".",
"ResponseWriter",
".",
"(",
"http",
".",
"Pusher",
")",
";",
"ok",... | // Push implements Pusher interface | [
"Push",
"implements",
"Pusher",
"interface"
] | 72ef9c385871dd1964bcdf6170ce9aefeff90fd8 | https://github.com/acoshift/middleware/blob/72ef9c385871dd1964bcdf6170ce9aefeff90fd8/compress.go#L211-L216 |
153,869 | acoshift/middleware | compress.go | Hijack | func (w *compressWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
if w, ok := w.ResponseWriter.(http.Hijacker); ok {
return w.Hijack()
}
return nil, nil, http.ErrNotSupported
} | go | func (w *compressWriter) Hijack() (net.Conn, *bufio.ReadWriter, error) {
if w, ok := w.ResponseWriter.(http.Hijacker); ok {
return w.Hijack()
}
return nil, nil, http.ErrNotSupported
} | [
"func",
"(",
"w",
"*",
"compressWriter",
")",
"Hijack",
"(",
")",
"(",
"net",
".",
"Conn",
",",
"*",
"bufio",
".",
"ReadWriter",
",",
"error",
")",
"{",
"if",
"w",
",",
"ok",
":=",
"w",
".",
"ResponseWriter",
".",
"(",
"http",
".",
"Hijacker",
")... | // Hijack implements Hijacker interface | [
"Hijack",
"implements",
"Hijacker",
"interface"
] | 72ef9c385871dd1964bcdf6170ce9aefeff90fd8 | https://github.com/acoshift/middleware/blob/72ef9c385871dd1964bcdf6170ce9aefeff90fd8/compress.go#L229-L234 |
153,870 | atsaki/golang-cloudstack-library | FirewallApi.go | DeleteEgressFirewallRule | func (c *Client) DeleteEgressFirewallRule(p *DeleteEgressFirewallRuleParameter) (*Result, error) {
obj, err := c.Request("deleteEgressFirewallRule", convertParamToMap(p))
if err != nil {
return nil, err
}
return obj.(*Result), err
} | go | func (c *Client) DeleteEgressFirewallRule(p *DeleteEgressFirewallRuleParameter) (*Result, error) {
obj, err := c.Request("deleteEgressFirewallRule", convertParamToMap(p))
if err != nil {
return nil, err
}
return obj.(*Result), err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteEgressFirewallRule",
"(",
"p",
"*",
"DeleteEgressFirewallRuleParameter",
")",
"(",
"*",
"Result",
",",
"error",
")",
"{",
"obj",
",",
"err",
":=",
"c",
".",
"Request",
"(",
"\"",
"\"",
",",
"convertParamToMap",
... | // Deletes an ggress firewall rule | [
"Deletes",
"an",
"ggress",
"firewall",
"rule"
] | 81da56f938156dd18edfce7a3ff15c0f77b47bfb | https://github.com/atsaki/golang-cloudstack-library/blob/81da56f938156dd18edfce7a3ff15c0f77b47bfb/FirewallApi.go#L16-L22 |
153,871 | atsaki/golang-cloudstack-library | FirewallApi.go | CreateFirewallRule | func (c *Client) CreateFirewallRule(p *CreateFirewallRuleParameter) (*FirewallRule, error) {
obj, err := c.Request("createFirewallRule", convertParamToMap(p))
if err != nil {
return nil, err
}
return obj.(*FirewallRule), err
} | go | func (c *Client) CreateFirewallRule(p *CreateFirewallRuleParameter) (*FirewallRule, error) {
obj, err := c.Request("createFirewallRule", convertParamToMap(p))
if err != nil {
return nil, err
}
return obj.(*FirewallRule), err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"CreateFirewallRule",
"(",
"p",
"*",
"CreateFirewallRuleParameter",
")",
"(",
"*",
"FirewallRule",
",",
"error",
")",
"{",
"obj",
",",
"err",
":=",
"c",
".",
"Request",
"(",
"\"",
"\"",
",",
"convertParamToMap",
"(",... | // Creates a firewall rule for a given ip address | [
"Creates",
"a",
"firewall",
"rule",
"for",
"a",
"given",
"ip",
"address"
] | 81da56f938156dd18edfce7a3ff15c0f77b47bfb | https://github.com/atsaki/golang-cloudstack-library/blob/81da56f938156dd18edfce7a3ff15c0f77b47bfb/FirewallApi.go#L369-L375 |
153,872 | atsaki/golang-cloudstack-library | FirewallApi.go | ListEgressFirewallRules | func (c *Client) ListEgressFirewallRules(p *ListEgressFirewallRulesParameter) ([]*FirewallRule, error) {
obj, err := c.Request("listEgressFirewallRules", convertParamToMap(p))
if err != nil {
return nil, err
}
return obj.([]*FirewallRule), err
} | go | func (c *Client) ListEgressFirewallRules(p *ListEgressFirewallRulesParameter) ([]*FirewallRule, error) {
obj, err := c.Request("listEgressFirewallRules", convertParamToMap(p))
if err != nil {
return nil, err
}
return obj.([]*FirewallRule), err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"ListEgressFirewallRules",
"(",
"p",
"*",
"ListEgressFirewallRulesParameter",
")",
"(",
"[",
"]",
"*",
"FirewallRule",
",",
"error",
")",
"{",
"obj",
",",
"err",
":=",
"c",
".",
"Request",
"(",
"\"",
"\"",
",",
"co... | // Lists all egress firewall rules for network id. | [
"Lists",
"all",
"egress",
"firewall",
"rules",
"for",
"network",
"id",
"."
] | 81da56f938156dd18edfce7a3ff15c0f77b47bfb | https://github.com/atsaki/golang-cloudstack-library/blob/81da56f938156dd18edfce7a3ff15c0f77b47bfb/FirewallApi.go#L415-L421 |
153,873 | gyuho/dataframe | sorter.go | SortBy | func SortBy(rows [][]string, lesses ...LessFunc) *MultiSorter {
return &MultiSorter{
data: rows,
less: lesses,
}
} | go | func SortBy(rows [][]string, lesses ...LessFunc) *MultiSorter {
return &MultiSorter{
data: rows,
less: lesses,
}
} | [
"func",
"SortBy",
"(",
"rows",
"[",
"]",
"[",
"]",
"string",
",",
"lesses",
"...",
"LessFunc",
")",
"*",
"MultiSorter",
"{",
"return",
"&",
"MultiSorter",
"{",
"data",
":",
"rows",
",",
"less",
":",
"lesses",
",",
"}",
"\n",
"}"
] | // SortBy returns a multiSorter that sorts using the less functions | [
"SortBy",
"returns",
"a",
"multiSorter",
"that",
"sorts",
"using",
"the",
"less",
"functions"
] | 008fc241adc41d4bd5c54b9f6564ef16407c030e | https://github.com/gyuho/dataframe/blob/008fc241adc41d4bd5c54b9f6564ef16407c030e/sorter.go#L26-L31 |
153,874 | megamsys/libgo | writer/writer.go | Write | func (w *LogWriter) Write(data []byte) (int, error) {
if w.msgCh == nil {
return len(data), w.write(data)
}
copied := make([]byte, len(data))
copy(copied, data)
w.msgCh <- copied
return len(data), nil
} | go | func (w *LogWriter) Write(data []byte) (int, error) {
if w.msgCh == nil {
return len(data), w.write(data)
}
copied := make([]byte, len(data))
copy(copied, data)
w.msgCh <- copied
return len(data), nil
} | [
"func",
"(",
"w",
"*",
"LogWriter",
")",
"Write",
"(",
"data",
"[",
"]",
"byte",
")",
"(",
"int",
",",
"error",
")",
"{",
"if",
"w",
".",
"msgCh",
"==",
"nil",
"{",
"return",
"len",
"(",
"data",
")",
",",
"w",
".",
"write",
"(",
"data",
")",
... | // Write writes and logs the data. | [
"Write",
"writes",
"and",
"logs",
"the",
"data",
"."
] | 101454b20f1af0541edb9391c75724e6c0143562 | https://github.com/megamsys/libgo/blob/101454b20f1af0541edb9391c75724e6c0143562/writer/writer.go#L60-L68 |
153,875 | atsaki/golang-cloudstack-library | ImageStoreApi.go | DeleteImageStore | func (c *Client) DeleteImageStore(p *DeleteImageStoreParameter) (*Result, error) {
obj, err := c.Request("deleteImageStore", convertParamToMap(p))
if err != nil {
return nil, err
}
return obj.(*Result), err
} | go | func (c *Client) DeleteImageStore(p *DeleteImageStoreParameter) (*Result, error) {
obj, err := c.Request("deleteImageStore", convertParamToMap(p))
if err != nil {
return nil, err
}
return obj.(*Result), err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DeleteImageStore",
"(",
"p",
"*",
"DeleteImageStoreParameter",
")",
"(",
"*",
"Result",
",",
"error",
")",
"{",
"obj",
",",
"err",
":=",
"c",
".",
"Request",
"(",
"\"",
"\"",
",",
"convertParamToMap",
"(",
"p",
... | // Deletes an image store . | [
"Deletes",
"an",
"image",
"store",
"."
] | 81da56f938156dd18edfce7a3ff15c0f77b47bfb | https://github.com/atsaki/golang-cloudstack-library/blob/81da56f938156dd18edfce7a3ff15c0f77b47bfb/ImageStoreApi.go#L211-L217 |
153,876 | megamsys/libgo | api/clients.go | validateVersion | func validateVersion(supported, current string) bool {
var (
bigger bool
limit int
)
if supported == "" {
return true
}
partsSupported := strings.Split(supported, ".")
partsCurrent := strings.Split(current, ".")
if len(partsSupported) > len(partsCurrent) {
limit = len(partsCurrent)
bigger = true
} else {
limit = len(partsSupported)
}
for i := 0; i < limit; i++ {
current, err := strconv.Atoi(partsCurrent[i])
if err != nil {
return false
}
supported, err := strconv.Atoi(partsSupported[i])
if err != nil {
return false
}
if current < supported {
return false
}
if current > supported {
return true
}
}
if bigger {
return false
}
return true
} | go | func validateVersion(supported, current string) bool {
var (
bigger bool
limit int
)
if supported == "" {
return true
}
partsSupported := strings.Split(supported, ".")
partsCurrent := strings.Split(current, ".")
if len(partsSupported) > len(partsCurrent) {
limit = len(partsCurrent)
bigger = true
} else {
limit = len(partsSupported)
}
for i := 0; i < limit; i++ {
current, err := strconv.Atoi(partsCurrent[i])
if err != nil {
return false
}
supported, err := strconv.Atoi(partsSupported[i])
if err != nil {
return false
}
if current < supported {
return false
}
if current > supported {
return true
}
}
if bigger {
return false
}
return true
} | [
"func",
"validateVersion",
"(",
"supported",
",",
"current",
"string",
")",
"bool",
"{",
"var",
"(",
"bigger",
"bool",
"\n",
"limit",
"int",
"\n",
")",
"\n",
"if",
"supported",
"==",
"\"",
"\"",
"{",
"return",
"true",
"\n",
"}",
"\n",
"partsSupported",
... | // validateVersion checks whether current version is greater or equal to
// supported version. | [
"validateVersion",
"checks",
"whether",
"current",
"version",
"is",
"greater",
"or",
"equal",
"to",
"supported",
"version",
"."
] | 101454b20f1af0541edb9391c75724e6c0143562 | https://github.com/megamsys/libgo/blob/101454b20f1af0541edb9391c75724e6c0143562/api/clients.go#L82-L118 |
153,877 | megamsys/libgo | events/handler.go | NewEventManager | func NewEventManager(storagePolicy StoragePolicy) *events {
return &events{
eventStore: make(map[EventType]*utils.TimedStore, 0),
watchers: make(map[int]*watch),
storagePolicy: storagePolicy,
}
} | go | func NewEventManager(storagePolicy StoragePolicy) *events {
return &events{
eventStore: make(map[EventType]*utils.TimedStore, 0),
watchers: make(map[int]*watch),
storagePolicy: storagePolicy,
}
} | [
"func",
"NewEventManager",
"(",
"storagePolicy",
"StoragePolicy",
")",
"*",
"events",
"{",
"return",
"&",
"events",
"{",
"eventStore",
":",
"make",
"(",
"map",
"[",
"EventType",
"]",
"*",
"utils",
".",
"TimedStore",
",",
"0",
")",
",",
"watchers",
":",
"... | // returns a pointer to an initialized Events object. | [
"returns",
"a",
"pointer",
"to",
"an",
"initialized",
"Events",
"object",
"."
] | 101454b20f1af0541edb9391c75724e6c0143562 | https://github.com/megamsys/libgo/blob/101454b20f1af0541edb9391c75724e6c0143562/events/handler.go#L121-L127 |
153,878 | megamsys/libgo | events/handler.go | NewRequest | func NewRequest(opts *eventReqOpts) *Request {
return &Request{
EventType: map[EventType]bool{opts.etype: true},
maxEventsReturned: 10,
}
} | go | func NewRequest(opts *eventReqOpts) *Request {
return &Request{
EventType: map[EventType]bool{opts.etype: true},
maxEventsReturned: 10,
}
} | [
"func",
"NewRequest",
"(",
"opts",
"*",
"eventReqOpts",
")",
"*",
"Request",
"{",
"return",
"&",
"Request",
"{",
"EventType",
":",
"map",
"[",
"EventType",
"]",
"bool",
"{",
"opts",
".",
"etype",
":",
"true",
"}",
",",
"maxEventsReturned",
":",
"10",
"... | // returns a pointer to an initialized Request object | [
"returns",
"a",
"pointer",
"to",
"an",
"initialized",
"Request",
"object"
] | 101454b20f1af0541edb9391c75724e6c0143562 | https://github.com/megamsys/libgo/blob/101454b20f1af0541edb9391c75724e6c0143562/events/handler.go#L130-L135 |
153,879 | megamsys/libgo | events/handler.go | newWatch | func newWatch(request *Request, eventChannel *EventChannel) *watch {
return &watch{
request: request,
eventChannel: eventChannel,
}
} | go | func newWatch(request *Request, eventChannel *EventChannel) *watch {
return &watch{
request: request,
eventChannel: eventChannel,
}
} | [
"func",
"newWatch",
"(",
"request",
"*",
"Request",
",",
"eventChannel",
"*",
"EventChannel",
")",
"*",
"watch",
"{",
"return",
"&",
"watch",
"{",
"request",
":",
"request",
",",
"eventChannel",
":",
"eventChannel",
",",
"}",
"\n",
"}"
] | // returns a pointer to an initialized watch object | [
"returns",
"a",
"pointer",
"to",
"an",
"initialized",
"watch",
"object"
] | 101454b20f1af0541edb9391c75724e6c0143562 | https://github.com/megamsys/libgo/blob/101454b20f1af0541edb9391c75724e6c0143562/events/handler.go#L138-L143 |
153,880 | megamsys/libgo | events/handler.go | getMaxEventsReturned | func getMaxEventsReturned(request *Request, eSlice []*Event) []*Event {
sort.Sort(byTimestamp(eSlice))
n := request.maxEventsReturned
if n >= len(eSlice) || n <= 0 {
return eSlice
}
return eSlice[len(eSlice)-n:]
} | go | func getMaxEventsReturned(request *Request, eSlice []*Event) []*Event {
sort.Sort(byTimestamp(eSlice))
n := request.maxEventsReturned
if n >= len(eSlice) || n <= 0 {
return eSlice
}
return eSlice[len(eSlice)-n:]
} | [
"func",
"getMaxEventsReturned",
"(",
"request",
"*",
"Request",
",",
"eSlice",
"[",
"]",
"*",
"Event",
")",
"[",
"]",
"*",
"Event",
"{",
"sort",
".",
"Sort",
"(",
"byTimestamp",
"(",
"eSlice",
")",
")",
"\n",
"n",
":=",
"request",
".",
"maxEventsReturn... | // sorts and returns up to the last MaxEventsReturned chronological elements | [
"sorts",
"and",
"returns",
"up",
"to",
"the",
"last",
"MaxEventsReturned",
"chronological",
"elements"
] | 101454b20f1af0541edb9391c75724e6c0143562 | https://github.com/megamsys/libgo/blob/101454b20f1af0541edb9391c75724e6c0143562/events/handler.go#L154-L161 |
153,881 | megamsys/libgo | events/handler.go | checkIfEventSatisfiesRequest | func checkIfEventSatisfiesRequest(request *Request, event *Event) bool {
startTime := request.StartTime
endTime := request.EndTime
eventTime := event.Timestamp
if !startTime.IsZero() {
if startTime.After(eventTime) {
return false
}
}
if !endTime.IsZero() {
if endTime.Before(eventTime) {
return false
}
}
if !request.EventType[event.EventType] {
return false
}
return true
} | go | func checkIfEventSatisfiesRequest(request *Request, event *Event) bool {
startTime := request.StartTime
endTime := request.EndTime
eventTime := event.Timestamp
if !startTime.IsZero() {
if startTime.After(eventTime) {
return false
}
}
if !endTime.IsZero() {
if endTime.Before(eventTime) {
return false
}
}
if !request.EventType[event.EventType] {
return false
}
return true
} | [
"func",
"checkIfEventSatisfiesRequest",
"(",
"request",
"*",
"Request",
",",
"event",
"*",
"Event",
")",
"bool",
"{",
"startTime",
":=",
"request",
".",
"StartTime",
"\n",
"endTime",
":=",
"request",
".",
"EndTime",
"\n",
"eventTime",
":=",
"event",
".",
"Ti... | // determines if an event occurs within the time set in the request object and is the right type | [
"determines",
"if",
"an",
"event",
"occurs",
"within",
"the",
"time",
"set",
"in",
"the",
"request",
"object",
"and",
"is",
"the",
"right",
"type"
] | 101454b20f1af0541edb9391c75724e6c0143562 | https://github.com/megamsys/libgo/blob/101454b20f1af0541edb9391c75724e6c0143562/events/handler.go#L164-L182 |
153,882 | megamsys/libgo | events/handler.go | updateEventStore | func (self *events) updateEventStore(e *Event) {
self.eventsLock.Lock()
defer self.eventsLock.Unlock()
if _, ok := self.eventStore[e.EventType]; !ok {
maxAge := self.storagePolicy.DefaultMaxAge
maxNumEvents := self.storagePolicy.DefaultMaxNumEvents
if age, ok := self.storagePolicy.PerTypeMaxAge[e.EventType]; ok {
maxAge = age
}
if numEvents, ok := self.storagePolicy.PerTypeMaxNumEvents[e.EventType]; ok {
maxNumEvents = numEvents
}
self.eventStore[e.EventType] = utils.NewTimedStore(maxAge, maxNumEvents)
}
self.eventStore[e.EventType].Add(e.Timestamp, e)
} | go | func (self *events) updateEventStore(e *Event) {
self.eventsLock.Lock()
defer self.eventsLock.Unlock()
if _, ok := self.eventStore[e.EventType]; !ok {
maxAge := self.storagePolicy.DefaultMaxAge
maxNumEvents := self.storagePolicy.DefaultMaxNumEvents
if age, ok := self.storagePolicy.PerTypeMaxAge[e.EventType]; ok {
maxAge = age
}
if numEvents, ok := self.storagePolicy.PerTypeMaxNumEvents[e.EventType]; ok {
maxNumEvents = numEvents
}
self.eventStore[e.EventType] = utils.NewTimedStore(maxAge, maxNumEvents)
}
self.eventStore[e.EventType].Add(e.Timestamp, e)
} | [
"func",
"(",
"self",
"*",
"events",
")",
"updateEventStore",
"(",
"e",
"*",
"Event",
")",
"{",
"self",
".",
"eventsLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"self",
".",
"eventsLock",
".",
"Unlock",
"(",
")",
"\n",
"if",
"_",
",",
"ok",
":=",
... | // helper function to update the event manager's eventStore | [
"helper",
"function",
"to",
"update",
"the",
"event",
"manager",
"s",
"eventStore"
] | 101454b20f1af0541edb9391c75724e6c0143562 | https://github.com/megamsys/libgo/blob/101454b20f1af0541edb9391c75724e6c0143562/events/handler.go#L235-L251 |
153,883 | megamsys/libgo | events/handler.go | AddEvent | func (self *events) AddEvent(e *Event) error {
self.updateEventStore(e)
self.watcherLock.RLock()
defer self.watcherLock.RUnlock()
watchesToSend := self.findValidWatchers(e)
for _, watchObject := range watchesToSend {
watchObject.eventChannel.GetChannel() <- e
}
log.Infof("WRIT %s %s", e.EventType, e.EventAction.String())
return nil
} | go | func (self *events) AddEvent(e *Event) error {
self.updateEventStore(e)
self.watcherLock.RLock()
defer self.watcherLock.RUnlock()
watchesToSend := self.findValidWatchers(e)
for _, watchObject := range watchesToSend {
watchObject.eventChannel.GetChannel() <- e
}
log.Infof("WRIT %s %s", e.EventType, e.EventAction.String())
return nil
} | [
"func",
"(",
"self",
"*",
"events",
")",
"AddEvent",
"(",
"e",
"*",
"Event",
")",
"error",
"{",
"self",
".",
"updateEventStore",
"(",
"e",
")",
"\n",
"self",
".",
"watcherLock",
".",
"RLock",
"(",
")",
"\n",
"defer",
"self",
".",
"watcherLock",
".",
... | // method of Events object that adds the argument Event object to the
// eventStore. It also feeds the event to a set of watch channels
// held by the manager if it satisfies the request keys of the channels | [
"method",
"of",
"Events",
"object",
"that",
"adds",
"the",
"argument",
"Event",
"object",
"to",
"the",
"eventStore",
".",
"It",
"also",
"feeds",
"the",
"event",
"to",
"a",
"set",
"of",
"watch",
"channels",
"held",
"by",
"the",
"manager",
"if",
"it",
"sat... | 101454b20f1af0541edb9391c75724e6c0143562 | https://github.com/megamsys/libgo/blob/101454b20f1af0541edb9391c75724e6c0143562/events/handler.go#L267-L277 |
153,884 | megamsys/libgo | events/handler.go | StopWatch | func (self *events) StopWatch(watchId int) {
self.watcherLock.Lock()
defer self.watcherLock.Unlock()
_, ok := self.watchers[watchId]
if !ok {
log.Errorf("Could not find watcher instance %v", watchId)
}
close(self.watchers[watchId].eventChannel.GetChannel())
delete(self.watchers, watchId)
} | go | func (self *events) StopWatch(watchId int) {
self.watcherLock.Lock()
defer self.watcherLock.Unlock()
_, ok := self.watchers[watchId]
if !ok {
log.Errorf("Could not find watcher instance %v", watchId)
}
close(self.watchers[watchId].eventChannel.GetChannel())
delete(self.watchers, watchId)
} | [
"func",
"(",
"self",
"*",
"events",
")",
"StopWatch",
"(",
"watchId",
"int",
")",
"{",
"self",
".",
"watcherLock",
".",
"Lock",
"(",
")",
"\n",
"defer",
"self",
".",
"watcherLock",
".",
"Unlock",
"(",
")",
"\n",
"_",
",",
"ok",
":=",
"self",
".",
... | // Removes a watch instance from the EventManager's watchers map | [
"Removes",
"a",
"watch",
"instance",
"from",
"the",
"EventManager",
"s",
"watchers",
"map"
] | 101454b20f1af0541edb9391c75724e6c0143562 | https://github.com/megamsys/libgo/blob/101454b20f1af0541edb9391c75724e6c0143562/events/handler.go#L280-L289 |
153,885 | uhoh-itsmaciek/femebe | codec/codec.go | GuessOids | func GuessOids(rows [][]interface{}) (oids []proto.Oid) {
if len(rows) == 0 {
// can't really make much of a guess here
return []proto.Oid{}
}
oids = make([]proto.Oid, len(rows[0]))
for _, row := range rows {
gotAll := true
for i := range oids {
if o := oids[i]; o == 0 || o == proto.OidUnknown {
oids[i] = MappedOid(row[i])
if oids[i] == proto.OidUnknown {
gotAll = false
}
}
}
if gotAll {
break
}
}
return oids
} | go | func GuessOids(rows [][]interface{}) (oids []proto.Oid) {
if len(rows) == 0 {
// can't really make much of a guess here
return []proto.Oid{}
}
oids = make([]proto.Oid, len(rows[0]))
for _, row := range rows {
gotAll := true
for i := range oids {
if o := oids[i]; o == 0 || o == proto.OidUnknown {
oids[i] = MappedOid(row[i])
if oids[i] == proto.OidUnknown {
gotAll = false
}
}
}
if gotAll {
break
}
}
return oids
} | [
"func",
"GuessOids",
"(",
"rows",
"[",
"]",
"[",
"]",
"interface",
"{",
"}",
")",
"(",
"oids",
"[",
"]",
"proto",
".",
"Oid",
")",
"{",
"if",
"len",
"(",
"rows",
")",
"==",
"0",
"{",
"// can't really make much of a guess here",
"return",
"[",
"]",
"p... | // GuessOids attemps to guess the Postgres oids for the given data
// values. It assumes that rows is a slice of uniform-length slices
// where each cell corresponds to a column. It returns a slice of oid
// values of the mapped oids, or OID_UNKNOWN where no mapping could
// be determined. | [
"GuessOids",
"attemps",
"to",
"guess",
"the",
"Postgres",
"oids",
"for",
"the",
"given",
"data",
"values",
".",
"It",
"assumes",
"that",
"rows",
"is",
"a",
"slice",
"of",
"uniform",
"-",
"length",
"slices",
"where",
"each",
"cell",
"corresponds",
"to",
"a"... | 78f00f2ef7b41255fe56120e95887461adb2aa38 | https://github.com/uhoh-itsmaciek/femebe/blob/78f00f2ef7b41255fe56120e95887461adb2aa38/codec/codec.go#L12-L33 |
153,886 | uhoh-itsmaciek/femebe | codec/codec.go | MappedOid | func MappedOid(val interface{}) proto.Oid {
switch val.(type) {
case nil:
// we can't determine a type here
return proto.OidUnknown
case int16:
return proto.OidInt2
case int32:
return proto.OidInt4
case int64:
return proto.OidInt8
case float32:
return proto.OidFloat4
case float64:
return proto.OidFloat8
case string:
return proto.OidText
case bool:
return proto.OidBool
default:
return proto.OidUnknown
}
} | go | func MappedOid(val interface{}) proto.Oid {
switch val.(type) {
case nil:
// we can't determine a type here
return proto.OidUnknown
case int16:
return proto.OidInt2
case int32:
return proto.OidInt4
case int64:
return proto.OidInt8
case float32:
return proto.OidFloat4
case float64:
return proto.OidFloat8
case string:
return proto.OidText
case bool:
return proto.OidBool
default:
return proto.OidUnknown
}
} | [
"func",
"MappedOid",
"(",
"val",
"interface",
"{",
"}",
")",
"proto",
".",
"Oid",
"{",
"switch",
"val",
".",
"(",
"type",
")",
"{",
"case",
"nil",
":",
"// we can't determine a type here",
"return",
"proto",
".",
"OidUnknown",
"\n",
"case",
"int16",
":",
... | // Mappedproto.Oid returns the Postgres oid mapped to the type of the given
// value in femebe, or OID_UNKNOWN if no mapping exists. | [
"Mappedproto",
".",
"Oid",
"returns",
"the",
"Postgres",
"oid",
"mapped",
"to",
"the",
"type",
"of",
"the",
"given",
"value",
"in",
"femebe",
"or",
"OID_UNKNOWN",
"if",
"no",
"mapping",
"exists",
"."
] | 78f00f2ef7b41255fe56120e95887461adb2aa38 | https://github.com/uhoh-itsmaciek/femebe/blob/78f00f2ef7b41255fe56120e95887461adb2aa38/codec/codec.go#L37-L59 |
153,887 | c4milo/handlers | grpcutil/cmd/example.go | Hola | func (s *Service) Hola(ctx context.Context, r *grpcutil.HolaRequest) (*grpcutil.HolaResponse, error) {
return &grpcutil.HolaResponse{Greeting: "Hola from gRPC service!"}, nil
} | go | func (s *Service) Hola(ctx context.Context, r *grpcutil.HolaRequest) (*grpcutil.HolaResponse, error) {
return &grpcutil.HolaResponse{Greeting: "Hola from gRPC service!"}, nil
} | [
"func",
"(",
"s",
"*",
"Service",
")",
"Hola",
"(",
"ctx",
"context",
".",
"Context",
",",
"r",
"*",
"grpcutil",
".",
"HolaRequest",
")",
"(",
"*",
"grpcutil",
".",
"HolaResponse",
",",
"error",
")",
"{",
"return",
"&",
"grpcutil",
".",
"HolaResponse",... | // Hola prints greeting message | [
"Hola",
"prints",
"greeting",
"message"
] | ea1b5d30c5ba55fdc1d737d0222daccb3d98d057 | https://github.com/c4milo/handlers/blob/ea1b5d30c5ba55fdc1d737d0222daccb3d98d057/grpcutil/cmd/example.go#L55-L57 |
153,888 | megamsys/libgo | events/bills/billers.go | Provider | func Provider(providerName string) BillProvider {
if _, ok := BillProviders[providerName]; !ok {
providerName = "nop"
}
return BillProviders[providerName]
} | go | func Provider(providerName string) BillProvider {
if _, ok := BillProviders[providerName]; !ok {
providerName = "nop"
}
return BillProviders[providerName]
} | [
"func",
"Provider",
"(",
"providerName",
"string",
")",
"BillProvider",
"{",
"if",
"_",
",",
"ok",
":=",
"BillProviders",
"[",
"providerName",
"]",
";",
"!",
"ok",
"{",
"providerName",
"=",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"BillProviders",
"[",
"pr... | // Provider returns the current configured manager, as defined in the
// configuration file. | [
"Provider",
"returns",
"the",
"current",
"configured",
"manager",
"as",
"defined",
"in",
"the",
"configuration",
"file",
"."
] | 101454b20f1af0541edb9391c75724e6c0143562 | https://github.com/megamsys/libgo/blob/101454b20f1af0541edb9391c75724e6c0143562/events/bills/billers.go#L48-L53 |
153,889 | megamsys/libgo | events/bills/billers.go | Register | func Register(name string, provider BillProvider) {
if BillProviders == nil {
BillProviders = make(map[string]BillProvider)
}
BillProviders[name] = provider
} | go | func Register(name string, provider BillProvider) {
if BillProviders == nil {
BillProviders = make(map[string]BillProvider)
}
BillProviders[name] = provider
} | [
"func",
"Register",
"(",
"name",
"string",
",",
"provider",
"BillProvider",
")",
"{",
"if",
"BillProviders",
"==",
"nil",
"{",
"BillProviders",
"=",
"make",
"(",
"map",
"[",
"string",
"]",
"BillProvider",
")",
"\n",
"}",
"\n",
"BillProviders",
"[",
"name",... | // Register registers a new billing provider, that can be later configured
// and used. | [
"Register",
"registers",
"a",
"new",
"billing",
"provider",
"that",
"can",
"be",
"later",
"configured",
"and",
"used",
"."
] | 101454b20f1af0541edb9391c75724e6c0143562 | https://github.com/megamsys/libgo/blob/101454b20f1af0541edb9391c75724e6c0143562/events/bills/billers.go#L57-L62 |
153,890 | acoshift/middleware | header.go | AddHeader | func AddHeader(key, value string) Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
addHeaderIfNotExists(w.Header(), key, value)
h.ServeHTTP(w, r)
})
}
} | go | func AddHeader(key, value string) Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
addHeaderIfNotExists(w.Header(), key, value)
h.ServeHTTP(w, r)
})
}
} | [
"func",
"AddHeader",
"(",
"key",
",",
"value",
"string",
")",
"Middleware",
"{",
"return",
"func",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWr... | // AddHeader creates new middleware that adds a header to response | [
"AddHeader",
"creates",
"new",
"middleware",
"that",
"adds",
"a",
"header",
"to",
"response"
] | 72ef9c385871dd1964bcdf6170ce9aefeff90fd8 | https://github.com/acoshift/middleware/blob/72ef9c385871dd1964bcdf6170ce9aefeff90fd8/header.go#L6-L13 |
153,891 | megamsys/libgo | hc/healthchecker.go | AddChecker | func AddChecker(name string, check func() (interface{}, error)) {
checker := healthChecker{name: name, check: check}
checkers = append(checkers, checker)
} | go | func AddChecker(name string, check func() (interface{}, error)) {
checker := healthChecker{name: name, check: check}
checkers = append(checkers, checker)
} | [
"func",
"AddChecker",
"(",
"name",
"string",
",",
"check",
"func",
"(",
")",
"(",
"interface",
"{",
"}",
",",
"error",
")",
")",
"{",
"checker",
":=",
"healthChecker",
"{",
"name",
":",
"name",
",",
"check",
":",
"check",
"}",
"\n",
"checkers",
"=",
... | // AddChecker adds a new checker to the internal list of checkers. Checkers
// added to this list can then be checked using the Check function. | [
"AddChecker",
"adds",
"a",
"new",
"checker",
"to",
"the",
"internal",
"list",
"of",
"checkers",
".",
"Checkers",
"added",
"to",
"this",
"list",
"can",
"then",
"be",
"checked",
"using",
"the",
"Check",
"function",
"."
] | 101454b20f1af0541edb9391c75724e6c0143562 | https://github.com/megamsys/libgo/blob/101454b20f1af0541edb9391c75724e6c0143562/hc/healthchecker.go#L39-L42 |
153,892 | megamsys/libgo | hc/healthchecker.go | Check | func Check() []Result {
results := make([]Result, 0, len(checkers))
for _, checker := range checkers {
startTime := time.Now()
if raw, err := checker.check(); err != nil && err != ErrDisabledComponent {
results = append(results, Result{
Name: checker.name,
Raw: raw,
Status: "fail - " + err.Error(),
Duration: time.Now().Sub(startTime),
})
} else if err == nil {
results = append(results, Result{
Name: checker.name,
Raw: raw,
Status: HealthCheckOK,
Duration: time.Now().Sub(startTime),
})
}
}
return results
} | go | func Check() []Result {
results := make([]Result, 0, len(checkers))
for _, checker := range checkers {
startTime := time.Now()
if raw, err := checker.check(); err != nil && err != ErrDisabledComponent {
results = append(results, Result{
Name: checker.name,
Raw: raw,
Status: "fail - " + err.Error(),
Duration: time.Now().Sub(startTime),
})
} else if err == nil {
results = append(results, Result{
Name: checker.name,
Raw: raw,
Status: HealthCheckOK,
Duration: time.Now().Sub(startTime),
})
}
}
return results
} | [
"func",
"Check",
"(",
")",
"[",
"]",
"Result",
"{",
"results",
":=",
"make",
"(",
"[",
"]",
"Result",
",",
"0",
",",
"len",
"(",
"checkers",
")",
")",
"\n",
"for",
"_",
",",
"checker",
":=",
"range",
"checkers",
"{",
"startTime",
":=",
"time",
".... | // Check check the status of all registered checkers and return a list of
// results. | [
"Check",
"check",
"the",
"status",
"of",
"all",
"registered",
"checkers",
"and",
"return",
"a",
"list",
"of",
"results",
"."
] | 101454b20f1af0541edb9391c75724e6c0143562 | https://github.com/megamsys/libgo/blob/101454b20f1af0541edb9391c75724e6c0143562/hc/healthchecker.go#L46-L67 |
153,893 | megamsys/libgo | events/bill.go | transaction | func (self *Bill) transaction(evt *Event) error {
log.Infof("Event:BILL:transaction")
result := &bills.BillOpts{}
_ = result.FillStruct(evt.EventData.M) //we will manage error later
for k, bp := range bills.BillProviders {
if !self.skip(k) {
err := bp.Transaction(result, self.M)
if err != nil {
return err
}
}
}
return nil
} | go | func (self *Bill) transaction(evt *Event) error {
log.Infof("Event:BILL:transaction")
result := &bills.BillOpts{}
_ = result.FillStruct(evt.EventData.M) //we will manage error later
for k, bp := range bills.BillProviders {
if !self.skip(k) {
err := bp.Transaction(result, self.M)
if err != nil {
return err
}
}
}
return nil
} | [
"func",
"(",
"self",
"*",
"Bill",
")",
"transaction",
"(",
"evt",
"*",
"Event",
")",
"error",
"{",
"log",
".",
"Infof",
"(",
"\"",
"\"",
")",
"\n",
"result",
":=",
"&",
"bills",
".",
"BillOpts",
"{",
"}",
"\n",
"_",
"=",
"result",
".",
"FillStruc... | //transaction for all managers like whmcs and scylla | [
"transaction",
"for",
"all",
"managers",
"like",
"whmcs",
"and",
"scylla"
] | 101454b20f1af0541edb9391c75724e6c0143562 | https://github.com/megamsys/libgo/blob/101454b20f1af0541edb9391c75724e6c0143562/events/bill.go#L136-L149 |
153,894 | acoshift/middleware | redirect.go | NonWWWRedirect | func NonWWWRedirect() Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
host := strings.TrimPrefix(r.Host, "www.")
if len(host) < len(r.Host) {
http.Redirect(w, r, scheme(r)+"://"+host+r.RequestURI, http.StatusMovedPermanently)
return
}
h.ServeHTTP(w, r)
})
}
} | go | func NonWWWRedirect() Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
host := strings.TrimPrefix(r.Host, "www.")
if len(host) < len(r.Host) {
http.Redirect(w, r, scheme(r)+"://"+host+r.RequestURI, http.StatusMovedPermanently)
return
}
h.ServeHTTP(w, r)
})
}
} | [
"func",
"NonWWWRedirect",
"(",
")",
"Middleware",
"{",
"return",
"func",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"htt... | // NonWWWRedirect redirects www to non-www | [
"NonWWWRedirect",
"redirects",
"www",
"to",
"non",
"-",
"www"
] | 72ef9c385871dd1964bcdf6170ce9aefeff90fd8 | https://github.com/acoshift/middleware/blob/72ef9c385871dd1964bcdf6170ce9aefeff90fd8/redirect.go#L9-L20 |
153,895 | acoshift/middleware | redirect.go | WWWRedirect | func WWWRedirect() Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !strings.HasPrefix(r.Host, "www.") {
http.Redirect(w, r, scheme(r)+"://www."+r.Host+r.RequestURI, http.StatusMovedPermanently)
return
}
h.ServeHTTP(w, r)
})
}
} | go | func WWWRedirect() Middleware {
return func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !strings.HasPrefix(r.Host, "www.") {
http.Redirect(w, r, scheme(r)+"://www."+r.Host+r.RequestURI, http.StatusMovedPermanently)
return
}
h.ServeHTTP(w, r)
})
}
} | [
"func",
"WWWRedirect",
"(",
")",
"Middleware",
"{",
"return",
"func",
"(",
"h",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"HandlerFunc",
"(",
"func",
"(",
"w",
"http",
".",
"ResponseWriter",
",",
"r",
"*",
"http",... | // WWWRedirect redirects non-www to www | [
"WWWRedirect",
"redirects",
"non",
"-",
"www",
"to",
"www"
] | 72ef9c385871dd1964bcdf6170ce9aefeff90fd8 | https://github.com/acoshift/middleware/blob/72ef9c385871dd1964bcdf6170ce9aefeff90fd8/redirect.go#L23-L33 |
153,896 | atsaki/golang-cloudstack-library | AddressApi.go | UpdateIpAddress | func (c *Client) UpdateIpAddress(p *UpdateIpAddressParameter) (*PublicIpAddress, error) {
obj, err := c.Request("updateIpAddress", convertParamToMap(p))
if err != nil {
return nil, err
}
return obj.(*PublicIpAddress), err
} | go | func (c *Client) UpdateIpAddress(p *UpdateIpAddressParameter) (*PublicIpAddress, error) {
obj, err := c.Request("updateIpAddress", convertParamToMap(p))
if err != nil {
return nil, err
}
return obj.(*PublicIpAddress), err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"UpdateIpAddress",
"(",
"p",
"*",
"UpdateIpAddressParameter",
")",
"(",
"*",
"PublicIpAddress",
",",
"error",
")",
"{",
"obj",
",",
"err",
":=",
"c",
".",
"Request",
"(",
"\"",
"\"",
",",
"convertParamToMap",
"(",
... | // Updates an ip address | [
"Updates",
"an",
"ip",
"address"
] | 81da56f938156dd18edfce7a3ff15c0f77b47bfb | https://github.com/atsaki/golang-cloudstack-library/blob/81da56f938156dd18edfce7a3ff15c0f77b47bfb/AddressApi.go#L87-L93 |
153,897 | atsaki/golang-cloudstack-library | AddressApi.go | DisassociateIpAddress | func (c *Client) DisassociateIpAddress(p *DisassociateIpAddressParameter) (*Result, error) {
obj, err := c.Request("disassociateIpAddress", convertParamToMap(p))
if err != nil {
return nil, err
}
return obj.(*Result), err
} | go | func (c *Client) DisassociateIpAddress(p *DisassociateIpAddressParameter) (*Result, error) {
obj, err := c.Request("disassociateIpAddress", convertParamToMap(p))
if err != nil {
return nil, err
}
return obj.(*Result), err
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"DisassociateIpAddress",
"(",
"p",
"*",
"DisassociateIpAddressParameter",
")",
"(",
"*",
"Result",
",",
"error",
")",
"{",
"obj",
",",
"err",
":=",
"c",
".",
"Request",
"(",
"\"",
"\"",
",",
"convertParamToMap",
"(",... | // Disassociates an ip address from the account. | [
"Disassociates",
"an",
"ip",
"address",
"from",
"the",
"account",
"."
] | 81da56f938156dd18edfce7a3ff15c0f77b47bfb | https://github.com/atsaki/golang-cloudstack-library/blob/81da56f938156dd18edfce7a3ff15c0f77b47bfb/AddressApi.go#L108-L114 |
153,898 | uhoh-itsmaciek/femebe | util/util.go | ErrToChannel | func ErrToChannel(fn func() error, ch chan<- error) {
var err error
for err = fn(); err == nil; err = fn() {
}
ch <- err
} | go | func ErrToChannel(fn func() error, ch chan<- error) {
var err error
for err = fn(); err == nil; err = fn() {
}
ch <- err
} | [
"func",
"ErrToChannel",
"(",
"fn",
"func",
"(",
")",
"error",
",",
"ch",
"chan",
"<-",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"for",
"err",
"=",
"fn",
"(",
")",
";",
"err",
"==",
"nil",
";",
"err",
"=",
"fn",
"(",
")",
"{",
"}",
"\n"... | // Call fn repeatedly until an error is returned; then send the error
// on the given channel and return | [
"Call",
"fn",
"repeatedly",
"until",
"an",
"error",
"is",
"returned",
";",
"then",
"send",
"the",
"error",
"on",
"the",
"given",
"channel",
"and",
"return"
] | 78f00f2ef7b41255fe56120e95887461adb2aa38 | https://github.com/uhoh-itsmaciek/femebe/blob/78f00f2ef7b41255fe56120e95887461adb2aa38/util/util.go#L14-L19 |
153,899 | uhoh-itsmaciek/femebe | util/util.go | AutoListen | func AutoListen(location string) (net.Listener, error) {
if strings.Contains(location, "/") {
return net.Listen("unix", location)
}
return net.Listen("tcp", location)
} | go | func AutoListen(location string) (net.Listener, error) {
if strings.Contains(location, "/") {
return net.Listen("unix", location)
}
return net.Listen("tcp", location)
} | [
"func",
"AutoListen",
"(",
"location",
"string",
")",
"(",
"net",
".",
"Listener",
",",
"error",
")",
"{",
"if",
"strings",
".",
"Contains",
"(",
"location",
",",
"\"",
"\"",
")",
"{",
"return",
"net",
".",
"Listen",
"(",
"\"",
"\"",
",",
"location",... | // Automatically chooses between unix sockets and tcp sockets for
// listening | [
"Automatically",
"chooses",
"between",
"unix",
"sockets",
"and",
"tcp",
"sockets",
"for",
"listening"
] | 78f00f2ef7b41255fe56120e95887461adb2aa38 | https://github.com/uhoh-itsmaciek/femebe/blob/78f00f2ef7b41255fe56120e95887461adb2aa38/util/util.go#L23-L28 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.