Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

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

Open
waitingkuo opened this issue Jan 4, 2017 · 3 comments
Open

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

waitingkuo opened this issue Jan 4, 2017 · 3 comments

Comments

@waitingkuo
Copy link

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?

@trotterdylan
Copy link
Contributor

trotterdylan commented Jan 4, 2017

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.

@trotterdylan trotterdylan changed the title library path includes "." Can't import Go libraries with names containing [^A-Za-z0-9_] Jan 9, 2017
@sebgoa
Copy link

sebgoa commented Jan 10, 2017

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"

@S-YOU
Copy link
Contributor

S-YOU commented Jan 10, 2017

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@trotterdylan @S-YOU @waitingkuo @sebgoa and others