Welvet examples

57. stub/introspection

Open original example β†—Recorded results Β· not a live execution

Part: VIII Β· Stubs
Package: github.com/openfluke/welvet/stub/introspection
Status: partial β€” 🚧

When

Scaffold / experimental stub stub/introspection (may be partial).

Where

import "github.com/openfluke/welvet/stub/introspection"

cd 57-stub-introspection && source ../env.sh && go run .

Why

UIs and FFI need to list Grid methods without hardcoding every export.

What

GetMethods, GetMethodsJSON, GetMethodSignature.

Sample output (captured)

9 <nil>

Live capture from go run ./cmd/runall on local ../../welvet (exit 0).

Source

Copied from the Welvet feature book examples (openfluke.github.io/welvet/examples/57-stub-introspection).

main.go

Download source ↓
package main

import (
	"fmt"

	"github.com/openfluke/welvet/architecture"
	"github.com/openfluke/welvet/stub/introspection"
)

func main() {
	g := architecture.NewGrid(1, 1, 1, 1)
	methods, err := introspection.GetMethods(g)
	fmt.Println(len(methods), err)
}