Skip to content Search Apps Documentation Source Content File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

interfaces.gno

0.61 Kb · 28 lines
 1package vm
 2
 3import (
 4	"strconv"
 5)
 6
 7type Stringer interface {
 8	String() string
 9}
10
11var stringers []Stringer
12
13func AddStringer(cur realm, str Stringer) {
14	// NOTE: this is ridiculous, a slice that will become too long
15	// eventually.  Don't do this in production programs; use
16	// gno.land/p/nt/avl/v0 or similar structures.
17	stringers = append(stringers, str)
18}
19
20func Render(path string) string {
21	res := ""
22	// NOTE: like the function above, this function too will eventually
23	// become too expensive to call.
24	for i, stringer := range stringers {
25		res += strconv.Itoa(i) + ": " + stringer.String() + "\n"
26	}
27	return res
28}