interfaces.gno

0.60 Kb ยท 28 lines
 1package tests
 2
 3import (
 4	"strconv"
 5)
 6
 7type Stringer interface {
 8	String() string
 9}
10
11var stringers []Stringer
12
13func AddStringer(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/demo/avl 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}