awalterschulze / goderive

Derives and generates mundane golang functions that you do not want to maintain yourself
Apache License 2.0
1.24k stars 43 forks source link

Using package name instead of folder name #35

Closed lhemala closed 7 years ago

lhemala commented 7 years ago

First of all: goderive is a really cool tool, thanks for your work ;)

I have the problem that I use deriveKeysString where the argument is of type map[string][]*event.Sensor and is imported via import "github.com/XXX/libs.event/proto/src/go".

The name of the package "github.com/XXX/libs.event/proto/src/go" is event (which works fine in the rest of my code) but goderive uses a named import with the folder as name, resulting in the following code:

import (
    go "github.com/XXX/libs.event/proto/src/go"
)

func deriveKeysString(m map[string][]*go.Sensor) []string {
    keys := make([]string, 0, len(m))
    for key := range m {
        keys = append(keys, key)
    }
    return keys
}

This obviously won't compile since go is reserved keyword.

Is it possible to force goderive to use the package name instead of the folder name? (I know I can rename the folder, but this breaks the naming scheme as there also are folders named java or cpp

(as a workaround I use sed to change go to event)

awalterschulze commented 7 years ago

This is a bug in goderive. I will fix it, hopefully later today. Thanks for reporting.

awalterschulze commented 7 years ago

Fixed https://github.com/awalterschulze/goderive/commit/93d97ee7e57388f8e6d5503f813a3f490e90e6d9

awalterschulze commented 7 years ago

If you are using it in a project, our users list could really use some help :)

lhemala commented 7 years ago

sadly we don't have any open source repositories (yet) :(

awalterschulze commented 7 years ago

Proprietary is also cool, we can link to the company. But thats only if you want and are allowed to.