Skip to content

Instantly share code, notes, and snippets.

@moul
Last active January 23, 2024 13:23
Show Gist options
  • Save moul/ccf1e2aff64e7a1f0c5ca5e2d98d7e9a to your computer and use it in GitHub Desktop.
Save moul/ccf1e2aff64e7a1f0c5ca5e2d98d7e9a to your computer and use it in GitHub Desktop.
gnokey maketx run
package main
import (
"std"
"gno.land/p/demo/bf"
"gno.land/p/demo/ufmt"
"gno.land/r/demo/tests"
"gno.land/r/demo/users"
)
func Main() {
// a comment
println("# HELLO WORLD!")
println(`## users.Render("")`)
println(users.Render(""))
println()
println(`## for i < 10 {print "hey hey hey!"}`)
for i := 0; i < 10; i++ {
println(ufmt.Sprintf("%d. hey hey hey!", i))
}
println()
println("## tests.* & std.*")
println("- `tests.CurrentRealmPath`", tests.CurrentRealmPath())
println("- `tests.IsOriginCall`", tests.IsOriginCall())
println("- `tests.GetPrevRealm`", tests.GetPrevRealm()) // XXX: should be the user, not gno.land/r/main
println("- `std.GetOrigCaller`", std.GetOrigCaller())
println("- `std.PrevRealm`", std.PrevRealm())
println()
println("## stateful check")
println(ufmt.Sprintf("- before: %d", tests.Counter()))
for i := 0; i < 10; i++ {
tests.IncCounter()
}
println(ufmt.Sprintf("- after: %d", tests.Counter()))
println()
println("## bf")
source := "++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++.>+.+++++++..+++.>++.<<+++++++++++++++.>.+++.------.--------."
println("```")
println("source: ", source)
println("result: ", bf.Execute(source))
println("```")
println()
println("## complex types")
obj := tests.TestRealmObject{Field: "foobar"}
println("- before: ", obj.Field)
tests.ModifyTestRealmObject(&obj)
println("- after: ", obj.Field)
}
@jefft0
Copy link

jefft0 commented Jan 23, 2024

On line 12, Main should be main .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment