Skip to content

Can't import Go libraries with names containing [^A-Za-z0-9_] #12

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

Open
alanjds opened this issue Aug 21, 2018 · 3 comments
Open

Can't import Go libraries with names containing [^A-Za-z0-9_] #12

alanjds opened this issue Aug 21, 2018 · 3 comments
Labels
imported Imported from google/grumpy

Comments

@alanjds
Copy link

alanjds commented Aug 21, 2018

google#11 opened by @waitingkuo on 4 Jan 2017

How to import libraries when its path contains "." ?

For example, I can import "github.com/labstack/echo" in pure go by

import "github.com/labstack/echo"

In grumpy, I can import it like

from __go__.github.com.labstack.echo import New

But it will be compiled to something like this

import "github/com/labstack/echo"

Anyway to correct this issue?

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by trotterdylan
Wednesday Jan 04, 2017 at 21:02 GMT


I think long term I'll need an alternative import syntax for Go imports, like:

from __go__ import "github.com/labstack/echo"

But unfortunately that's not workable at the moment since I'm using the ast module for Python parsing and it won't accept this kind of syntax.

In the short term, perhaps something like:

New = __goimport__("github.com/labstack/echo", "New")

I'll put something together.

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by sebgoa
Tuesday Jan 10, 2017 at 13:10 GMT


Very dirty but, couldn't you temporarily hack grumpc to just detect .com and don't replace it with a /.

I am not familiar with ast, so I am going through the grumpc code now.

but yes , best would be from __go__ import "github.com/labstack/echo"

@alanjds
Copy link
Author

alanjds commented Aug 21, 2018

Comment by S-YOU
Tuesday Jan 10, 2017 at 13:22 GMT


golang.org does not include .com, I would suggest putting "github.com" and "golang.org" as special case for the time being.

@alanjds alanjds added the imported Imported from google/grumpy label Aug 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
imported Imported from google/grumpy
Projects
None yet
Development

No branches or pull requests

1 participant