![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
github.com/mitranim/refut
Utilities missing from the "reflect" package: easier struct traversal, deep dereferencing, various boolean tests such as generic `IsNil`, and some more. Small and dependency-free. • Functions that take a `reflect.Value` have "Rval" in the name. • Functions that take a `reflect.Type` have "Rtype" in the name. In general, utils for struct traversal can be implemented as function that take closures, or as stateful iterator objects. Both approaches were tested and demonstrated similar performance characteristics. The iterator-based approach can be more convenient to use because it doesn't interrupt the control flow of the caller code. However, the closure-based approach is much simpler to implement and get right. It's also much simpler to wrap, making it easier for users of this package to implement their own iterator functions in terms of the existing ones.
Readme
Short for "reflect utils": utilities missing from the "reflect" package in the Go standard library. Small and dependency-free.
See the full documentation at https://pkg.go.dev/github.com/mitranim/rf.
Walking now avoids stack overflow on cyclic types. More specifically, it avoids infinite recursion when generating walkers for cyclic types. Note that fully walking cyclic types is not yet supported; instead, inner occurrences of a cyclic type are ignored, and only the outermost occurrence is walked. This limitation may be lifted in future versions.
Walking now ignores private fields.
Converted the following tools to generics, for better type safety and efficiency:
TypeFilter
IfaceFilter
ShallowIfaceFilter
Appender
Trawl
TrawlWith
Added KindFilter
(untested).
Added Type
.
Rename WalkFuncPtr
→ WalkPtrFunc
.
Add WalkPtr
and WalkFuncPtr
. Remove DerefPtr
because it made no sense.
Added:
ValueAddr
Interface
DeepFields
TypeDeepFields
OffsetFields
TypeOffsetFields
Path
Rev
Breaking changes:
DerefValue*
to begin with Deref*
.CopyPath
with Path.Copy
.DeepFields
and TypeDeepFields
is a particularly useful addition, as it supports "flattening" structs, simplifying most use cases that involve struct iteration.
Add IfaceFilterFor
, ShallowIfaceFilterFor
.
Reverted breaking change in v0.3.1
: IfaceFilter
once again allows to visit descendants. Added ShallowIfaceFilter
that doesn't visit descendants of a matching node.
Quick breaking change: IfaceFilter
visits either self or descendants, not both.
More flexible Filter
interface:
Previous approach: filter returns bool
answering "should visit this node". 2 possible states. Implicitly walks descendants.
New approach: filter returns flagset where "should visit this node" and "should walk descendants" are both optional flags. 4 possible states. Walking descendants is now optional.
Renamed Filter.ShouldVisit
to Filter.Visit
because it's no longer a boolean. This makes it impossible to implement Filter
and Walker
on the same type, which is probably a good thing due to filter equality rules.
Nop
no longer implements Filter
.
Replaced True
and False
with Self
, Desc
, Both
, All
.
Replaced Not
with InvertSelf
.
Renamed DerefLen
to Len
.
Added Fields
and TypeFields
for micro-optimizing struct shallow walking.
Walk
/ GetWalker
now support walking into interface{}
values, fetching the appropriate cached walker for the given type and filter on the fly.
Added MaybeOr
, MaybeAnd
, GetTypeFilter
, TypeFilterFor
for micro-optimizing filter allocations.
Complete revision.
Cache
for generating and caching arbitrary type-dependent structures.github.com/mitranim/refut
to github.com/mitranim/rf
for brevity.I'm receptive to suggestions. If this library almost satisfies you but needs changes, open an issue or chat me up. Contacts: https://mitranim.com/#contacts
FAQs
Utilities missing from the "reflect" package: easier struct traversal, deep dereferencing, various boolean tests such as generic `IsNil`, and some more. Small and dependency-free. • Functions that take a `reflect.Value` have "Rval" in the name. • Functions that take a `reflect.Type` have "Rtype" in the name. In general, utils for struct traversal can be implemented as function that take closures, or as stateful iterator objects. Both approaches were tested and demonstrated similar performance characteristics. The iterator-based approach can be more convenient to use because it doesn't interrupt the control flow of the caller code. However, the closure-based approach is much simpler to implement and get right. It's also much simpler to wrap, making it easier for users of this package to implement their own iterator functions in terms of the existing ones.
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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.