{"action":"created","comment":{"url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/pulls/comments/53301098","id":53301098,"diff_hunk":"@@ -177,4 +178,61 @@ func FromCompositionTags(object interface{}, current string, namespace *[]string\n \treturn FromMap(jmap, current, namespace)\n }\n \n-// TODO - Value getters (GetValueByTag, GetValueByNamespace etc)\n+// GetValueByNamespace returns value stored in struct composition.\n+// It requires filed tags on each struct field which may be represented as namespace component.\n+// It iterates over fields recursively, checks tags until it finds leaf value.\n+func GetValueByNamespace(object interface{}, ns []string) interface{} {\n+\t// current level of namespace\n+\tcurrent := ns[0]\n+\tfields, err := reflections.Fields(object)\n+\tif err != nil {\n+\t\tfmt.Printf(\"Could not return fields for object{%v}\\n\", object)\n+\t\treturn nil\n+\t}\n+\n+\tfor _, field := range fields {\n+\t\ttag, err := reflections.GetFieldTag(object, field, \"json\")\n+\t\tif err != nil {\n+\t\t\tfmt.Printf(\"Could not find tag for field{%s}\\n\", field)\n+\t\t\treturn nil\n+\t\t}\n+\t\t// remove omitempty from tag\n+\t\ttag = strings.Replace(tag, \",omitempty\", \"\", -1)\n+\t\tif tag == current {\n+\t\t\tval, _ := reflections.GetField(object, field)","path":"ns/namespace.go","position":34,"original_position":34,"commit_id":"c5f74b5960eead03d6e89bfd674071eb20d6060c","original_commit_id":"c5f74b5960eead03d6e89bfd674071eb20d6060c","user":{"login":"marcin-krolik","id":14905131,"avatar_url":"https://avatars.githubusercontent.com/u/14905131?v=3","gravatar_id":"","url":"https://api.github.com/users/marcin-krolik","html_url":"https://github.com/marcin-krolik","followers_url":"https://api.github.com/users/marcin-krolik/followers","following_url":"https://api.github.com/users/marcin-krolik/following{/other_user}","gists_url":"https://api.github.com/users/marcin-krolik/gists{/gist_id}","starred_url":"https://api.github.com/users/marcin-krolik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcin-krolik/subscriptions","organizations_url":"https://api.github.com/users/marcin-krolik/orgs","repos_url":"https://api.github.com/users/marcin-krolik/repos","events_url":"https://api.github.com/users/marcin-krolik/events{/privacy}","received_events_url":"https://api.github.com/users/marcin-krolik/received_events","type":"User","site_admin":false},"body":"Sure","created_at":"2016-02-18T11:17:43Z","updated_at":"2016-02-18T11:17:43Z","html_url":"https://github.com/intelsdi-x/snap-plugin-utilities/pull/8#discussion_r53301098","pull_request_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/pulls/8","_links":{"self":{"href":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/pulls/comments/53301098"},"html":{"href":"https://github.com/intelsdi-x/snap-plugin-utilities/pull/8#discussion_r53301098"},"pull_request":{"href":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/pulls/8"}}},"pull_request":{"url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/pulls/8","id":59705323,"html_url":"https://github.com/intelsdi-x/snap-plugin-utilities/pull/8","diff_url":"https://github.com/intelsdi-x/snap-plugin-utilities/pull/8.diff","patch_url":"https://github.com/intelsdi-x/snap-plugin-utilities/pull/8.patch","issue_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/issues/8","number":8,"state":"open","locked":false,"title":"Namespaces: GetValuebyNamespace","user":{"login":"marcin-krolik","id":14905131,"avatar_url":"https://avatars.githubusercontent.com/u/14905131?v=3","gravatar_id":"","url":"https://api.github.com/users/marcin-krolik","html_url":"https://github.com/marcin-krolik","followers_url":"https://api.github.com/users/marcin-krolik/followers","following_url":"https://api.github.com/users/marcin-krolik/following{/other_user}","gists_url":"https://api.github.com/users/marcin-krolik/gists{/gist_id}","starred_url":"https://api.github.com/users/marcin-krolik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcin-krolik/subscriptions","organizations_url":"https://api.github.com/users/marcin-krolik/orgs","repos_url":"https://api.github.com/users/marcin-krolik/repos","events_url":"https://api.github.com/users/marcin-krolik/events{/privacy}","received_events_url":"https://api.github.com/users/marcin-krolik/received_events","type":"User","site_admin":false},"body":"Added function which recursively looks for value represented in namespace in struct composition","created_at":"2016-02-17T20:41:02Z","updated_at":"2016-02-18T11:17:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4d186e3a6f3c1296c15baf582f28447d9bfd1aaf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/pulls/8/commits","review_comments_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/pulls/8/comments","review_comment_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/pulls/comments{/number}","comments_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/issues/8/comments","statuses_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/statuses/c5f74b5960eead03d6e89bfd674071eb20d6060c","head":{"label":"marcin-krolik:kromar-get-val","ref":"kromar-get-val","sha":"c5f74b5960eead03d6e89bfd674071eb20d6060c","user":{"login":"marcin-krolik","id":14905131,"avatar_url":"https://avatars.githubusercontent.com/u/14905131?v=3","gravatar_id":"","url":"https://api.github.com/users/marcin-krolik","html_url":"https://github.com/marcin-krolik","followers_url":"https://api.github.com/users/marcin-krolik/followers","following_url":"https://api.github.com/users/marcin-krolik/following{/other_user}","gists_url":"https://api.github.com/users/marcin-krolik/gists{/gist_id}","starred_url":"https://api.github.com/users/marcin-krolik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcin-krolik/subscriptions","organizations_url":"https://api.github.com/users/marcin-krolik/orgs","repos_url":"https://api.github.com/users/marcin-krolik/repos","events_url":"https://api.github.com/users/marcin-krolik/events{/privacy}","received_events_url":"https://api.github.com/users/marcin-krolik/received_events","type":"User","site_admin":false},"repo":{"id":48122441,"name":"snap-plugin-utilities","full_name":"marcin-krolik/snap-plugin-utilities","owner":{"login":"marcin-krolik","id":14905131,"avatar_url":"https://avatars.githubusercontent.com/u/14905131?v=3","gravatar_id":"","url":"https://api.github.com/users/marcin-krolik","html_url":"https://github.com/marcin-krolik","followers_url":"https://api.github.com/users/marcin-krolik/followers","following_url":"https://api.github.com/users/marcin-krolik/following{/other_user}","gists_url":"https://api.github.com/users/marcin-krolik/gists{/gist_id}","starred_url":"https://api.github.com/users/marcin-krolik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marcin-krolik/subscriptions","organizations_url":"https://api.github.com/users/marcin-krolik/orgs","repos_url":"https://api.github.com/users/marcin-krolik/repos","events_url":"https://api.github.com/users/marcin-krolik/events{/privacy}","received_events_url":"https://api.github.com/users/marcin-krolik/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/marcin-krolik/snap-plugin-utilities","description":"","fork":true,"url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities","forks_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/forks","keys_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/keys{/key_id}","collaborators_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/teams","hooks_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/hooks","issue_events_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/issues/events{/number}","events_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/events","assignees_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/assignees{/user}","branches_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/branches{/branch}","tags_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/tags","blobs_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/git/refs{/sha}","trees_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/git/trees{/sha}","statuses_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/statuses/{sha}","languages_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/languages","stargazers_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/stargazers","contributors_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/contributors","subscribers_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/subscribers","subscription_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/subscription","commits_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/commits{/sha}","git_commits_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/git/commits{/sha}","comments_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/comments{/number}","issue_comment_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/issues/comments{/number}","contents_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/contents/{+path}","compare_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/compare/{base}...{head}","merges_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/merges","archive_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/downloads","issues_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/issues{/number}","pulls_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/pulls{/number}","milestones_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/milestones{/number}","notifications_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/labels{/name}","releases_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/releases{/id}","deployments_url":"https://api.github.com/repos/marcin-krolik/snap-plugin-utilities/deployments","created_at":"2015-12-16T16:39:00Z","updated_at":"2015-12-16T16:39:01Z","pushed_at":"2016-02-18T08:10:02Z","git_url":"git://github.com/marcin-krolik/snap-plugin-utilities.git","ssh_url":"git@github.com:marcin-krolik/snap-plugin-utilities.git","clone_url":"https://github.com/marcin-krolik/snap-plugin-utilities.git","svn_url":"https://github.com/marcin-krolik/snap-plugin-utilities","homepage":null,"size":47,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"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"}},"base":{"label":"intelsdi-x:master","ref":"master","sha":"f6ebcc7cdefd9a74e256187e638ad6fa62487629","user":{"login":"intelsdi-x","id":8398747,"avatar_url":"https://avatars.githubusercontent.com/u/8398747?v=3","gravatar_id":"","url":"https://api.github.com/users/intelsdi-x","html_url":"https://github.com/intelsdi-x","followers_url":"https://api.github.com/users/intelsdi-x/followers","following_url":"https://api.github.com/users/intelsdi-x/following{/other_user}","gists_url":"https://api.github.com/users/intelsdi-x/gists{/gist_id}","starred_url":"https://api.github.com/users/intelsdi-x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intelsdi-x/subscriptions","organizations_url":"https://api.github.com/users/intelsdi-x/orgs","repos_url":"https://api.github.com/users/intelsdi-x/repos","events_url":"https://api.github.com/users/intelsdi-x/events{/privacy}","received_events_url":"https://api.github.com/users/intelsdi-x/received_events","type":"Organization","site_admin":false},"repo":{"id":45548737,"name":"snap-plugin-utilities","full_name":"intelsdi-x/snap-plugin-utilities","owner":{"login":"intelsdi-x","id":8398747,"avatar_url":"https://avatars.githubusercontent.com/u/8398747?v=3","gravatar_id":"","url":"https://api.github.com/users/intelsdi-x","html_url":"https://github.com/intelsdi-x","followers_url":"https://api.github.com/users/intelsdi-x/followers","following_url":"https://api.github.com/users/intelsdi-x/following{/other_user}","gists_url":"https://api.github.com/users/intelsdi-x/gists{/gist_id}","starred_url":"https://api.github.com/users/intelsdi-x/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/intelsdi-x/subscriptions","organizations_url":"https://api.github.com/users/intelsdi-x/orgs","repos_url":"https://api.github.com/users/intelsdi-x/repos","events_url":"https://api.github.com/users/intelsdi-x/events{/privacy}","received_events_url":"https://api.github.com/users/intelsdi-x/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/intelsdi-x/snap-plugin-utilities","description":"","fork":false,"url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities","forks_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/forks","keys_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/keys{/key_id}","collaborators_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/teams","hooks_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/hooks","issue_events_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/issues/events{/number}","events_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/events","assignees_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/assignees{/user}","branches_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/branches{/branch}","tags_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/tags","blobs_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/git/refs{/sha}","trees_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/git/trees{/sha}","statuses_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/statuses/{sha}","languages_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/languages","stargazers_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/stargazers","contributors_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/contributors","subscribers_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/subscribers","subscription_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/subscription","commits_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/commits{/sha}","git_commits_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/git/commits{/sha}","comments_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/comments{/number}","issue_comment_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/issues/comments{/number}","contents_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/contents/{+path}","compare_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/compare/{base}...{head}","merges_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/merges","archive_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/downloads","issues_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/issues{/number}","pulls_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/pulls{/number}","milestones_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/milestones{/number}","notifications_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/labels{/name}","releases_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/releases{/id}","deployments_url":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/deployments","created_at":"2015-11-04T15:38:52Z","updated_at":"2015-12-03T18:19:32Z","pushed_at":"2016-02-18T08:10:02Z","git_url":"git://github.com/intelsdi-x/snap-plugin-utilities.git","ssh_url":"git@github.com:intelsdi-x/snap-plugin-utilities.git","clone_url":"https://github.com/intelsdi-x/snap-plugin-utilities.git","svn_url":"https://github.com/intelsdi-x/snap-plugin-utilities","homepage":null,"size":51,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/pulls/8"},"html":{"href":"https://github.com/intelsdi-x/snap-plugin-utilities/pull/8"},"issue":{"href":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/issues/8"},"comments":{"href":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/issues/8/comments"},"review_comments":{"href":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/pulls/8/comments"},"review_comment":{"href":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/pulls/8/commits"},"statuses":{"href":"https://api.github.com/repos/intelsdi-x/snap-plugin-utilities/statuses/c5f74b5960eead03d6e89bfd674071eb20d6060c"}}}}