The first number is the count of modules that contain a package that imports this one.
The module count is a better indicator of popularity than the package count.
A module with 100 importing packages is counted only once instead of 100 times,
reflecting the fact that the choice to use the package was likely made only once,
not 100 times.
A '?' means that the value hasn't been computed yet.
===============================================================================
gluamapper: maps a GopherLua table to a Go struct
===============================================================================
.. image:: https://godoc.org/github.com/yuin/gluamapper?status.svg
:target: http://godoc.org/github.com/yuin/gluamapper
.. image:: https://travis-ci.org/yuin/gluamapper.svg
:target: https://travis-ci.org/yuin/gluamapper
|
gluamapper provides an easy way to map GopherLua tables to Go structs.
gluamapper converts a GopherLua table to ``map[string]interface{}`` , and then converts it to a Go struct using `mapstructure <https://github.com/mitchellh/mapstructure/>`_ .
----------------------------------------------------------------
Installation
----------------------------------------------------------------
.. code-block:: bash
go get github.com/yuin/gluamapper
----------------------------------------------------------------
API
----------------------------------------------------------------
See `Go doc <http://godoc.org/github.com/yuin/gluamapper>`_ .
----------------------------------------------------------------
Usage
----------------------------------------------------------------
.. code-block:: go
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 := gluamapper.Map(L.GetGlobal("person").(*lua.LTable), &person); err != nil {
panic(err)
}
fmt.Printf("%s %d", person.Name, person.Age)
----------------------------------------------------------------
License
----------------------------------------------------------------
MIT
----------------------------------------------------------------
Author
----------------------------------------------------------------
Yusuke Inuzuka
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)
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.