• Stars
    star
    114
  • Rank 308,031 (Top 7 %)
  • Language
    Go
  • License
    MIT License
  • Created over 9 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

gluamapper: maps a GopherLua table to a Go struct

gluamapper: maps a GopherLua table to a Go struct


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 .

Installation

go get github.com/yuin/gluamapper

API

See Go doc .

Usage

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

More Repositories

1

gopher-lua

GopherLua: VM and compiler for Lua in Go
Go
6,207
star
2

goldmark

🏆 A markdown parser written in Go. Easy to extend, standard(CommonMark) compliant, well structured.
Go
3,586
star
3

goldmark-highlighting

A Syntax highlighting extension for the goldmark markdown parser.
Go
98
star
4

goldmark-meta

A YAML metadata extension for the goldmark markdown parser.
Go
76
star
5

charsetutil

An easiest way to convert character set encodings in Go
Go
40
star
6

iceberg

A lightweight hackable keystroke application launcher can run on Windows and Linux
C++
30
star
7

golbot

A single binary Lua scriptable chat bot with REST API support written in Go
Go
26
star
8

goldmark-emoji

An emoji extension for the goldmark markdown parser
Go
21
star
9

sesame

An object-to-object mapper generator for Go that can 'scale'
Go
12
star
10

gluare

A regular expression library for the GopherLua
Go
12
star
11

silkylog

silkylog: an extensible static site generator
Go
7
star
12

mellowdown

An extensible markdown processor with visualization supports(PlantUML, PowerPoint etc...)
Go
7
star
13

stagparser

Generic parser for golang struct tag
Go
6
star
14

glel

Expression evaluation with Lua for Go
Go
5
star
15

cidre

cidre is a modular and extensible thin web framework in Go.
Go
4
star
16

logias

A simple server monitoring agent built with Go and GopherLua
Go
3
star
17

rays

A "LESS PAIN" lightweight WSGI compatible web framework
Python
3
star
18

thistle

server monitoring app for small systems
Python
2
star
19

goldmark-dynamic

Dynamic extension loading for goldmark markdown parser
Go
2
star
20

cidre-bottle

cidre-bottle: building a packaged cidre webapp binary
Go
1
star
21

cidre-ego

An ego integration for the cidre web framework
Go
1
star
22

yammy

Composable YAML/JSON made easy for CLI and Go 😋
Go
1
star