github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/examples/gno.land/r/demo/tests/interfaces.gno (about) 1 package tests 2 3 import ( 4 "strconv" 5 ) 6 7 type Stringer interface { 8 String() string 9 } 10 11 var stringers []Stringer 12 13 func 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 20 func 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 }