Security News
The Risks of Misguided Research in Supply Chain Security
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
github.com/orcaman/concurrent-map
As explained here and here, the map
type in Go doesn't support concurrent reads and writes. concurrent-map
provides a high-performance solution to this by sharding the map with minimal time spent waiting for locks.
Prior to Go 1.9, there was no concurrent map implementation in the stdlib. In Go 1.9, sync.Map
was introduced. The new sync.Map
has a few key differences from this map. The stdlib sync.Map
is designed for append-only scenarios. So if you want to use the map for something more like in-memory db, you might benefit from using our version. You can read more about it in the golang repo, for example here and here
Import the package:
import (
"github.com/orcaman/concurrent-map"
)
go get "github.com/orcaman/concurrent-map"
The package is now imported under the "cmap" namespace.
// Create a new map.
m := cmap.New()
// Sets item within map, sets "bar" under key "foo"
m.Set("foo", "bar")
// Retrieve item from map.
if tmp, ok := m.Get("foo"); ok {
bar := tmp.(string)
}
// Removes item under key "foo"
m.Remove("foo")
For more examples have a look at concurrent_map_test.go.
Running tests:
go test "github.com/orcaman/concurrent-map"
Contributions are highly welcome. In order for a contribution to be merged, please follow these guidelines:
concurrent-map
as simple as possible and as similar to the native map
. Please keep this in mind when opening issues.MIT (see LICENSE file)
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Snyk's use of malicious npm packages for research raises ethical concerns, highlighting risks in public deployment, data exfiltration, and unauthorized testing.
Research
Security News
Socket researchers found several malicious npm packages typosquatting Chalk and Chokidar, targeting Node.js developers with kill switches and data theft.
Security News
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.