Skip to content

Instantly share code, notes, and snippets.

@dimiro1
Created May 29, 2016 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dimiro1/4f539132a2f8a5e074002b4236535598 to your computer and use it in GitHub Desktop.
Save dimiro1/4f539132a2f8a5e074002b4236535598 to your computer and use it in GitHub Desktop.
Stack Dump Shopify-Go-lua
func stackDump(l *lua.State) {
n := l.Top()
fmt.Println("-------------------- Stack Dump -------------------")
fmt.Printf("Total in stack: %d\n", n)
for i := 1; i <= n; i++ {
fmt.Printf("%d: ", i)
switch l.TypeOf(i) {
case lua.TypeString:
s, _ := l.ToString(i)
fmt.Printf("string %s", s)
case lua.TypeBoolean:
fmt.Printf("boolean %t", l.ToBoolean(i))
case lua.TypeNumber:
f, _ := l.ToNumber(i)
fmt.Printf("number %f", f)
default:
fmt.Printf("%s", lua.TypeNameOf(l, i))
}
fmt.Println()
}
fmt.Println("--------------- Stack Dump Finished ---------------")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment