Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose More Go Libraries #104

Open
tooolbox opened this issue Jun 24, 2022 · 7 comments
Open

Expose More Go Libraries #104

tooolbox opened this issue Jun 24, 2022 · 7 comments
Labels
feature request Enhancement or feature request

Comments

@tooolbox
Copy link
Collaborator

In the past couple days I've had to deal with some utf8 content, and discovered that Lua has no native support for utf8. Many of the most popular/commonly recommended solutions involve C libraries wrapped by Lua, which obviously won't work for Algernon.

Nevertheless, I have scoured the internet for pure-Lua utf8 libs and I almost have a working solution.

However, Go has pretty fantastic utf8/unicode handling. Actually, it has pretty fantastic a lot of things. We wouldn't necessarily want to blow away the standard Lua functionality because libraries will depend on them, but what about adding more Go libraries under the go namespace?

local name = "Björk"
print(name:upper()) -- BJöRK
local strings = require("go").strings
print(strings.ToUpper(name)) -- BJÖRK

Obviously the strings lib is top of mind for me at the moment but I wanted to pitch the general idea of exposing more Go libraries into Algernon and grouping them under the go namespace.

@xyproto xyproto added the feature request Enhancement or feature request label Jun 24, 2022
@linkerlin
Copy link

How about added the libs?
https://github.com/vadv/gopher-lua-libs

@tooolbox
Copy link
Collaborator Author

tooolbox commented Jul 2, 2022

How about added the libs?

Not a bad idea actually. But I wouldn't want all those things, maybe:

  • base64
  • crypto
  • filepath
  • humanize?
  • inspect
  • json
  • pprof?
  • regexp
  • strings
  • time
  • xmlpath
  • yaml

There's also a db module with support for sqlite3, postgres and mysql, although Algernon already has its own db support in various forms and adding another option seems a little confusing/odd?

Using these libs would probably mean not grouping them under the "go" namespace but it may be worth sacrificing that point for time saved in development.

Thoughts, @xyproto ?

@xyproto
Copy link
Owner

xyproto commented Jul 2, 2022

I think It's a great idea, as long as normal Lua code does not experience name collisions.

@xyproto
Copy link
Owner

xyproto commented Jul 2, 2022

This might be controversial, but I even think that exposing a graphics library like https://github.com/fogleman/fauxgl, for being able to render 3D graphics to a buffer, would be cool.

@tooolbox
Copy link
Collaborator Author

tooolbox commented Jul 5, 2022

This might be controversial, but I even think that exposing a graphics library like https://github.com/fogleman/fauxgl, for being able to render 3D graphics to a buffer, would be cool.

Interesting, what use case were you thinking of there? Rendering 3D models from the server into jpegs to be served to display in the browser, I guess?

@xyproto
Copy link
Owner

xyproto commented Jul 6, 2022

@tooolbox Yes, or even as a way to write a 3D game and show a window with graphics locally, while also including a server. Multiplayer games often includes servers.... But this is just an idea, I haven't really thought this through. 🙂

@tooolbox
Copy link
Collaborator Author

tooolbox commented Mar 27, 2024

Another good set of options is: https://github.com/Shopify/goluago

  • crypto (aes, hmac, md5, sha256)
  • encoding (base64, hex, json)
  • fmt
  • net/url
  • regexp
  • strings
  • time
  • uuid

Add in the missing ones from gopher-lua-libs:

  • filepath
  • http (little more complex yet robust than current functionality)
  • inspect (pure Lua)
  • io
  • ioutil
  • xmlpath
  • yaml

Perhaps anything directly wrapping Go libraries can be under the go namespace and anything 3rd party can be under pkg or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Enhancement or feature request
Projects
None yet
Development

No branches or pull requests

3 participants