Documentation ¶
Overview ¶
Package gluamapper provides an easy way to map GopherLua tables to Go structs
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Map ¶
Map maps the lua table to the given struct pointer with default options.
Example ¶
type Role struct { Name string } type Person struct { Name string Age int WorkPlace string Role []*Role } L := lua.NewState() if err := L.DoString(` person = { name = "Michel", age = "31", -- weakly input work_place = "San Jose", role = { { name = "Administrator" }, { name = "Operator" } } } `); err != nil { panic(err) } var person Person if err := Map(L.GetGlobal("person").(*lua.LTable), &person); err != nil { panic(err) } fmt.Printf("%s %d", person.Name, person.Age)
Output: Michel 31
func ToUpperCamelCase ¶
ToUpperCamelCase is an Option.NameFunc that converts strings from snake case to upper camel case.
Types ¶
type Option ¶
type Option struct { // Function to convert a lua table key to Go's one. This defaults to "ToUpperCamelCase". NameFunc func(string) string // Returns error if unused keys exist. ErrorUnused bool // A struct tag name for lua table keys . This defaults to "gluamapper" TagName string }
Option is a configuration that is used to create a new mapper.
Click to show internal directories.
Click to hide internal directories.