github.com/arnodel/golua@v0.0.0-20230215163904-e0b5347eaaa1/lib/packagelib/lua/require.lua (about)

     1  print(pcall(require))
     2  --> ~^false\t.*value needed
     3  
     4  print(pcall(require, {}))
     5  --> ~^false\t.*must be a string
     6  
     7  print(require "testlib.foo") -- points at testlib/foo.lua
     8  --> =foo
     9  --> =bar
    10  
    11  -- Second time, the module is already loaded so no side effects.
    12  print(require "testlib.foo")
    13  --> =bar
    14  
    15  print(package.loaded["testlib.foo"])
    16  --> =bar
    17  
    18  print(require "testlib.bar") -- points at testlib/bar/init.lua
    19  --> =42