{"id":13413247,"url":"https://github.com/simonnilsson/ask","last_synced_at":"2026-05-27T19:48:34.918Z","repository":{"id":50192495,"uuid":"295161759","full_name":"simonnilsson/ask","owner":"simonnilsson","description":"A Go package that provides a simple way of accessing nested properties in maps and slices.","archived":false,"fork":false,"pushed_at":"2023-08-28T21:07:01.000Z","size":455,"stargazers_count":56,"open_issues_count":1,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-27T19:48:30.015Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonnilsson.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-09-13T13:53:31.000Z","updated_at":"2025-12-31T03:28:00.000Z","dependencies_parsed_at":"2024-01-08T15:34:40.159Z","dependency_job_id":null,"html_url":"https://github.com/simonnilsson/ask","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/simonnilsson/ask","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonnilsson%2Fask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonnilsson%2Fask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonnilsson%2Fask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonnilsson%2Fask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonnilsson","download_url":"https://codeload.github.com/simonnilsson/ask/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonnilsson%2Fask/sbom","scorecard":{"id":824948,"data":{"date":"2025-08-11","repo":{"name":"github.com/simonnilsson/ask","commit":"084a0696901c6b5552183d74fecff86459b20da5"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/13 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/ci.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/simonnilsson/ask/ci.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/simonnilsson/ask/ci.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/ci.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/simonnilsson/ask/ci.yml/main?enable=pin","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T16:27:02.645Z","repository_id":50192495,"created_at":"2025-08-23T16:27:02.645Z","updated_at":"2025-08-23T16:27:02.645Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33581559,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-27T02:00:06.184Z","response_time":53,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-30T20:01:36.033Z","updated_at":"2026-05-27T19:48:34.899Z","avatar_url":"https://github.com/simonnilsson.png","language":"Go","funding_links":[],"categories":["JSON","Relational Databases"],"sub_categories":["Search and Analytic Databases","检索及分析资料库","Advanced Console UIs"],"readme":"\u003cp align=\"center\"\u003e\n\u003cimg src=\"logo.svg\" height=\"100\" border=\"0\" alt=\"ASK\"\u003e\n\u003cbr/\u003e\n\u003ca href=\"https://pkg.go.dev/github.com/simonnilsson/ask\"\u003e\u003cimg src=\"https://pkg.go.dev/badge/github.com/simonnilsson/ask\" alt=\"PkgGoDev\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://goreportcard.com/report/github.com/simonnilsson/ask\"\u003e\u003cimg src=\"https://goreportcard.com/badge/github.com/simonnilsson/ask\" alt=\"Go Report Card\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://raw.githack.com/wiki/simonnilsson/ask/coverage.html\"\u003e\u003cimg src=\"https://github.com/simonnilsson/ask/wiki/coverage.svg\" alt=\"Go Coverage\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/avelino/awesome-go#json\"\u003e\u003cimg src=\"https://awesome.re/mentioned-badge.svg\" alt=\"Mentioned in Awesome Go\" /\u003e\u003c/a\u003e  \n\u003cbr/\u003e\nand you shall receive.\n\u003c/p\u003e\nAsk provides a simple way of accessing nested properties in maps and slices. Works great in combination with encoding/json and other packages that \"Unmarshal\" arbitrary data into Go data-types. Inspired by the get function in the lodash javascript library.\n\u003cbr/\u003e\u003cbr/\u003e\n\n:warning: From version `v0.3.0`, the package requires [Go 1.17+](https://golang.org/doc/install), due to the usage of new additions to the reflect package.\n\n## Use\n\n```go\npackage main\n\nimport \"json\"\nimport \"github.com/simonnilsson/ask\"\n\nfunc main() {\n\n\t// Use parsed JSON as source data\n\tvar object map[string]interface{}\n\tjson.Unmarshal([]byte(`{ \"a\": [{ \"b\": { \"c\": 3 } }] }`), \u0026object)\n\n\t// Extract the 3\n\tres, ok := ask.For(object, \"a[0].b.c\").Int(0)\n\n\tfmt.Println(res, ok)\n\t// Output: 3 true\n\n\t// Attempt extracting a string at path .d that does not exist\n\tres2, ok := ask.ForArgs(object, \"a\", 0, \"b\", \"d\").String(\"nothing\")\n\n\tfmt.Println(res2, ok)\n\t// Output: nothing false\n\n}\n```\n\n## API\n\nInternally ask uses type assertions to traverse down the path supplied. Each invocation starts by calling For() with your data structure **source** and the **path** in this structure to extract. You can also use ForArgs() if want to supply each part of the path as a seperate argument, this can be usefull if your field names contain dots for example. The same accessors used in For can be used in ForArgs, but ForArgs can also take integers for slice indexes.\n\n```go\nFor(source interface{}, path string) *Answer\nForArgs(source interface{}, parts ...interface{}) *Answer\n```\nAdditional paths can be traversed by calling Path()/PathArgs() on the resulting answer.\n```go\n(a *Answer) Path(path string) *Answer\n(a *Answer) PathArgs(parts ...interface{}) *Answer\n```\n\n\n### Type assertion\n\nAfter receiving an `*Answer` from a call to For() it can be asserted to a type. The methods for this is seen below. Each function takes a default value as a parameter that will be returned in case the value can not be asserted from the answer. A second return value is used to indicate if the assertion was successful.\n\n```go\n(a *Answer) String(d string) (string, bool)\n(a *Answer) Bool(d bool) (bool, bool)\n(a *Answer) Int(d int64) (int64, bool)\n(a *Answer) Uint(d uint64) (uint64, bool)\n(a *Answer) Float(d float64) (float64, bool)\n(a *Answer) Slice(d []interface{}) ([]interface{}, bool)\n(a *Answer) Map(d map[string]interface{}) (map[string]interface{}, bool)\n```\n\nIf a number is found but it is of different type than requested it will be casted to desired type and return success. If the value would not fit within the valid range of requested type the operation will fail however and the default parameter will be returned instead.\n\nTwo additional methods are available, one to check if the answer has a value (not nil) and one to return the raw value as a interface{}.\n\n```go\n(a *Answer) Exists() bool\n(a *Answer) Value() interface{}\n```\n\nFor full documentation see [pkg.go.dev](https://pkg.go.dev/github.com/simonnilsson/ask).\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonnilsson%2Fask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonnilsson%2Fask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonnilsson%2Fask/lists"}