open2b/scriggo

cmd/scriggo: allow to set the package name in the Scriggo file

gazerro opened this issue · 3 comments

Currently, it is not possible to set the package name with the IMPORT instruction in a Scriggo file.

For example

IMPORT github.com/3dsinteractive/uuid AS foobar

changes the package path but does not change the package name.

I propose to change the IMPORT instruction in the following way

IMPORT <package> AS <as>

As for IMPORT <package> but the path by which it can be imported is named as and the package name is the last path element of as.

IMPORT <package> WITH NAME <name>

As for IMPORT <package> but the package name is name. If AS <as> precedes WITH NAME <name>, the package path is as and the package name is name.

If the package name is not a valid Go identifier, an error occurs.

Examples

IMPORT github.com/3dsinteractive/uuid AS foo
# package has path "foo" and name "foo"
IMPORT github.com/3dsinteractive/uuid AS github.com/3dsinteractive/foo
# package has path "github.com/3dsinteractive/foo" and name "foo"
IMPORT github.com/3dsinteractive/uuid WITH NAME bar
# package has path "github.com/3dsinteractive/uuid" and name "bar"
IMPORT github.com/zoonoo/go-msgraph AS go-msgraph WITH NAME msgraph
# package has path "go-msgraph" and name "msgraph"

I agree with this proposal.

I agree too