{"id":42572714,"url":"https://github.com/go-humble/locstor","last_synced_at":"2026-01-28T21:24:10.368Z","repository":{"id":89968448,"uuid":"42338143","full_name":"go-humble/locstor","owner":"go-humble","description":"localstorage bindings for go and gopherjs","archived":false,"fork":false,"pushed_at":"2024-05-22T13:10:06.000Z","size":518,"stargazers_count":27,"open_issues_count":4,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-06-19T03:13:31.432Z","etag":null,"topics":["go","gopherjs","gopherjs-bindings"],"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/go-humble.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-12T00:18:16.000Z","updated_at":"2024-04-05T15:57:27.000Z","dependencies_parsed_at":"2023-03-08T01:30:19.291Z","dependency_job_id":null,"html_url":"https://github.com/go-humble/locstor","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/go-humble/locstor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-humble%2Flocstor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-humble%2Flocstor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-humble%2Flocstor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-humble%2Flocstor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/go-humble","download_url":"https://codeload.github.com/go-humble/locstor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/go-humble%2Flocstor/sbom","scorecard":{"id":431981,"data":{"date":"2025-08-11","repo":{"name":"github.com/go-humble/locstor","commit":"d8d9ce95b96d05685f73f4dfe8fe7d1edfabf18a"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 2/24 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":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"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":"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":"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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"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"}},{"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 'master'"],"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 5 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-19T03:35:30.721Z","repository_id":89968448,"created_at":"2025-08-19T03:35:30.721Z","updated_at":"2025-08-19T03:35:30.721Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28852375,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-28T15:15:36.453Z","status":"ssl_error","status_checked_at":"2026-01-28T15:15:13.020Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["go","gopherjs","gopherjs-bindings"],"created_at":"2026-01-28T21:24:09.642Z","updated_at":"2026-01-28T21:24:10.354Z","avatar_url":"https://github.com/go-humble.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"Humble/locstor\n=============\n\n[![GoDoc](https://godoc.org/github.com/go-humble/locstor?status.svg)](https://godoc.org/github.com/go-humble/locstor)\n\nVersion 0.2.2\n\nlocstor provides gopherjs bindings for the localStorage API. It allows you to\nstore and retrieve any arbitrary go data structure, and is intended to be\ncompiled to javascript with [gopherjs](https://github.com/gopherjs/gopherjs)\nand run in the browser. locstor works great as a stand-alone package or in\ncombination with other [Humble](https://github.com/go-humble) packages.\n\nlocstor is written in pure go. It feels like go, follows go idioms when\npossible, and compiles with the go tools.\n\n\nBrowser Support\n---------------\n\nlocstor works with IE9+ (with a\n[polyfill for typed arrays](https://github.com/inexorabletash/polyfill/blob/master/typedarray.js))\nand all other modern browsers. locstor compiles to javascript via\n[gopherjs](https://github.com/gopherjs/gopherjs) and this is a gopherjs\nlimitation.\n\n\nInstallation\n------------\n\nInstall locstor like you would any other go package:\n\n```bash\ngo get github.com/go-humble/locstor\n```\n\nYou will also need to install gopherjs if you don't already have it. The latest\nversion is recommended. Install gopherjs with:\n\n```\ngo get -u github.com/gopherjs/gopherjs\n```\n\nYou can compile your application to javascript using the `gopherjs build`\ncommand. Run `gopherjs --help` to learn more about the gopherjs command-line\ntool.\n\n\nExample Usage\n-------------\n\n### Accessing the localStorage API Directly\n\nUse [`SetItem`](https://godoc.org/github.com/go-humble/locstor#SetItem) to\nstore an item in localStorage:\n\n```go\nif err := locstor.SetItem('foo', 'bar'); err != nil {\n\t// Handle err\n}\n```\n\nUse [`GetItem`](https://godoc.org/github.com/go-humble/locstor#GetItem) to get\nan item from localStorage:\n\n```go\nitem, err := locstor.GetItem('foo')\nif err != nil {\n\t// Handle err\n}\nfmt.Println(item)\n// Output:\n//   bar\n```\n\nUse [`Key`](https://godoc.org/github.com/go-humble/locstor#Key) to get the key\nfor a specific item:\n\n```go\nkey, err := locstor.Key('bar')\nif err != nil {\n\t// Handle err\n}\nfmt.Println(key)\n// Output:\n//   foo\n```\n\nUse [`RemoveItem`](https://godoc.org/github.com/go-humble/locstor#RemoveItem)\nto remove an existing item from localStorage:\n\n```go\nif err := locstor.RemoveItem('foo'); err != nil {\n\t// Handle err\n}\n_, err := locstor.GetItem('foo')\nfmt.Println(err)\n// Output:\n//   Could not find an item with the given key: foo\n```\n\nUse [`Length`](https://godoc.org/github.com/go-humble/locstor#Length) to get\nthe number of items currently in localStorage:\n\n```go\ncount, err := locstor.Length()\nif err != nil {\n\t// Handle err\n}\n```\n\nUse [`Clear`](https://godoc.org/github.com/go-humble/locstor#Clear) to remove\nall items from localStorage:\n\n```go\nif err := locstor.Clear(); err != nil {\n\t// Handle err\n}\n```\n\n### Using a DataStore\n\nYou can also use a\n[`DataStore`](https://godoc.org/github.com/go-humble/locstor#DataStore), which\nis an abstraction layer built on top of localStorage capable of storing and\nretrieving arbitrary go data structures, not just strings.\n\nUse\n[`NewDataStore`](https://godoc.org/github.com/go-humble/locstor#NewDataStore) to\ncreate a new `DataStore`. It accepts an `EncoderDecoder` as an argument. There\nare two encodings provided out-of-the-box: `JSONEncoding` and `BinaryEncoding`.\nYou should choose `JSONEncoding` if you want the data stored in localStorage to\nbe more readable and `BinaryEncoding` if you want the data to take up less\nspace. You can also provide a custom encoding by implementing the\n[`EncoderDecoder`](https://godoc.org/github.com/go-humble/locstor#EncoderDecoder)\ninterface.\n\n```go\nstore := locstor.NewDataStore(JSONEncoding)\n```\n\nUse [`Save`](https://godoc.org/github.com/go-humble/locstor#DataStore.Save) to\nsave data structures in localStorage:\n\n```go\nif err := store.Save(\"numbers\", []int{1, 2, 3}); err != nil {\n\t// Handle err\n}\n```\n\nUse [`Find`](https://godoc.org/github.com/go-humble/locstor#DataStore.Find) to\nget existing data structures out of localStorage. Find works similarly to\n[`json.Unmarshal`](http://golang.org/pkg/encoding/json/#Unmarshal) from the\nstandard library. The second argument to `Find`, called `holder`, is a pointer\nto a variable that is capable of holding the decoded data structure. Since in\nthis case we stored a slice of ints, the type of holder should be `*[]int`.\n\n```go\ngotNumbers := []int{}\nif err := store.Find(\"numbers\", \u0026gotNumbers); err != nil {\n\t// Handle err\n}\nfmt.Println(gotNumbers)\n// Output:\n//   [1 2 3]\n```\n\nUse [`Delete`](https://godoc.org/github.com/go-humble/locstor#DataStore.Delete)\nto delete an existing data structure from localStorage:\n\n```go\nif err := store.Delete(\"numbers\"); err != nil {\n\t// Handle err\n}\ngotNumbers := []int{}\n_, err := locstor.Find('numbers', \u0026gotNumbers)\nfmt.Println(err)\n// Output:\n//   Could not find an item with the given key: numbers\n```\n\n### Handling Errors\n\n[`ErrLocalStorageNotSupported`](https://godoc.org/github.com/go-humble/locstor#pkg-variables)\nwill be returned by any function or method if localStorage is not supported in\nthe current browser. `ErrLocalStorageNotSupported` is just a variable, so\nyou can do direct comparisons:\n\n```go\nif err := locstor.GetItem(\"foo\"); err != nil {\n\tif err == locstor.ErrLocalStorageNotSupported {\n\t\t// Handle an ErrLocalStorageNotSupported error \n\t} else {\n\t\t// Handle some other type of error\n\t}\n}\n```\n\n[`ItemNotFoundError`](https://godoc.org/github.com/go-humble/locstor#ItemNotFoundError)\nis the type of error returned if the item you were looking for does not exist in\nlocalStorage. It is a type that implements the `error` interface and tells you\nwhich key or item was not found. To check if an error is an `ItemNotFoundError`,\nyou can use a type assertion:\n\n```go\nif err := locstor.GetItem(\"foo\"); err != nil {\n\tif _, ok := err.(locstor.ItemNotFoundError); ok {\n\t\t// Handle an ItemNotFoundError error \n\t} else {\n\t\t// Handle some other type of error\n\t}\n}\n```\n\n\nTesting\n-------\n\nlocstor uses the [karma test runner](http://karma-runner.github.io/0.12/index.html)\nto test the code running in actual browsers.\n\nThe tests require the following additional dependencies:\n\n- [node.js](http://nodejs.org/)\n- [karma](http://karma-runner.github.io/0.12/index.html)\n- [karma-qunit](https://github.com/karma-runner/karma-qunit)\n\nDon't forget to also install the karma command line tools with `npm install -g karma-cli`.\n\nYou will also need to install a launcher for each browser you want to test with,\nas well as the browsers themselves. Typically you install a karma launcher with\n`npm install -g karma-chrome-launcher`. You can edit the config file at\n`karma/test-mac.conf.js` or create a new one (e.g. `karma/test-windows.conf.js`)\nif you want to change the browsers that are tested on.\n\nOnce you have installed all the dependencies, start karma with\n`karma start karma/test-mac.conf.js` (or your customized config file, if\napplicable). Once karma is running, you can keep it running in between tests.\n\nNext you need to compile the test.go file to javascript so it can run in the\nbrowsers:\n\n```\ngopherjs build karma/go/locstor_test.go -o karma/js/locstor_test.js\n```\n\nFinally run the tests with `karma run karma/test-mac.conf.js` (changing the name\nof the config file if needed).\n\nIf you are on a unix-like operating system, you can recompile and run the tests\nin one go by running the provided bash script: `./karma/test.sh`.\n\n\nContributing\n------------\n\nSee [CONTRIBUTING.md](https://github.com/go-humble/locstor/blob/master/CONTRIBUTING.md)\n\n\nLicense\n-------\n\nlocstor is licensed under the MIT License. See the\n[LICENSE](https://github.com/go-humble/locstor/blob/master/LICENSE) file for\nmore information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-humble%2Flocstor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgo-humble%2Flocstor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgo-humble%2Flocstor/lists"}