()
| 11 | } |
| 12 | |
| 13 | func Example() { |
| 14 | steps := []step{} |
| 15 | l := lua.NewState() |
| 16 | lua.BaseOpen(l) |
| 17 | _ = lua.NewMetaTable(l, "stepMetaTable") |
| 18 | lua.SetFunctions(l, []lua.RegistryFunction{{"__newindex", func(l *lua.State) int { |
| 19 | k, v := lua.CheckString(l, 2), l.ToValue(3) |
| 20 | steps = append(steps, step{name: k, function: v}) |
| 21 | return 0 |
| 22 | }}}, 0) |
| 23 | l.PushUserData(steps) |
| 24 | l.PushValue(-1) |
| 25 | l.SetGlobal("step") |
| 26 | lua.SetMetaTableNamed(l, "stepMetaTable") |
| 27 | lua.LoadString(l, `step.request_tracking_js = function () |
| 28 | get(config.domain..'/javascripts/shopify_stats.js') |
| 29 | end`) |
| 30 | l.Call(0, 0) |
| 31 | fmt.Println(steps[0].name) |
| 32 | // Output: request_tracking_js |
| 33 | } |
nothing calls this directly
no test coverage detected