Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
github.com/JesseCoretta/go-stackage
The stackage package implements flexible Stack and Condition types with many useful features. It can be used to create object-based Boolean statements, abstract mathematical constructs, simple lists and much more: the possibilities are endless!
The main goal of this package is provide an extremely reliable and accommodating stack/condition solution that is suitable for use in virtually any conceivable Go-based scenario in which objects of these types are needed. While extremely extensible and flexible, it should always be possible to use this package with no need for additional (non main) code while operating in extremely simple scenarios.
This package is no longer considered experimental, as it is currently in use in the wild with impressive results.
The stackage package, from go-stackage
, is released under the terms of the MIT license. See the LICENSE
file in the repository root, or click the License badge above, for complete details.
When needed, users may opt to create their own derivative alias types of either the Stack or Condition types for more customized use in their application.
The caveat, naturally, is that users will be expected to wrap all of the package-provided methods (e.g.: String
, Push
, Pop
, etc) they intend to use.
However, the upside is that the user may now write (extend) wholly new methods that are unique to their own application, and without having to resort to potentially awkward measures, such as embedding.
To create a derivative type based on the Stack type, simply do something similar to the following example in your code:
type MyStack stackage.Stack
// Here we extend a wholly new function. The input and output signatures
// are entirely defined at the discretion of the author and are shown in
// "pseudo code context" here.
func (r MyStack) NewMethodName([input signature]) [<output signature>] {
// your custom code, do whatever!
}
// Here we wrap a pre-existing package-provided function, String, that
// one would probably intend to use.
//
// To run the actual String method, we need to first CAST the custom
// type (r, MyStack) to a bonafide stackage.Stack instance as shown
// here. Unlike the above example, this is NOT "pseudo code" and will
// compile just fine.
//
// Repeat as needed for other methods that may be used.
func (r MyStack) String() string {
// return the result from a "TYPE CAST -> EXEC" call
return stackage.Stack(r).String()
}
// For added convenience, adopters can write their own private "cast"
// method for quick transformation back to the derived Stack type.
// This allows easy access to base methods which the adopter has not
// explicitly wrapped.
func (r MyStack) cast() stackage.Stack {
return stackage.Stack(r)
}
The procedure would be identical for a Condition alias -- just change the name and the derived stackage type from the first example line and modify as desired.
If you'd like to see a more complex working example of this concept in the wild, have a look at the go-aci
package, which makes heavy use of derivative stackage types.
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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.