An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 8.2% on proxy.golang.org

proxy.golang.org : github.com/lanl/goop

Package goop (Go Object-Oriented Programming) provides support for dynamic object-oriented programming constructs in Go, much like those that appear in various scripting languages. The goal is to integrate fast, native-Go objects and slower but more flexible Goop objects within the same program. FEATURES: For flexibility, Goop uses a prototype-based object model (cf. http://en.wikipedia.org/wiki/Prototype-based_programming) rather than a class-based object model. Objects can be created either by inheriting from existing objects or from scratch. Data fields (a.k.a. properties) and method functions can be added and removed at will. Multiple inheritance is supported. An object's inheritance hierarchy can be altered dynamically. Methods can utilize type-dependent dispatch (i.e., multiple methods with the same name but different argument types). As an example, let's create an object from scratch: Now let's add a couple of data fields to pointObj: Unlike native Go, Goop lets you define multiple method functions with the same name, as long as the arguments differ in type and/or number: Admittedly, having to use Get and Set all the time can be a bit tedious. Functions that are less trivial than the above will typically call Get and Set only at the beginning and end of the function and use local variables for most of the computation. Use Call to call a method on an object: Call returns all of the method's return values as a single slice. Use type assertions to put the individual return values into their correct format: Again, sorry for the bloat, but that's what it takes to provide this sort of dynamic behavior in Go. The following more extended example shows how to define and instantiate an LCMCalculator object, which is constructed from two integers and provides methods that return the greatest common divisor and least common multiple of those two numbers. Each of those methods memoizes its return value by redefining itself after its first invocation to a function that returns a constant value.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/lanl/goop
License: BSD-3-Clause
Latest release: about 3 years ago
First release: about 3 years ago
Namespace: github.com/lanl
Stars: 107 on GitHub
Forks: 18 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 30 days ago

    Loading...
    Readme
    Loading...