gluarequire2

package module
Version: v0.0.0-...-7528d5a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2020 License: MIT Imports: 8 Imported by: 2

README

gluarequire2

builds.sr.ht status    Godoc Reference

gluarequire2 provides a way to import file directly from GitHub using GopherLua.

Files are downloaded on the fly via HTTP (and stored in /tmp), then require2 rewrite the imports to the right location.

Installation

$ go get a4.io/gluarequire2
QuickStart
package main

import (
	"a4.io/gluarequire2"
	"github.com/yuin/gopher-lua"
)

func main() {
	L := lua.NewState()
	defer L.Close()

	gluarequire2.NewRequire2Module(gluarequire2.NewRequireFromGitHub(nil)).SetGlobal(L)

	if err := L.DoString(`

        local mymod = require2('github.com/tsileo/gluarequire2/_tests/testmod')
	assert(mymod.return1() == 1)

    `); err != nil {
		panic(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRequire2Module

func NewRequire2Module(requireSetuper RequireSetuper) *require2

Types

type RequireFromGitHub

type RequireFromGitHub struct {
	// contains filtered or unexported fields
}

func NewRequireFromGitHub

func NewRequireFromGitHub(conf *RequireFromGitHubConf) *RequireFromGitHub

func (*RequireFromGitHub) Setup

func (rfgh *RequireFromGitHub) Setup(L *lua.LState, name string) (string, error)

type RequireFromGitHubConf

type RequireFromGitHubConf struct {
	Path string
}

type RequireSetuper

type RequireSetuper interface {
	Setup(L *lua.LState, name string) (newName string, err error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL